Class: Forge::UsersController
Instance Method Summary
collapse
#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor
#app_init
Instance Method Details
#approve ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 55
def approve
if @user.id == current_user.id
flash[:warning] = 'You cannot unapprove yourself'
else
@user.approved = @user.approved? ? false : true
@user.save
UserMailer.approved(@user).deliver if @user.approved?
end
redirect_to forge_users_path
end
|
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 20
def create
@user = User.new(params[:user])
@user.role_ids = params[:role_ids]
@user.approved = true unless @user.role_ids.join(" ").match(/1|2/).blank?
if @user.save
flash[:notice] = 'User was successfully created.'
redirect_to(forge_users_path)
else
render :action => "new"
end
end
|
#destroy ⇒ Object
50
51
52
53
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 50
def destroy
@user.destroy
redirect_to(forge_users_path)
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 5
def index
respond_to do |format|
format.html { @users = User.paginate(:per_page => 10, :page => params[:page]) }
format.js {
params[:q] ||= ''
@users = User.where("LOWER(email) LIKE ?", "%#{params[:q].downcase}%")
render :partial => "user", :collection => @users
}
end
end
|
#new ⇒ Object
16
17
18
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 16
def new
@user = User.new
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/forge/app/controllers/forge/users_controller.rb', line 32
def update
params[:user].delete_if { |key, value| [:password, :password_confirmation].include?(key.to_sym) && value.blank? } if current_user.is_admin? || current_user.is_super_admin?
if current_user.is_admin?
params[:role_ids].delete(Role.find_by_title("Super Admin").id.to_s) rescue nil end
@user.role_ids = params[:role_ids]
end
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
redirect_to(forge_users_path)
else
render :action => "edit"
end
end
|