summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-31 07:16:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-31 07:16:23 +0000
commited9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b (patch)
tree3420c99029f21a21c236c4ff8c0c532dd548401e /app/models/user.rb
parent48d40a8c8884aefc2287f2030c439578057c9516 (diff)
downloadredmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.tar.gz
redmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.zip
Ability to limit member management to certain roles (#19707).
git-svn-id: http://svn.redmine.org/redmine/trunk@14293 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 70610159f..9ff706178 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -566,6 +566,15 @@ class User < Principal
@visible_project_ids ||= Project.visible(self).pluck(:id)
end
+ # Returns the roles that the user is allowed to manage for the given project
+ def managed_roles(project)
+ if admin?
+ Role.givable.to_a
+ else
+ membership(project).try(:managed_roles) || []
+ end
+ end
+
# Returns true if user is arg or belongs to arg
def is_or_belongs_to?(arg)
if arg.is_a?(User)