]> source.dussan.org Git - redmine.git/commitdiff
Include roles of built-in "Non member users" and "Anonymous users" members when user...
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 27 Mar 2022 21:29:05 +0000 (21:29 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 27 Mar 2022 21:29:05 +0000 (21:29 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@21502 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb

index 7ead1f8cb7ea507fef23bafdf86c523e688ff2b4..1a4022c39124ea825ff89a8eaf5624665ed2bcb1 100644 (file)
@@ -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