Project

General

Profile

Patch #11057 » 0001-Confirm-admin-flag-change-on-a-separate-tab.patch

Alex Shulgin, 2012-06-22 22:57

View differences:

app/controllers/users_controller.rb
164 164
      respond_to do |format|
165 165
        format.html {
166 166
          flash[:notice] = l(:notice_successful_update)
167
          redirect_to :back
167
          redirect_to :controller => 'users', :action => 'edit', :tab => params[:tab]
168 168
        }
169 169
        format.api  { head :ok }
170 170
      end
app/helpers/users_helper.rb
53 53

  
54 54
  def user_settings_tabs
55 55
    tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
56
            {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
57
            ]
56
            {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural},
57
            {:name => 'admin', :partial => 'users/admin', :label => :label_administration}]
58 58
    if Group.all.any?
59 59
      tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
60 60
    end
app/views/users/_admin.html.erb
1
<% disabled = (@user == User.current) %>
2

  
3
<% form_for(:user, :url => { :action => 'update' }, :html => {:method => :put}) do %>
4
  <%= hidden_field_tag 'tab', 'admin', :id => nil %>
5
  <div class="warning">
6
    <%=l :text_administrator_flag_warning %>
7
  </div>
8
  <fieldset class="box tabular">
9
    <legend><%=l(:label_administration)%></legend>
10
    <p>
11
      <%= hidden_field_tag 'user[admin]', '0', :id => nil %>
12
      <%= label_tag 'user[admin]', l(:field_admin) %>
13
      <%= check_box_tag 'user[admin]', '1', @user.admin?, :disabled => disabled %>
14
    </p>
15
  </fieldset>
16
  <%= submit_tag(l(:button_save)) unless disabled %>
17
<% end %>
app/views/users/_form.html.erb
18 18
    <p><%= custom_field_tag_with_label :user, value %></p>
19 19
  <% end %>
20 20

  
21
  <p><%= f.check_box :admin, :disabled => (@user == User.current) %></p>
22 21
  <%= call_hook(:view_users_form, :user => @user, :form => f) %>
23 22
</fieldset>
24 23

  
config/locales/en.yml
961 961
  text_scm_command_version: Version
962 962
  text_scm_config: You can configure your scm commands in config/configuration.yml. Please restart the application after editing it.
963 963
  text_scm_command_not_available: Scm command is not available. Please check settings on the administration panel.
964
  text_administrator_flag_warning: "Administrator flag grants a user permissions to access and change every aspect of your Redmine instance.  Please mean it when you change it.  As a precaution, you cannot revoke administrator flag from yourself."
964 965

  
965 966
  default_role_manager: Manager
966 967
  default_role_developer: Developer
(2-2/2)