mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Reuse code for TrustLevelAndStaffSetting (#15044)
The code that checked this permission was duplicated everytime a new settings of this type was added. This commit changes the behavior of some functionality because some feature checks were bypassed for staff members.
This commit is contained in:
@@ -3,15 +3,11 @@
|
||||
#mixin for all guardian methods dealing with tagging permissions
|
||||
module TagGuardian
|
||||
def can_create_tag?
|
||||
return is_admin? if SiteSetting.min_trust_to_create_tag.to_s == 'admin'
|
||||
return is_staff? if SiteSetting.min_trust_to_create_tag.to_s == 'staff'
|
||||
user && SiteSetting.tagging_enabled && user.has_trust_level?(SiteSetting.min_trust_to_create_tag.to_i)
|
||||
SiteSetting.tagging_enabled && @user.has_trust_level_or_staff?(SiteSetting.min_trust_to_create_tag)
|
||||
end
|
||||
|
||||
def can_tag_topics?
|
||||
return is_admin? if SiteSetting.min_trust_level_to_tag_topics.to_s == 'admin'
|
||||
return is_staff? if SiteSetting.min_trust_level_to_tag_topics.to_s == 'staff'
|
||||
user && SiteSetting.tagging_enabled && user.has_trust_level?(SiteSetting.min_trust_level_to_tag_topics.to_i)
|
||||
SiteSetting.tagging_enabled && @user.has_trust_level_or_staff?(SiteSetting.min_trust_level_to_tag_topics)
|
||||
end
|
||||
|
||||
def can_tag_pms?
|
||||
|
||||
@@ -32,10 +32,7 @@ module TopicGuardian
|
||||
end
|
||||
|
||||
def can_see_shared_draft?
|
||||
return is_admin? if SiteSetting.shared_drafts_min_trust_level.to_s == 'admin'
|
||||
return is_staff? if SiteSetting.shared_drafts_min_trust_level.to_s == 'staff'
|
||||
|
||||
@user.has_trust_level?(SiteSetting.shared_drafts_min_trust_level.to_i)
|
||||
@user.has_trust_level_or_staff?(SiteSetting.shared_drafts_min_trust_level)
|
||||
end
|
||||
|
||||
def can_create_whisper?
|
||||
|
||||
Reference in New Issue
Block a user