diaspora/app/controllers/users_controller.rb
zhitomirskiyi df4ebb286d accept invitation feature passing
wip, added a form to add aspect to the contact list

added files

typo

render the partial

remote friend

specifying the provider for the route

refactored local person person friend finder functionality to use the partial

typo

trying to use the stream
2011-02-08 16:40:28 -08:00

111 lines
3.6 KiB
Ruby

# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class UsersController < ApplicationController
require File.join(Rails.root, 'lib/diaspora/ostatus_builder')
require File.join(Rails.root, 'lib/diaspora/exporter')
require File.join(Rails.root, 'lib/collect_user_photos')
before_filter :authenticate_user!, :except => [:new, :create, :public]
respond_to :html
def edit
@aspect = :user_edit
@user = current_user
end
def update
@user = current_user
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
params[:user].delete(:language) if params[:user][:language].blank?
# change email notifications
if params[:user][:disable_mail]
@user.update_attributes(:disable_mail => params[:user][:disable_mail])
flash[:notice] = I18n.t 'users.update.email_notifications_changed'
# change passowrd
elsif params[:user][:current_password] && params[:user][:password] && params[:user][:password_confirmation]
if @user.update_with_password(params[:user])
flash[:notice] = I18n.t 'users.update.password_changed'
else
flash[:error] = I18n.t 'users.update.password_not_changed'
end
elsif params[:user][:language]
if @user.update_attributes(:language => params[:user][:language])
flash[:notice] = I18n.t 'users.update.language_changed'
else
flash[:error] = I18n.t 'users.update.language_not_changed'
end
elsif params[:user][:a_ids]
@user.aspects.update_all(:open => false)
unless params[:user][:a_ids] == ["home"]
@user.aspects.where(:id => params[:user][:a_ids]).update_all(:open => true)
end
end
redirect_to edit_user_path(@user)
end
def destroy
current_user.destroy
sign_out current_user
flash[:notice] = I18n.t 'users.destroy'
redirect_to root_path
end
def public
user = User.find_by_username(params[:username])
if user
director = Diaspora::Director.new
ostatus_builder = Diaspora::OstatusBuilder.new(user)
render :xml => director.build(ostatus_builder), :content_type => 'application/atom+xml'
else
flash[:error] = I18n.t 'users.public.does_not_exist', :username => params[:username]
redirect_to root_url
end
end
def getting_started
@aspect = :getting_started
@user = current_user
@person = @user.person
@profile = @user.profile
@services = @user.services
@requests = Request.where(:recipient_id => @person.id).all
@step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1
@step ||= 1
if @step == 3
service = current_user.services.where(:type => "Services::Facebook").first
@friends = service ? service.finder : {}
elsif @step == 4
@user.getting_started = false
@user.save
end
render "users/getting_started"
end
def getting_started_completed
user = current_user
user.update_attributes( :getting_started => false )
redirect_to root_path
end
def export
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
send_data exporter.execute(current_user), :filename => "#{current_user.username}_diaspora_data.xml", :type => :xml
end
def export_photos
tar_path = PhotoMover::move_photos(current_user)
send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" )
end
end