kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
12 years ago
|
module OpenProject::GlobalRoles::Patches
|
||
14 years ago
|
module RolesControllerPatch
|
||
|
def self.included(base)
|
||
|
base.send(:include, InstanceMethods)
|
||
|
|
||
|
base.class_eval do
|
||
|
alias_method_chain :new, :global_roles
|
||
|
alias_method_chain :index, :global_roles
|
||
14 years ago
|
alias_method_chain :list, :global_roles if Redmine::VERSION::MAJOR < 1
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
|
module InstanceMethods
|
||
|
def create
|
||
|
if params['global_role']
|
||
|
create_global_role
|
||
|
else
|
||
|
new
|
||
14 years ago
|
|
||
|
render :template => 'roles/new' if @role.errors.size > 0
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
|
def new_with_global_roles
|
||
|
new_without_global_roles
|
||
|
|
||
14 years ago
|
@member_permissions = (@role.setable_permissions || @permissions)
|
||
|
@global_permissions = GlobalRole.setable_permissions
|
||
14 years ago
|
end
|
||
|
|
||
|
def index_with_global_roles
|
||
14 years ago
|
@role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
|
||
14 years ago
|
respond_to do |format|
|
||
|
format.html {render :action => 'index'}
|
||
|
format.js {render :action => 'index', :layout => false}
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def list_with_global_roles
|
||
|
index_with_global_roles
|
||
|
end
|
||
|
|
||
14 years ago
|
def update
|
||
|
edit
|
||
14 years ago
|
|
||
|
render :template => 'roles/edit' if @role.errors.size > 0
|
||
14 years ago
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def create_global_role
|
||
14 years ago
|
@role = GlobalRole.new params[:role]
|
||
|
if @role.save
|
||
14 years ago
|
flash[:notice] = l(:notice_successful_create)
|
||
|
redirect_to :action => 'index'
|
||
|
else
|
||
14 years ago
|
@roles = Role.all :order => 'builtin, position'
|
||
|
@member_permissions = Role.new.setable_permissions
|
||
|
@global_permissions = GlobalRole.setable_permissions
|
||
14 years ago
|
render :template => 'roles/new'
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
|
def standard_member_and_global_assigns
|
||
|
@member_permissions = (@member_role.setable_permissions || @permissions)
|
||
14 years ago
|
@global_permissions = GlobalRole.setable_permissions
|
||
14 years ago
|
@global_roles = GlobalRole.all
|
||
|
@member_roles = (Role.all || @roles)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
RolesController.send(:include, OpenProject::GlobalRoles::Patches::RolesControllerPatch)
|