render :partial => 'issues/bulk_change_form'
end
- # POST /issues/bulk_change
+ # POST /issues/bulk_change?criteria
def bulk_change
verify_post_request
Internal.issues.bulkChange(params, params[:comment])
SECTION=Navigation::SECTION_RESOURCE
- verify :method => :post, :only => [:grant_users, :grant_groups ], :redirect_to => { :action => 'index' }
-
+ # GET /project_roles/@project
def index
@project=Project.by_key(params[:id])
access_denied unless is_admin?(@project)
end
- def edit_users
- @project=Project.by_key(params[:id])
- access_denied unless is_admin?(@project)
- @role = params[:role]
- end
-
- def edit_groups
- @project=Project.by_key(params[:id])
- access_denied unless is_admin?(@project)
- @role = params[:role]
- end
-
- def grant_users
- project=Project.by_key(params[:id])
- access_denied unless is_admin?(project)
-
- UserRole.grant_users(params[:users], params[:role], project.id)
- redirect_to(:action => 'index', :id => project.id)
- end
-
- def grant_groups
- project=Project.by_key(params[:id])
- access_denied unless is_admin?(project)
-
- GroupRole.grant_groups(params[:groups], params[:role], project.id)
- redirect_to(:action => 'index', :id => project.id)
- end
-
end
SECTION=Navigation::SECTION_CONFIGURATION
before_filter :admin_required
- verify :method => :post, :only => [:set_users, :set_groups, :set_default_project_groups, :set_default_project_users], :redirect_to => {:action => 'global'}
+ verify :method => :post, :only => [:set_users, :set_groups], :redirect_to => {:action => 'global'}
- # GET REQUESTS
-
+ # GET /roles/global
def global
end
+ # GET /roles/projects
def projects
params['pageSize'] = 25
params['qualifiers'] ||= 'TRK'
)
end
+ # GET /roles/edit_users[?resource=<resource>]
def edit_users
@project=Project.by_key(params[:resource]) if params[:resource].present?
@role = params[:role]
render :partial => 'edit_users'
end
- def edit_groups
- @project=Project.by_key(params[:resource]) if params[:resource].present?
- @role = params[:role]
- render :partial => 'edit_groups'
- end
-
- def apply_template_form
- bad_request('There are currently no results to apply the permission template to') if params[:projects].blank?
- @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().collect {|pt| [pt.name, pt.key]}
- render :partial => 'apply_template_form', :locals => {:components => params[:projects], :qualifier => params[:qualifier] || 'TRK'}
- end
-
- # POST REQUESTS
-
+ # POST /roles/set_users?users=<users>&role=<role>[&resource=<resource>]
def set_users
bad_request('Missing role') if params[:role].blank?
UserRole.grant_users(params[:users], params[:role], params[:resource])
render :text => '', :status => 200
end
- def set_groups
- bad_request('Missing role') if params[:role].blank?
- GroupRole.grant_groups(params[:groups], params[:role], params[:resource])
- redirect
+ # GET /roles/edit_groups[?resource=<resource>]
+ def edit_groups
+ @project=Project.by_key(params[:resource]) if params[:resource].present?
+ @role = params[:role]
+ render :partial => 'edit_groups'
end
- def set_default_project_groups
+ # POST /roles/set_groups?users=<users>&role=<role>[&resource=<resource>]
+ def set_groups
bad_request('Missing role') if params[:role].blank?
- bad_request('Missing qualifier') if params[:qualifier].blank?
- group_names = params[:groups] || []
- Property.set("sonar.role.#{params[:role]}.#{params[:qualifier]}.defaultGroups", group_names.join(','))
- redirect
+ GroupRole.grant_groups(params[:groups], params[:role], params[:resource])
+ render :text => '', :status => 200
end
- def set_default_project_users
- bad_request('Missing role') if params[:role].blank?
- bad_request('Missing qualifier') if params[:qualifier].blank?
- logins = params[:logins] || []
- Property.set("sonar.role.#{params[:role]}.#{params[:qualifier]}.defaultUsers", logins.join(','))
- redirect
+ # GET /roles/apply_template_form?projects=<projects>&qualifier=<qualifier>
+ def apply_template_form
+ bad_request('There are currently no results to apply the permission template to') if params[:projects].blank?
+ @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().collect {|pt| [pt.name, pt.key]}
+ render :partial => 'apply_template_form', :locals => {:components => params[:projects], :qualifier => params[:qualifier] || 'TRK'}
end
+ # POST /roles/apply_template?criteria
def apply_template
verify_post_request
require_parameters :template_key
redirect_to :action => 'projects'
end
- private
-
- def redirect
- redirect_to(:action => params['redirect'] || 'global', :q => params[:q], :qualifier => params[:qualifier], :page => params[:page])
- end
-
end
def users(role, resource_id=nil)
resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- user_roles=UserRole.find(:all, :include => 'user', :conditions => {:role => role, :resource_id => resource_id, :users => {:active => true}})
+ user_roles=UserRole.all(:include => 'user', :conditions => {:role => role, :resource_id => resource_id, :users => {:active => true}})
users = user_roles.map { |ur| ur.user }
Api::Utils.insensitive_sort(users) { |user| user.name }
end
def all_users
- users = User.find(:all, :conditions => ["active=?", true])
+ users = User.all(:conditions => ["active=?", true])
Api::Utils.insensitive_sort(users) { |user| user.name }
end
def groups(role, resource_id=nil)
resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- group_roles=GroupRole.find(:all, :include => 'group', :conditions => {:role => role, :resource_id => resource_id})
+ group_roles=GroupRole.all(:include => 'group', :conditions => {:role => role, :resource_id => resource_id})
groups = group_roles.map { |ur| ur.group }
Api::Utils.insensitive_sort(groups) { |group| group ? group.name : '' }
end
# verify that groups still exist
result = []
if group_names.size>0
- groups = Group.find(:all, :conditions => ['name in (?)', group_names])
+ groups = Group.all(:conditions => ['name in (?)', group_names])
result = Api::Utils.insensitive_sort(groups.map{|g| g.name})
result = ['Anyone'].concat(result) if group_names.include? 'Anyone'
end
def default_project_users(role, qualifier)
logins=(controller.java_facade.getConfigurationValue("sonar.role.#{role}.#{qualifier}.defaultUsers") || '').split(',')
- users = User.find(:all, :conditions => ['login in (?) and active=?', logins, true])
+ users = User.all(:conditions => ['login in (?) and active=?', logins, true])
Api::Utils.insensitive_sort(users) { |user| user.name }
end
+++ /dev/null
-<%
- granted_groups=groups(@role, @project.id)
- ungranted_groups=all_groups - granted_groups
-%>
-<div class="subtitle">» <a href="<%= url_for :action => 'index', :id => @project.id -%>">Back</a></div>
-<h1>Role Membership Of <%= h(@project.name) %></h1>
-<br/>
-<div>
- <form action="<%= url_for :action => 'grant_groups' -%>" method="post">
- <input name="id" value="<%= @project.id -%>" type="hidden"/>
- <input name="role" value="<%= @role -%>" type="hidden"/>
- <table>
- <tbody>
- <tr>
- <td style="padding: 5px 0" valign="top">
- <h2>Add Groups</h2>
- <select name="from" id="from" size="20" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% ungranted_groups.each do |group| %>
- <option value="<%= group ? group.id : '' -%>"><%= group_name(group) %></option>
- <% end %>
- </select>
- </td>
- <td style="padding: 0 10px;" align="center">
- <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
- <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
- <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
- <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;"><< unselect all</button>
- </td>
- <td class="box" style="padding: 5px 10px;" valign="top">
- <h2>Role: <%= role_name(@role) -%></h2>
-
- <select name="groups[]" id="to" size="20" multiple="multiple" style="margin: 5px 0; width: 300px;">
- <% granted_groups.each do |group| %>
- <option value="<%= group ? group.id : '' -%>"><%= group_name(group) %></option>
- <% end %>
- </select><br>
-
- <div style="padding: 5px 0">
- <input id="save" value="Save" onclick="SelectBox.select_all('to');submit();return false;" type="submit">
- <a href="<%= url_for :action => 'index', :id => @project.id -%>"><%= message 'cancel' -%></a>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- <script>
- SelectBox.init('from');
- SelectBox.init('to');
- </script>
-</div>
+++ /dev/null
-<%
- granted_users=users(@role, params[:id])
- ungranted_users=all_users - granted_users
-%>
-<div class="subtitle">» <a href="<%= url_for :action => 'index', :id => @project.id -%>">Back</a></div>
-<h1>Role Membership Of <%= h(@project.name) %></h1>
-<br/>
-<div id="main_content">
- <form action="<%= url_for :action => 'grant_users' -%>" method="post">
- <input name="id" value="<%= params[:id] -%>" type="hidden"/>
- <input name="role" value="<%= @role -%>" type="hidden"/>
- <input name="redirect" value="<%= params[:redirect] -%>" type="hidden"/>
- <table>
- <tbody>
- <tr>
- <td style="padding: 5px 0;" valign="top">
- <h2>Add Users</h2>
- <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
- <% ungranted_users.sort.each do |user| %>
- <option value="<%= user.id -%>"><%= h user.name -%></option>
- <% end %>
- </select>
- </td>
- <td style="padding: 0 10px;" align="center">
- <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
- <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
- <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
- <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;"><< unselect all</button>
- </td>
- <td class="box" style="padding: 5px 10px;" valign="top">
- <h2>Role: <%= role_name(@role) -%></h2>
-
- <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
- <%= options_from_collection_for_select(granted_users, "id", "name") %>
- </select><br>
-
- <div style="padding: 5px 0;">
- <input id="save" value="Save" onclick="SelectBox.select_all('to');submit();return false;" type="submit">
- <a href="<%= url_for :action => 'index', :id => @project.id -%>"><%= message 'cancel' -%></a>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- <script>
- SelectBox.init('from');
- SelectBox.init('to');
- </script>
-</div>
<td valign="top"><b>Administrators</b><br/><span class="small gray">Ability to perform administration functions for a project by accessing its settings.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="admin-role-users"><%= users('admin', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_users', :id => @project.id, :role => 'admin'}, {:id => 'select-admin-edit-users', :class => 'link-action'} %>)
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'admin', :resource => @project.id},
+ :id => 'select-admin-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="admin-role-groups"><%= groups('admin', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_groups', :id => @project.id, :role => 'admin'}, {:id => 'select-admin-edit-groups', :class => 'link-action'} %>)
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'admin', :resource => @project.id},
+ :id => 'select-admin-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
</td>
</tr>
<tr class="odd">
<td valign="top"><b>Users</b><br/><span class="small gray">Ability to navigate through every service of a project, except viewing source code and settings.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="user-role-users"><%= users('user', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_users', :id => @project.id, :role => 'user'}, {:id => 'select-user-edit-users', :class => 'link-action'} %>)
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'user', :resource => @project.id},
+ :id => 'select-user-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="user-role-groups"><%= groups('user', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_groups', :id => @project.id, :role => 'user'}, {:id => 'select-user-edit-groups', :class => 'link-action'} %>)
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'user', :resource => @project.id},
+ :id => 'select-user-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
</td>
</tr>
<tr class="even" >
<td valign="top"><b>Code viewers</b><br/><span class="small gray">Ability to view source code of a project.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="codeviewer-role-users"><%= users('codeviewer', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_users', :id => @project.id, :role => 'codeviewer'}, {:id => 'select-codeviewer-edit-users', :class => 'link-action'} %>)
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'codeviewer', :resource => @project.id},
+ :id => 'select-codeviewer-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="codeviewer-role-groups"><%= groups('codeviewer', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to "select", {:action => 'edit_groups', :id => @project.id, :role => 'codeviewer'}, {:id => 'select-codeviewer-edit-groups', :class => 'link-action'} %>)
- </td>
+ (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'codeviewer', :resource => @project.id},
+ :id => 'select-codeviewer-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
+
</tr>
</tbody>
</table>
\ No newline at end of file
<%
- granted_groups=groups(@role, params[:resource])
+ project_id = @project ? @project.id : nil
+ granted_groups=groups(@role, project_id)
ungranted_groups=all_groups - granted_groups
%>
<div>
- <form id="permission-groups-form" action="<%= url_for :action => 'set_groups' -%>" method="post">
- <input name="resource" value="<%= params[:resource] -%>" type="hidden"/>
+ <form id="permission-groups-form" action="<%= url_for :controller => :roles, :action => :set_groups -%>" method="post">
+ <input name="resource" value="<%= project_id -%>" type="hidden"/>
<input name="role" value="<%= @role -%>" type="hidden"/>
<fieldset>
<div class="modal-head">
<%
- granted_users=users(@role, params[:resource])
+ project_id = @project ? @project.id : nil
+ granted_users=users(@role, project_id)
ungranted_users=(all_users - granted_users)
%>
-<form id="permission-users-form" action="<%= url_for :action => 'set_users' -%>" method="post">
- <input name="resource" value="<%= params[:resource] -%>" type="hidden"/>
+<form id="permission-users-form" action="<%= url_for :controller => :roles, :action => :set_users -%>" method="post">
+ <input name="resource" value="<%= project_id -%>" type="hidden"/>
<input name="role" value="<%= @role -%>" type="hidden" />
<fieldset>
<div class="modal-head">