DEV: Convert min_trust_to_edit_post to groups (#24840)

We're changing the implementation of trust levels to use groups. Part of this is to have site settings that reference trust levels use groups instead. It converts the min_trust_to_edit_post site setting to edit_post_allowed_groups.

The old implementation will co-exist for a short period while I update any references in plugins and themes.
This commit is contained in:
Ted Johansson
2023-12-13 13:25:13 +08:00
committed by GitHub
parent 702d0620d7
commit 36057638ca
11 changed files with 74 additions and 49 deletions

View File

@@ -4,13 +4,22 @@ module LimitedEdit
extend ActiveSupport::Concern
def edit_time_limit_expired?(user)
return true if user.trust_level < SiteSetting.min_trust_to_edit_post
return true if !trusted_with_edits?(user)
time_limit = user_time_limit(user)
created_at && (time_limit > 0) && (created_at < time_limit.minutes.ago)
end
private
# TODO: This duplicates some functionality from PostGuardian. This should
# probably be checked there instead, because this has nothing to do
# with time limits.
#
def trusted_with_edits?(user)
user.trust_level >= SiteSetting.min_trust_to_edit_post ||
user.in_any_groups?(SiteSetting.edit_post_allowed_groups_map)
end
def user_time_limit(user)
if user.trust_level < 2
SiteSetting.post_edit_time_limit.to_i