discourse/app/models/trust_level_and_staff_and_disabled_setting.rb
Bianca Nenciu ff367e22fb
FEATURE: Make allow_uploaded_avatars accept TL (#14091)
This gives admins more control over who can upload custom profile
pictures.
2021-08-24 10:46:28 +03:00

33 lines
694 B
Ruby

# frozen_string_literal: true
class TrustLevelAndStaffAndDisabledSetting < TrustLevelAndStaffSetting
def self.valid_value?(val)
valid_values.include?(val) || (val.to_i.to_s == val.to_s && valid_values.include?(val.to_i))
end
def self.valid_values
['disabled'] + TrustLevel.valid_range.to_a + special_groups
end
def self.translation(value)
if value == 'disabled'
I18n.t('site_settings.disabled')
else
super
end
end
def self.matches?(value, user)
case value
when 'disabled'
false
when 'staff'
user.staff?
when 'admin'
user.admin?
else
user.has_trust_level?(value.to_i) || user.staff?
end
end
end