unify flag moderator permissions

This commit is contained in:
Kevin Chugh
2013-04-21 06:15:23 -04:00
parent 0a627bb5d9
commit 649578ea2f
9 changed files with 14 additions and 9 deletions

View File

@@ -18,8 +18,12 @@ class @DiscussionUtil
@loadRoles: (roles)->
@roleIds = roles
@loadFlagModerator: (what)->
@isFlagModerator = what
@loadRolesFromContainer: ->
@loadRoles($("#discussion-container").data("roles"))
@loadFlagModerator($("#discussion-container").data("flag-moderator"))
@isStaff: (user_id) ->
staff = _.union(@roleIds['Staff'], @roleIds['Moderator'], @roleIds['Administrator'])

View File

@@ -109,7 +109,7 @@ if Backbone?
toggleFlagAbuse: (event) ->
event.preventDefault()
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isStaff(@model.get("user_id")) and @model.get("abuse_flaggers").length > 0)
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isFlagModerator and @model.get("abuse_flaggers").length > 0)
@unFlagAbuse()
else
@flagAbuse()
@@ -140,7 +140,7 @@ if Backbone?
temp_array = _.clone(@model.get('abuse_flaggers'));
temp_array.pop(window.user.id)
# if you're an admin, clear this
if DiscussionUtil.isStaff(@model.get("user_id"))
if DiscussionUtil.isFlagModerator
temp_array = []
@model.set('abuse_flaggers', temp_array)

View File

@@ -46,7 +46,7 @@ if Backbone?
@$("[data-role=discussion-vote]").removeClass("is-cast")
renderFlagged: =>
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isStaff(@model.get("user_id")) and @model.get("abuse_flaggers").length > 0)
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isFlagModerator and @model.get("abuse_flaggers").length > 0)
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
@$(".discussion-flag-abuse .flag-label").html("Misuse Reported")

View File

@@ -45,7 +45,7 @@ if Backbone?
renderFlagged: =>
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isStaff(@model.get("user_id")) and @model.get("abuse_flaggers").length > 0)
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isFlagModerator and @model.get("abuse_flaggers").length > 0)
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
else

View File

@@ -98,7 +98,7 @@ if Backbone?
renderFlagged: =>
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isStaff(@model.get("user_id")) and @model.get("abuse_flaggers").length > 0)
if window.user.id in @model.get("abuse_flaggers") or (DiscussionUtil.isFlagModerator and @model.get("abuse_flaggers").length > 0)
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
@$(".discussion-flag-abuse .flag-label").html("Misuse Reported")