mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Admins should be able to view PMs of any group.
This commit is contained in:
@@ -434,11 +434,21 @@ class TopicQuery
|
||||
|
||||
if type == :group
|
||||
result = result.includes(:allowed_users)
|
||||
result = result.where("topics.id IN (SELECT topic_id FROM topic_allowed_groups
|
||||
WHERE group_id IN (
|
||||
SELECT group_id FROM group_users WHERE user_id = #{user.id.to_i}) AND
|
||||
group_id IN (SELECT id FROM groups WHERE name ilike ?)
|
||||
)", @options[:group_name])
|
||||
result = result.where("
|
||||
topics.id IN (
|
||||
SELECT topic_id FROM topic_allowed_groups
|
||||
WHERE (
|
||||
group_id IN (
|
||||
SELECT group_id
|
||||
FROM group_users
|
||||
WHERE user_id = #{user.id.to_i}
|
||||
OR #{user.staff?}
|
||||
)
|
||||
)
|
||||
AND group_id IN (SELECT id FROM groups WHERE name ilike ?)
|
||||
)",
|
||||
@options[:group_name]
|
||||
)
|
||||
elsif type == :user
|
||||
result = result.includes(:allowed_users)
|
||||
result = result.where("topics.id IN (SELECT topic_id FROM topic_allowed_users WHERE user_id = #{user.id.to_i})")
|
||||
|
Reference in New Issue
Block a user