##// END OF EJS Templates
Introduce virtual MenuNodes (#15880)....
Introduce virtual MenuNodes (#15880). They are characterized by having a blank url. they will only be rendered if the user is authorized to see at least one of its children. they render as links which do nothing when clicked. Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15501 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r15119:53710d80fc88
Show More
groups_controller.rb
149 lines | 3.8 KiB | text/x-ruby | RubyLexer
/ app / controllers / groups_controller.rb
Jean-Philippe Lang
User groups branch merged....
r2755 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
User groups branch merged....
r2755 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784 #
Jean-Philippe Lang
User groups branch merged....
r2755 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784 #
Jean-Philippe Lang
User groups branch merged....
r2755 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class GroupsController < ApplicationController
Jean-Philippe Lang
Adds an admin layout that displays the admin menu in the sidebar....
r3062 layout 'admin'
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
User groups branch merged....
r2755 before_filter :require_admin
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 before_filter :find_group, :except => [:index, :new, :create]
accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
Require password re-entry for sensitive actions (#19851)....
r13951 require_sudo_mode :add_users, :remove_user, :create, :update, :destroy, :edit_membership, :destroy_membership
Jean-Philippe Lang
User groups branch merged....
r2755 helper :custom_fields
Jean-Philippe Lang
Adds a single controller for users and groups memberships and support for adding multiple projects at once (#11702)....
r13116 helper :principal_memberships
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
User groups branch merged....
r2755 def index
respond_to do |format|
Jean-Philippe Lang
Count users with a single query on group list (#16905)....
r12874 format.html {
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 @groups = Group.sorted.to_a
Jean-Philippe Lang
Count users with a single query on group list (#16905)....
r12874 @user_count_by_group_id = user_count_by_group_id
}
Jean-Philippe Lang
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976)....
r13053 format.api {
scope = Group.sorted
scope = scope.givable unless params[:builtin] == '1'
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 @groups = scope.to_a
Jean-Philippe Lang
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976)....
r13053 }
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
def show
respond_to do |format|
Jean-Philippe Lang
Removed auto-generated comments....
r9564 format.html
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 format.api
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
def new
@group = Group.new
end
def create
Jean-Philippe Lang
Use safe_attributes in GroupsController....
r9563 @group = Group.new
@group.safe_attributes = params[:group]
Jean-Philippe Lang
User groups branch merged....
r2755
respond_to do |format|
if @group.save
Jean-Philippe Lang
Adds 'Create and continue' button on the new group form....
r6184 format.html {
flash[:notice] = l(:notice_successful_create)
redirect_to(params[:continue] ? new_group_path : groups_path)
}
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 format.api { render :action => 'show', :status => :created, :location => group_url(@group) }
Jean-Philippe Lang
User groups branch merged....
r2755 else
format.html { render :action => "new" }
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 format.api { render_validation_errors(@group) }
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
end
Jean-Philippe Lang
Removed auto-generated comments....
r9564 def edit
end
Jean-Philippe Lang
User groups branch merged....
r2755 def update
Jean-Philippe Lang
Use safe_attributes in GroupsController....
r9563 @group.safe_attributes = params[:group]
Jean-Philippe Lang
User groups branch merged....
r2755
respond_to do |format|
Jean-Philippe Lang
Use safe_attributes in GroupsController....
r9563 if @group.save
Jean-Philippe Lang
User groups branch merged....
r2755 flash[:notice] = l(:notice_successful_update)
format.html { redirect_to(groups_path) }
Jean-Philippe Lang
Fixed that 200 API responses have a body containing one space (#11388)....
r9792 format.api { render_api_ok }
Jean-Philippe Lang
User groups branch merged....
r2755 else
format.html { render :action => "edit" }
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 format.api { render_validation_errors(@group) }
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
end
def destroy
@group.destroy
respond_to do |format|
Jean-Philippe Lang
Use named routes in controllers....
r10752 format.html { redirect_to(groups_path) }
Jean-Philippe Lang
Fixed that 200 API responses have a body containing one space (#11388)....
r9792 format.api { render_api_ok }
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
Moved new group user to its own action GroupsController#new_users....
r13220 def new_users
end
Jean-Philippe Lang
User groups branch merged....
r2755 def add_users
Jean-Philippe Lang
Error when adding user to group where he is already assigned (#18665)....
r13403 @users = User.not_in_group(@group).where(:id => (params[:user_id] || params[:user_ids])).to_a
@group.users << @users
Jean-Philippe Lang
User groups branch merged....
r2755 respond_to do |format|
Jean-Philippe Lang
Use named routes in controllers....
r10752 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
Jean-Philippe Lang
Removes RJS from GroupsController....
r9861 format.js
Jean-Philippe Lang
Error when adding user to group where he is already assigned (#18665)....
r13403 format.api {
if @users.any?
render_api_ok
else
render_api_errors "#{l(:label_user)} #{l('activerecord.errors.messages.invalid')}"
end
}
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
User groups branch merged....
r2755 def remove_user
Jean-Philippe Lang
Adds routes for group users....
r7826 @group.users.delete(User.find(params[:user_id])) if request.delete?
Jean-Philippe Lang
User groups branch merged....
r2755 respond_to do |format|
Jean-Philippe Lang
Use named routes in controllers....
r10752 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
Jean-Philippe Lang
Removes RJS from GroupsController....
r9861 format.js
Jean-Philippe Lang
Fixed that 200 API responses have a body containing one space (#11388)....
r9792 format.api { render_api_ok }
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
User groups branch merged....
r2755 def autocomplete_for_user
Jean-Philippe Lang
Adds pagination to users list when adding project or group members (#9549)....
r10970 respond_to do |format|
format.js
end
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/groups_controller.rb....
r6784
Jean-Philippe Lang
Adds #find_group filter....
r9565 private
def find_group
@group = Group.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
Jean-Philippe Lang
Count users with a single query on group list (#16905)....
r12874
def user_count_by_group_id
h = User.joins(:groups).group('group_id').count
h.keys.each do |key|
h[key.to_i] = h.delete(key)
end
h
end
Jean-Philippe Lang
User groups branch merged....
r2755 end