Class: Cms::UsersController
Instance Method Summary
collapse
#create, #destroy, #edit, #new, #show, #update
Methods included from PageHelper
#able_to?, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet
Methods included from PathHelper
#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path
#handle_access_denied, #handle_server_error, included
Instance Method Details
#change_password ⇒ Object
38
39
40
|
# File 'app/controllers/cms/users_controller.rb', line 38
def change_password
user
end
|
#disable ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/cms/users_controller.rb', line 51
def disable
begin
user.disable!
flash[:notice] = "User #{user.login} disabled"
rescue Exception => e
flash[:error] = e.message
end
redirect_to cms_users_path
end
|
#enable ⇒ Object
61
62
63
64
|
# File 'app/controllers/cms/users_controller.rb', line 61
def enable
user.enable!
redirect_to cms_users_path
end
|
#index ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/cms/users_controller.rb', line 13
def index
query, conditions = [], []
unless params[:show_expired]
query << "expires_at IS NULL OR expires_at >= ?"
conditions << Time.now.utc
end
unless params[:key_word].blank?
query << %w(login email first_name last_name).collect { |f| "lower(#{f}) LIKE lower(?)" }.join(" OR ")
4.times { conditions << "%#{params[:key_word]}%" }
end
unless params[:group_id].to_i == 0
query << "user_group_memberships.group_id = ?"
conditions << params[:group_id]
end
query.collect! { |q| "(#{q})"}
conditions = conditions.unshift(query.join(" AND "))
per_page = params[:per_page] || 10
@users = User.paginate(:page => params[:page], :per_page => per_page, :include => :user_group_memberships, :conditions => conditions, :order => "first_name, last_name, email")
end
|
#update_password ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'app/controllers/cms/users_controller.rb', line 42
def update_password
if user.update_attributes(params[:user])
flash[:notice] = "Password for '#{user.login}' was changed"
redirect_to(current_user.able_to?(:administrate) ? cms_users_path : cms_user_path(user))
else
render :action => 'change_password'
end
end
|