Merge pull request #3303 from riking/patch-6

FIX: Don't fail topic auto-close if privledges are lost
This commit is contained in:
Régis Hanol 2015-04-06 11:12:37 +02:00
commit 23e8e1b6c1
2 changed files with 5 additions and 0 deletions

View file

@ -4,6 +4,10 @@ module Jobs
def execute(args)
if topic = Topic.find_by(id: args[:topic_id])
closer = User.find_by(id: args[:user_id])
guardian = Guardian.new(closer)
unless guardian.can_close?(topic)
closer = Discourse.system_user
end
topic.auto_close(closer)
end
end

View file

@ -114,6 +114,7 @@ class Guardian
alias :can_move_posts? :can_moderate?
alias :can_see_flags? :can_moderate?
alias :can_send_activation_email? :can_moderate?
alias :can_close? :can_moderate?
def can_grant_badges?(_user)
SiteSetting.enable_badges && is_staff?