def projects
@projects=Project.find(:all,
:conditions => {:enabled=>true, :scope => Project::SCOPE_SET, :qualifier => [Project::QUALIFIER_VIEW, Project::QUALIFIER_SUBVIEW, Project::QUALIFIER_PROJECT]},
- :include => ['user_roles', 'group_roles']).sort{|a,b| a.name.downcase<=>b.name.downcase}
+ :include => ['user_roles', 'group_roles'])
+ Api::Utils.insensitive_sort!(@projects){|project| project.name}
end
def edit_users
def users(role, resource_id=nil)
resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- user_roles=UserRole.find(:all, :conditions => {:role => role, :resource_id => resource_id})
- user_roles.map {|ur| ur.user}.sort
+ user_roles=UserRole.find(:all, :include => 'user', :conditions => {:role => role, :resource_id => resource_id})
+ users = user_roles.map { |ur| ur.user }
+ Api::Utils.insensitive_sort(users) {|user| user.name}
end
def all_users
- User.find(:all, :conditions => ["active=?", true], :order => 'name')
+ users = User.find(: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, :conditions => {:role => role, :resource_id => resource_id})
- group_roles.map{|ur| ur.group}.sort do |x,y|
- x ? x<=>y : -1
- end
+ groups = group_roles.map{|ur| ur.group}
+ Api::Utils.insensitive_sort(groups) {|group| group ? group.name : ''}
end
def all_groups
- [nil].concat(Group.find(:all, :order => 'name'))
+ [nil].concat(Api::Utils.insensitive_sort(Group.all) {|group| group.name})
end
def group_name(group)
<table>
<tbody>
<tr>
- <td style="padding: 5px 0pt;" valign="top">
+ <td style="padding: 5px 0;" valign="top">
<h2>Ungranted groups</h2>
- <select name="from" id="from" size="20" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% ungranted_groups.sort.each do |group| %>
+ <select name="from" id="from" size="20" style="margin: 5px 0; width: 300px;" multiple="multiple">
+ <% ungranted_groups.each do |group| %>
<option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
<% end %>
</select>
</td>
- <td style="padding: 0pt 10px;" align="center">
+ <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>
<h2>Role: <%= role_name(@role) -%></h2>
<select name="groups[]" id="to" size="20" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
- <% granted_groups.sort.each do |group| %>
+ <% granted_groups.each do |group| %>
<option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
<% end %>
</select><br>
<table>
<tbody>
<tr>
- <td style="padding: 5px 0pt;" valign="top">
+ <td style="padding: 5px 0;" valign="top">
<h2>Ungranted users</h2>
- <select name="from" id="from" size="30" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% ungranted_users.sort.each do |user| %>
+ <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
+ <% ungranted_users.each do |user| %>
<option value="<%= user.id -%>"><%= user.name -%></option>
<% end %>
</select>
</td>
- <td style="padding: 0pt 10px;" align="center">
+ <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>
<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;">
+ <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0; width: 300px;">
<%= options_from_collection_for_select(granted_users, "id", "name") %>
</select><br>
- <div style="padding: 5px 0pt;">
+ <div style="padding: 5px 0;">
<input id="save" value="Save" onclick="SelectBox.select_all('to');submit();return false;" type="submit">
</div>
</td>