summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-03-27 21:29:05 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-03-27 21:29:05 +0000
commit883fcb89ee25649f75e94173a9a46cf5ff8af757 (patch)
treeffb7ce3f49ab680c330e1298dc7130e093bfa7cf
parentd27582644a270a1fe3e9db12ec88d890bb2979d1 (diff)
downloadredmine-883fcb89ee25649f75e94173a9a46cf5ff8af757.tar.gz
redmine-883fcb89ee25649f75e94173a9a46cf5ff8af757.zip
Include roles of built-in "Non member users" and "Anonymous users" members when user is not a member of the project. This fixes #34029.
git-svn-id: https://svn.redmine.org/redmine/trunk@21502 e93f8b46-1217-0410-a6f0-8f06a7374b81
-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 7ead1f8cb..1a4022c39 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -622,6 +622,15 @@ class User < Principal
Role.joins(members: :project).
where(["#{Project.table_name}.status <> ?", Project::STATUS_ARCHIVED]).
where(Member.arel_table[:user_id].eq(id)).distinct
+
+ if @roles.blank?
+ group_class = anonymous? ? GroupAnonymous : GroupNonMember
+ @roles = Role.joins(members: :project).
+ where(["#{Project.table_name}.status <> ? AND #{Project.table_name}.is_public = ?", Project::STATUS_ARCHIVED, true]).
+ where(Member.arel_table[:user_id].eq(group_class.first.id)).distinct
+ end
+
+ @roles
end
# Returns the user's bult-in role