##// END OF EJS Templates
Reverts r10896 (#12472)....
Jean-Philippe Lang -
r10671:ca73f9905627
parent child
Show More
@@ -1,100 +1,99
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class RolesController < ApplicationController
19 19 layout 'admin'
20 20
21 21 before_filter :require_admin, :except => :index
22 22 before_filter :require_admin_or_api_request, :only => :index
23 23 before_filter :find_role, :only => [:edit, :update, :destroy]
24 24 accept_api_auth :index
25 accept_api_auth :index, :show
26 25
27 26 def index
28 27 respond_to do |format|
29 28 format.html {
30 29 @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
31 30 render :action => "index", :layout => false if request.xhr?
32 31 }
33 32 format.api {
34 33 @roles = Role.givable.all
35 34 }
36 35 end
37 36 end
38 37
39 38 def new
40 39 # Prefills the form with 'Non member' role permissions
41 40 @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
42 41 @roles = Role.sorted.all
43 42 end
44 43
45 44 def create
46 45 @role = Role.new(params[:role])
47 46 if request.post? && @role.save
48 47 # workflow copy
49 48 if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
50 49 @role.workflows.copy(copy_from)
51 50 end
52 51 flash[:notice] = l(:notice_successful_create)
53 52 redirect_to :action => 'index'
54 53 else
55 54 @roles = Role.sorted.all
56 55 render :action => 'new'
57 56 end
58 57 end
59 58
60 59 def edit
61 60 end
62 61
63 62 def update
64 63 if request.put? and @role.update_attributes(params[:role])
65 64 flash[:notice] = l(:notice_successful_update)
66 65 redirect_to :action => 'index'
67 66 else
68 67 render :action => 'edit'
69 68 end
70 69 end
71 70
72 71 def destroy
73 72 @role.destroy
74 73 redirect_to :action => 'index'
75 74 rescue
76 75 flash[:error] = l(:error_can_not_remove_role)
77 76 redirect_to :action => 'index'
78 77 end
79 78
80 79 def permissions
81 80 @roles = Role.sorted.all
82 81 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
83 82 if request.post?
84 83 @roles.each do |role|
85 84 role.permissions = params[:permissions][role.id.to_s]
86 85 role.save
87 86 end
88 87 flash[:notice] = l(:notice_successful_update)
89 88 redirect_to :action => 'index'
90 89 end
91 90 end
92 91
93 92 private
94 93
95 94 def find_role
96 95 @role = Role.find(params[:id])
97 96 rescue ActiveRecord::RecordNotFound
98 97 render_404
99 98 end
100 99 end
General Comments 0
You need to be logged in to leave comments. Login now