Class: Admin::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::UsersController
- Defined in:
- app/controllers/admin/users_controller.rb
Overview
Fat Free CRM Copyright © 2008-2011 by Michael Dvorkin
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
-
#confirm ⇒ Object
GET /admin/users/1/confirm AJAX —————————————————————————-.
-
#create ⇒ Object
POST /admin/users POST /admin/users.xml AJAX —————————————————————————-.
-
#destroy ⇒ Object
DELETE /admin/users/1 DELETE /admin/users/1.xml AJAX —————————————————————————-.
-
#edit ⇒ Object
GET /admin/users/1/edit AJAX —————————————————————————-.
-
#index ⇒ Object
GET /admin/users GET /admin/users.xml HTML —————————————————————————-.
-
#new ⇒ Object
GET /admin/users/new GET /admin/users/new.xml AJAX —————————————————————————-.
-
#reactivate ⇒ Object
PUT /admin/users/1/reactivate PUT /admin/users/1/reactivate.xml AJAX —————————————————————————-.
-
#show ⇒ Object
GET /admin/users/1 GET /admin/users/1.xml —————————————————————————-.
-
#suspend ⇒ Object
PUT /admin/users/1/suspend PUT /admin/users/1/suspend.xml AJAX —————————————————————————-.
-
#update ⇒ Object
PUT /admin/users/1 PUT /admin/users/1.xml AJAX —————————————————————————-.
Instance Method Details
#confirm ⇒ Object
GET /admin/users/1/confirm AJAX
82 83 84 |
# File 'app/controllers/admin/users_controller.rb', line 82 def confirm respond_with(@user) end |
#create ⇒ Object
POST /admin/users POST /admin/users.xml AJAX
58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/admin/users_controller.rb', line 58 def create params[:user][:password_confirmation] = nil if params[:user][:password_confirmation].blank? @user = User.new(params[:user]) @user.admin = (params[:user][:admin] == "1") @user.save_without_session_maintenance @users = get_users respond_with(@user) end |
#destroy ⇒ Object
DELETE /admin/users/1 DELETE /admin/users/1.xml AJAX
89 90 91 92 93 94 95 |
# File 'app/controllers/admin/users_controller.rb', line 89 def destroy unless @user.destroy flash[:warning] = t(:msg_cant_delete_user, @user.full_name) end respond_with(@user) end |
#edit ⇒ Object
GET /admin/users/1/edit AJAX
47 48 49 50 51 52 53 |
# File 'app/controllers/admin/users_controller.rb', line 47 def edit if params[:previous].to_s =~ /(\d+)\z/ @previous = User.find_by_id($1) || $1.to_i end respond_with(@user) end |
#index ⇒ Object
GET /admin/users GET /admin/users.xml HTML
26 27 28 29 |
# File 'app/controllers/admin/users_controller.rb', line 26 def index @users = get_users(:page => params[:page]) respond_with(@users) end |
#new ⇒ Object
GET /admin/users/new GET /admin/users/new.xml AJAX
41 42 43 |
# File 'app/controllers/admin/users_controller.rb', line 41 def new respond_with(@user) end |
#reactivate ⇒ Object
PUT /admin/users/1/reactivate PUT /admin/users/1/reactivate.xml AJAX
113 114 115 116 117 |
# File 'app/controllers/admin/users_controller.rb', line 113 def reactivate @user.update_attribute(:suspended_at, nil) respond_with(@user) end |
#show ⇒ Object
GET /admin/users/1 GET /admin/users/1.xml
34 35 36 |
# File 'app/controllers/admin/users_controller.rb', line 34 def show respond_with(@user) end |
#suspend ⇒ Object
PUT /admin/users/1/suspend PUT /admin/users/1/suspend.xml AJAX
104 105 106 107 108 |
# File 'app/controllers/admin/users_controller.rb', line 104 def suspend @user.update_attribute(:suspended_at, Time.now) if @user != @current_user respond_with(@user) end |
#update ⇒ Object
PUT /admin/users/1 PUT /admin/users/1.xml AJAX
71 72 73 74 75 76 77 78 |
# File 'app/controllers/admin/users_controller.rb', line 71 def update params[:user][:password_confirmation] = nil if params[:user][:password_confirmation].blank? @user = User.find(params[:id]) @user.update_attributes(params[:user]) @user.admin = (params[:user][:admin] == "1") respond_with(@user) end |