/**
* Privileges are the calculated actions users can make.
*
* These are calculated verifying:
* + Forum Visibility
* + If User is owner of a forum
* + User Role on Forum Permissions
*
*/

var privileges = {
  canView: function canView (forum, user) {
    if (forum.hasVisibility('public', 'closed')) return true
    return forum.isOwner(user) || forum.hasRole(user)
  },

  canEdit: function canEdit (forum, user) {
    return forum.isOwner(user) || forum.hasRole(user, 'admin')
  },

  canDelete: function canDelete (forum, user) {
    return forum.isOwner(user)
  },

  canVoteAndComment: function canVoteAndComment (forum, user) {
    if (forum.hasVisibility('public')) return true
    return forum.isOwner(user) || forum.hasRole(user)
  },

  canChangeTopics: function canChangeTopics (forum, user) {
    return forum.isOwner(user) || forum.hasRole(user, 'admin', 'collaborator')
  }
}

/**
* Helper function 'all' generator to retrieve all the privileges of a user
* on a specific forum.
*/

privileges.all = (function () {
  var keys = Object.keys(privileges)
  return function all (forum, user) {
    var p = {}

    keys.forEach((k) => {
      p[k] = privileges[k](forum, user)
    })

    return p
  }
})()

module.exports = privileges

@@ -1,12 +1,48 @@
+var config = require('lib/config')%0A%0A
 /**%0A* Privil
@@ -274,32 +274,94 @@
 (forum, user) %7B%0A
+    if (!config.multiForum && user && user.staff) return true%0A
     if (forum.ha
@@ -501,32 +501,94 @@
 (forum, user) %7B%0A
+    if (!config.multiForum && user && user.staff) return true%0A
     return forum
@@ -680,32 +680,94 @@
 (forum, user) %7B%0A
+    if (!config.multiForum && user && user.staff) return true%0A
     return forum
@@ -894,32 +894,94 @@
 ')) return true%0A
+    if (!config.multiForum && user && user.staff) return true%0A
     return forum
@@ -1080,24 +1080,86 @@
 um, user) %7B%0A
+    if (!config.multiForum && user && user.staff) return true%0A
     return f

fix staff members should be able to do everything on singleForum