From: Marius Balteanu Date: Sun, 27 Mar 2022 21:29:05 +0000 (+0000) Subject: Include roles of built-in "Non member users" and "Anonymous users" members when user... X-Git-Tag: 5.0.0~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=883fcb89ee25649f75e94173a9a46cf5ff8af757;p=redmine.git 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 --- 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