diff options
author | Go MAEDA <maeda@farend.jp> | 2018-04-07 00:26:54 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-04-07 00:26:54 +0000 |
commit | e5a8bcfd72de2b4ac5d90a534f3bd927619904a7 (patch) | |
tree | 2b02c3c73656270974b2fd056663d5987c1df1ce /app/models/query.rb | |
parent | 97a5e99de83a0f454e74b78a660b75a1dba75a4d (diff) | |
download | redmine-e5a8bcfd72de2b4ac5d90a534f3bd927619904a7.tar.gz redmine-e5a8bcfd72de2b4ac5d90a534f3bd927619904a7.zip |
Ignore archived project memberships when calculating issue query visibility (#28180).
Patch by Holger Just.
git-svn-id: http://svn.redmine.org/redmine/trunk@17257 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r-- | app/models/query.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/query.rb b/app/models/query.rb index 6c20cd992..319a0b8a8 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -319,9 +319,10 @@ class Query < ActiveRecord::Base " INNER JOIN #{table_name_prefix}queries_roles#{table_name_suffix} qr on qr.query_id = q.id" + " INNER JOIN #{MemberRole.table_name} mr ON mr.role_id = qr.role_id" + " INNER JOIN #{Member.table_name} m ON m.id = mr.member_id AND m.user_id = ?" + + " INNER JOIN #{Project.table_name} p ON p.id = m.project_id AND p.status <> ?" + " WHERE q.project_id IS NULL OR q.project_id = m.project_id))" + " OR #{table_name}.user_id = ?", - VISIBILITY_PUBLIC, VISIBILITY_ROLES, user.id, user.id) + VISIBILITY_PUBLIC, VISIBILITY_ROLES, user.id, Project::STATUS_ARCHIVED, user.id) elsif user.logged? scope.where("#{table_name}.visibility = ? OR #{table_name}.user_id = ?", VISIBILITY_PUBLIC, user.id) else @@ -340,7 +341,7 @@ class Query < ActiveRecord::Base if project (user.roles_for_project(project) & roles).any? else - Member.where(:user_id => user.id).joins(:roles).where(:member_roles => {:role_id => roles.map(&:id)}).any? + user.memberships.joins(:member_roles).where(:member_roles => {:role_id => roles.map(&:id)}).any? end else user == self.user |