##// END OF EJS Templates
Prevent admin users from locking their own account (#1276)....
Jean-Philippe Lang -
r1434:7f134a8c6795
parent child
Show More
@@ -1,57 +1,57
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module UsersHelper
18 module UsersHelper
19 def status_options_for_select(selected)
19 def status_options_for_select(selected)
20 options_for_select([[l(:label_all), ''],
20 options_for_select([[l(:label_all), ''],
21 [l(:status_active), 1],
21 [l(:status_active), 1],
22 [l(:status_registered), 2],
22 [l(:status_registered), 2],
23 [l(:status_locked), 3]], selected)
23 [l(:status_locked), 3]], selected)
24 end
24 end
25
25
26 # Options for the new membership projects combo-box
26 # Options for the new membership projects combo-box
27 def projects_options_for_select(projects)
27 def projects_options_for_select(projects)
28 options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
28 options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
29 projects_by_root = projects.group_by(&:root)
29 projects_by_root = projects.group_by(&:root)
30 projects_by_root.keys.sort.each do |root|
30 projects_by_root.keys.sort.each do |root|
31 options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
31 options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
32 projects_by_root[root].sort.each do |project|
32 projects_by_root[root].sort.each do |project|
33 next if project == root
33 next if project == root
34 options << content_tag('option', '&#187; ' + h(project.name), :value => project.id)
34 options << content_tag('option', '&#187; ' + h(project.name), :value => project.id)
35 end
35 end
36 end
36 end
37 options
37 options
38 end
38 end
39
39
40 def change_status_link(user)
40 def change_status_link(user)
41 url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]}
41 url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]}
42
42
43 if user.locked?
43 if user.locked?
44 link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
44 link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
45 elsif user.registered?
45 elsif user.registered?
46 link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
46 link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
47 else
47 elsif user != User.current
48 link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
48 link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
49 end
49 end
50 end
50 end
51
51
52 def user_settings_tabs
52 def user_settings_tabs
53 tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
53 tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
54 {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
54 {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
55 ]
55 ]
56 end
56 end
57 end
57 end
General Comments 0
You need to be logged in to leave comments. Login now