Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Reorder things

Klaus Zandersafc376f6e277
diff --git a/app/models/users/project_role_cache.rb b/app/models/users/project_role_cache.rb
index f869d5e53cf..99169cf674d 100644
--- a/app/models/users/project_role_cache.rb
+++ b/app/models/users/project_role_cache.rb
@@ -46,16 +46,18 @@ class Users::ProjectRoleCache
private
def roles(project: nil, entity: nil)
- # Return all roles if user is admin
- return all_givable_roles if user.admin?
-
if project
# Project is nil if checking global role
# No roles on archived projects, unless the active state is being changed
return [] if archived?(project)
+ # Return all roles if user is admin
+ return all_givable_roles if user.admin?
::Authorization.roles(user, project:).eager_load(:role_permissions)
elsif entity
+ # Return all roles if user is admin
+ return all_givable_roles if user.admin?
+
::Authorization.roles(user, entity:).eager_load(:role_permissions)
end
end