2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-25 14:53:21 -05:00
|
|
|
module LimitedEdit
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2019-09-06 07:44:12 -04:00
|
|
|
def edit_time_limit_expired?(user)
|
|
|
|
time_limit = user_time_limit(user)
|
|
|
|
if created_at && time_limit > 0
|
|
|
|
created_at < time_limit.minutes.ago
|
2015-02-25 14:53:21 -05:00
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
2019-09-06 07:44:12 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def user_time_limit(user)
|
|
|
|
if user.trust_level < 2
|
|
|
|
SiteSetting.post_edit_time_limit.to_i
|
|
|
|
else
|
|
|
|
SiteSetting.tl2_post_edit_time_limit.to_i
|
|
|
|
end
|
|
|
|
end
|
2015-02-25 14:53:21 -05:00
|
|
|
end
|