Class AdminController
In: app/controllers/admin_controller.rb
Parent: ApplicationController

Methods

Public Instance methods

Add a new user to the database.

[Source]

    # File app/controllers/admin_controller.rb, line 10
10:   def add_user
11:     if request.get?
12:       @user = User.new
13:     else
14:       @user = User.new(params[:user])
15:       @user.admin = params[:user][:admin]
16:       @user.datestring = "%d.%m.%Y"
17:       @user.header = "</head><body>"
18:       @user.currency = "%0.2f Eur"
19:       @user.confirmed = "1"
20:       @user.homepage = params[:user][:homepage]
21:       @user.email = params[:user][:email]
22:       if @user.save
23:         redirect_to_index("User #{@user.name} created")
24:       end
25:     end
26:   end

confirm a newly registered user

[Source]

    # File app/controllers/admin_controller.rb, line 63
63:   def confirm_user
64:     @user = User.find(params[:id])
65:     @user.confirmed = 1
66:     @user.datestring = "%d.%m.%Y"
67:     @user.header = "</head><body>"
68:     @user.currency = "%0.2f Eur"
69:     @user.language = "en-US"
70: 
71:     if @user.update
72:       Notifier::deliver_signup_thanks(@user)
73:       flash[:notice] = "User confirmed".t
74:       redirect_to(:action => "list_users_to_confirm")
75:     else
76:       flash[:notice] = "User not confirmed".t
77:       redirect_to(:action => "list_users_to_confirm")
78:     end
79:   end

Delete the user with the given ID from the database. The model raises an exception if we attempt to delete the last user.

[Source]

    # File app/controllers/admin_controller.rb, line 32
32:   def delete_user
33:     id = params[:id]
34:     if user = User.find(id)
35:       begin
36:         if user.confirmed == 1
37:           user.destroy
38:           flash[:notice] = "User #{user.name} deleted"
39:           redirect_to(:action => :list_users)
40:         else
41:           user.destroy
42:           flash[:notice] = "User #{user.name} deleted"
43:           redirect_to(:action => :list_users_to_confirm)
44:         end
45:       rescue
46:         flash[:notice] = "Can't delete that user"
47:       end
48:     end
49: 
50:   end

[Source]

    # File app/controllers/admin_controller.rb, line 91
91:   def edit
92:     @user = User.find(params[:id])
93:   end

Show default administation page

[Source]

    # File app/controllers/admin_controller.rb, line 82
82:   def index
83:     @user = User.find(session[:user_id])
84:   end

Update Globalize localisation entries

[Source]

    # File app/controllers/admin_controller.rb, line 87
87:   def lang_db_update
88:     locale_update
89:   end

List all the users.

[Source]

    # File app/controllers/admin_controller.rb, line 53
53:   def list_users
54:     @user_pages, @all_users = paginate :users, :per_page => 10, :conditions => ["confirmed = 1"], :order => "created_at DESC"
55:   end

List all unconfirmed users

[Source]

    # File app/controllers/admin_controller.rb, line 58
58:   def list_users_to_confirm
59:     @user_pages, @all_users = paginate :users, :per_page => 10, :conditions => ["confirmed = 0"]
60:   end

[Source]

     # File app/controllers/admin_controller.rb, line 95
 95:   def update
 96:     @user = User.find(params[:id])
 97:     if params[:password] != ""
 98:       @user.hashed_password = User.hash_password(params[:password])
 99:     end
100:     @user.homepage = params[:user][:homepage]
101:     @user.email = params[:user][:email]
102:     @user.language = params[:user][:language]
103: 
104: 
105:     if @user.update #_attributes(params[:user])
106:       flash[:notice] = 'User was successfully updated.'
107:       redirect_to :action => 'edit', :id => @user
108:     else
109:       render :action => 'edit'
110:     end
111:   end

[Validate]