FEATURE: setting which allows TL4 users to deleted posts (#19766)

New setting which allows TL4 users to delete/view/recover posts and topics
This commit is contained in:
Krzysztof Kotlarek
2023-01-20 13:31:51 +11:00
committed by GitHub
parent b05f193cf0
commit 019ec74076
5 changed files with 47 additions and 3 deletions

View File

@@ -191,6 +191,8 @@ module PostGuardian
return true if is_staff? || is_category_group_moderator?(post.topic&.category)
return true if SiteSetting.tl4_delete_posts_and_topics && user.has_trust_level?(TrustLevel[4])
# Can't delete posts in archived topics unless you are staff
return false if post.topic&.archived?
@@ -311,7 +313,8 @@ module PostGuardian
end
def can_see_deleted_posts?(category = nil)
is_staff? || is_category_group_moderator?(category)
is_staff? || is_category_group_moderator?(category) ||
(SiteSetting.tl4_delete_posts_and_topics && @user.has_trust_level?(TrustLevel[4]))
end
def can_view_raw_email?(post)

View File

@@ -142,7 +142,8 @@ module TopicGuardian
end
def can_recover_topic?(topic)
if is_staff? || (topic&.category && is_category_group_moderator?(topic.category))
if is_staff? || (topic&.category && is_category_group_moderator?(topic.category)) ||
(SiteSetting.tl4_delete_posts_and_topics && user.has_trust_level?(TrustLevel[4]))
!!(topic && topic.deleted_at)
else
topic && can_recover_post?(topic.ordered_posts.first)
@@ -156,7 +157,8 @@ module TopicGuardian
(
is_my_own?(topic) && topic.posts_count <= 1 && topic.created_at &&
topic.created_at > 24.hours.ago
) || is_category_group_moderator?(topic.category)
) || is_category_group_moderator?(topic.category) ||
(SiteSetting.tl4_delete_posts_and_topics && user.has_trust_level?(TrustLevel[4]))
) && !topic.is_category_topic? && !Discourse.static_doc_topic_ids.include?(topic.id)
end