FIX: Do not perform grants if badges are disabled

This commit is contained in:
riking 2014-09-02 13:12:27 -07:00
parent defe1dd86f
commit ee812eb447
3 changed files with 7 additions and 1 deletions

View File

@ -8,6 +8,7 @@ module Jobs
every 1.day every 1.day
def execute(args) def execute(args)
return unless SiteSetting.enable_badges
Badge.all.each do |b| Badge.all.each do |b|
BadgeGranter.backfill(b) BadgeGranter.backfill(b)
end end

View File

@ -68,6 +68,7 @@ class BadgeGranter
end end
def self.queue_badge_grant(type,opt) def self.queue_badge_grant(type,opt)
return unless SiteSetting.enable_badges
payload = nil payload = nil
case type case type
@ -208,6 +209,7 @@ class BadgeGranter
MAX_ITEMS_FOR_DELTA = 200 MAX_ITEMS_FOR_DELTA = 200
def self.backfill(badge, opts=nil) def self.backfill(badge, opts=nil)
return unless SiteSetting.enable_badges
return unless badge.query.present? && badge.enabled return unless badge.query.present? && badge.enabled
post_ids = user_ids = nil post_ids = user_ids = nil

View File

@ -108,7 +108,10 @@ class Guardian
alias :can_move_posts? :can_moderate? alias :can_move_posts? :can_moderate?
alias :can_see_flags? :can_moderate? alias :can_see_flags? :can_moderate?
alias :can_send_activation_email? :can_moderate? alias :can_send_activation_email? :can_moderate?
alias :can_grant_badges? :can_moderate?
def can_grant_badges?(_user)
SiteSetting.enable_badges && is_staff?
end
def can_see_group?(group) def can_see_group?(group)
group.present? && (is_admin? || group.visible?) group.present? && (is_admin? || group.visible?)