Class UsersController
In: app/controllers/users_controller.rb
Parent: ApplicationController

Methods

Classes and Modules

Class UsersController::Helper

Public Instance methods

Body methods

[Source]

     # File app/controllers/users_controller.rb, line 169
169:   def about
170:     render_body 'logis/small_snippet',
171:         :locals => {:logi => @logi, :id => 'site_description'}
172:   end

[Source]

     # File app/controllers/users_controller.rb, line 180
180:   def badge
181:     peer_group = current_prefs.peer_group
182:     membership = peer_group.membership_for(@user)
183:     percentile = membership.capped_percentile
184:     respond_to do |format|
185:       format.png do
186:         build_save_and_send_badge(@user.name, @user.home_page_tag_string,
187:             GlobalConfig.domain, peer_group.home_page_tag_string, 
188:             percentile)
189:       end
190:     end
191:   end

[Source]

    # File app/controllers/users_controller.rb, line 66
66:   def create
67:     @user = User.new(params[:user])
68:     @user.save do |result|
69:       if result
70:         @user.deliver_welcome!
71:         if session[:invitation].nil?
72:           flash[:notice] = t 'c.users.created'
73:           redirect_to_return_url_or_default
74:         else
75:           flash[:notice] = t 'c.users.created_accept_invitation'
76:           redirect_to edit_invitation_url(session[:invitation])
77:         end
78:       else
79:         flash.now[:error] = t 'c.users.error_creating'
80:         if !@user.openid_identifier.nil?
81:           @selected = "openid"
82:         end
83:         render :action => :new
84:       end
85:     end
86:   end

[Source]

     # File app/controllers/users_controller.rb, line 143
143:   def destroy
144:     if @user != User.admin
145:       if @user.destroy
146:         flash[:notice] = t 'c.users.deleted'
147:         redirect_to root_url
148:       else
149:         flash[:warning] = t 'c.users.error_deleting'
150:         render :action => 'edit'
151:       end
152:     else
153:       flash[:error] = t 'c.users.error_deleting_admin'
154:       redirect_to user_url(@user)
155:     end
156:   end

[Source]

    # File app/controllers/users_controller.rb, line 88
88:   def edit
89:     @prefs_profile = @user.default_prefs_profile
90:     self.read_log_log_subscriptions
91:   end

[Source]

     # File app/controllers/users_controller.rb, line 193
193:   def medal
194:     respond_to do |format|
195:       format.png do
196:         build_save_and_send_medal(params[:percentile].to_i)
197:       end
198:     end
199:   end

[Source]

    # File app/controllers/users_controller.rb, line 55
55:   def new
56:     @selected = params[:selected]
57:     @user = User.new()
58:     respond_to do |format|
59:       format.html
60:       format.js do
61:         select_body(@selected)
62:       end
63:     end
64:   end

Tabbed methods

[Source]

     # File app/controllers/users_controller.rb, line 160
160:   def normal
161:     render_ajax_body :partial => 'method.html.erb',
162:         :locals => {:selected => @selected}
163:   end
openid()

Alias for normal

Methods

[Source]

    # File app/controllers/users_controller.rb, line 40
40:   def show
41:     @logis = Logi.recent.created_by_user(@user).paginate(
42:         :page => params[:page], :per_page => 9)
43:     respond_to do |format|
44:       format.html do
45:         render :layout => 'user_page'
46:       end
47:       format.js do
48:         render :partial => 'logis/snippets_pagination',
49:             :locals => {:logis => @logis, :selected => 'recent_by_author',
50:                 :no_top => true}
51:       end
52:     end
53:   end

[Source]

     # File app/controllers/users_controller.rb, line 174
174:   def side_panel
175:     @remark = Remark.new
176:     @remarks = @logi.remarks.find(:all,
177:         :limit => 10, :order => ["created_at DESC"])
178:   end

[Source]

     # File app/controllers/users_controller.rb, line 93
 93:   def update
 94:     @prefs_profile = @user.default_prefs_profile
 95: 
 96:     if params[:user]
 97:       if params[:user][:delete]
 98:         render_to_confirm_delete :text => t('c.users.confirm_delete'),
 99:             :url => user_url(@user), :cancel_url => edit_user_url(current_user)
100:         return
101:       end
102:       @user.attributes = params[:user]
103:       @user.save do |result|
104:         if result
105:           flash[:notice] = t 'c.users.updated'
106:           redirect_to_return_url_or_default(user_url(@user))
107:         else
108:           flash[:error] = t 'c.users.error_updating'
109:           render :action => :edit
110:         end
111:       end
112:     elsif params[:prefs_profile]
113:       # For now prefs-profiles are edited here too
114:       @prefs_profile.default_peer_group = PeerGroup.find(
115:           params[:prefs_profile][:default_peer_group_id])
116:       if @prefs_profile.save 
117:         flash[:notice] = t 'c.users.settings_updated'
118:         redirect_to_return_url_or_default(user_url(@user))
119:       else
120:         flash[:error] = t 'c.users.error_updating_settings'
121:         render :action => 'edit'
122:       end
123:     elsif params[:log_log_subscription]
124:       self.read_log_log_subscriptions
125:       @subscriptions.each_pair do |name, subscription|
126:         if params[:log_log_subscription][name]
127:           if !subscription
128:             channel = (name == :personalized_log ? "for_" + @user.unix_name :
129:                 "logis")
130:             ll_s = LogLogSubscription.new(:user => @user, :channel => channel, 
131:                 :period => (name == :personalized_log ? "daily" : "weekly"))
132:             ll_s.save
133:           end # else do nothing
134:         elsif subscription
135:           subscription.destroy
136:         end
137:       end
138:       flash[:notice] = t 'c.users.settings_updated'
139:       redirect_to_return_url_or_default(user_url(@user))
140:     end
141:   end

Protected Instance methods

Helper methods

[Source]

     # File app/controllers/users_controller.rb, line 241
241:   def build_save_and_send_badge(user_name, normalized_name, pg_name, pg_normalized_name,
242:       percentile)
243:     img = LaurelBuilder.build_badge(user_name, pg_name, percentile, 
244:         t('c.users.at'), self.helpers)
245:     dir = "#{RAILS_ROOT}/public/do/users/#{normalized_name}/badge"
246:     file = "#{dir}/#{pg_normalized_name}.png"
247:     self.save_and_send_image(img, dir, file)
248:   end

[Source]

     # File app/controllers/users_controller.rb, line 250
250:   def build_save_and_send_medal(percentile)
251:     img = LaurelBuilder.build_medal(percentile, self.helpers)
252:     dir = "#{RAILS_ROOT}/public/do/medals"
253:     file = "#{dir}/#{percentile.to_s}.png"
254:     self.save_and_send_image(img, dir, file)
255:   end

Filter-methods

[Source]

     # File app/controllers/users_controller.rb, line 205
205:   def find
206:     @user = User.find_by_id(params[:id])
207:     if !@user
208:       @user = User.find_by_home_page_tag_string(params[:id])
209:     end
210:   end

[Source]

     # File app/controllers/users_controller.rb, line 212
212:   def find_users_logi
213:     self.find
214:     link = @user.home_page_link
215:     link.resolve
216:     @logi = link.volatile_to_logi 
217:   end

[Source]

     # File app/controllers/users_controller.rb, line 265
265:   def helpers
266:     Helper.instance
267:   end

Helper methods

[Source]

     # File app/controllers/users_controller.rb, line 229
229:   def read_log_log_subscriptions
230:     @subscriptions = {}
231:     [:personalized_log, :logis_log].each do |name|
232:       channel = (name == :personalized_log ? "for_" + @user.unix_name :
233:           "logis")
234:       @subscriptions[name] = LogLogSubscription.find_by_user_id_and_channel(
235:           @user, channel)
236:     end
237:   end

[Source]

     # File app/controllers/users_controller.rb, line 219
219:   def require_current
220:     if self.current_user != @user
221:       flash[:error] = t 'c.users.error_permissions'
222:       redirect_to user_url(@user)
223:       return false
224:     end
225:   end

[Source]

     # File app/controllers/users_controller.rb, line 257
257:   def save_and_send_image(img, dir, file)
258:     system "mkdir -p '#{dir}'"
259:     img.write(file) # Next time the saved image will be used.
260:     img.destroy!
261:     send_file file, :disposition => 'inline',
262:         :type => 'image/png'
263:   end

[Validate]