|
|
|
@ -4,7 +4,11 @@
|
|
|
|
|
var async = require('async');
|
|
|
|
|
var _ = require('underscore');
|
|
|
|
|
|
|
|
|
|
var categories = require('../categories');
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
var helpers = require('./helpers');
|
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
|
|
|
|
|
|
module.exports = function(privileges) {
|
|
|
|
|
|
|
|
|
@ -12,9 +16,6 @@ module.exports = function(privileges) {
|
|
|
|
|
|
|
|
|
|
privileges.categories.list = function(cid, callback) {
|
|
|
|
|
// Method used in admin/category controller to show all users/groups with privs in that given cid
|
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
|
|
|
|
|
var privilegeLabels = [
|
|
|
|
|
{name: 'Find Category'},
|
|
|
|
@ -156,7 +157,6 @@ module.exports = function(privileges) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.get = function(cid, uid, callback) {
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
async.parallel({
|
|
|
|
|
'topics:create': function(next) {
|
|
|
|
|
helpers.isUserAllowedTo('topics:create', uid, [cid], next);
|
|
|
|
@ -179,7 +179,7 @@ module.exports = function(privileges) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var isAdminOrMod = results.isAdministrator || results.isModerator;
|
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('filter:privileges.categories.get', {
|
|
|
|
|
cid: cid,
|
|
|
|
|
uid: uid,
|
|
|
|
@ -197,7 +197,6 @@ module.exports = function(privileges) {
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
return callback(null, false);
|
|
|
|
|
}
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
helpers.some([
|
|
|
|
|
function (next) {
|
|
|
|
|
user.isModerator(uid, cid, next);
|
|
|
|
@ -221,8 +220,7 @@ module.exports = function(privileges) {
|
|
|
|
|
if (!cid) {
|
|
|
|
|
return callback(null, false);
|
|
|
|
|
}
|
|
|
|
|
var categories = require('../categories');
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
|
|
|
|
|
categories.getCategoryField(cid, 'disabled', function(err, disabled) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
@ -272,8 +270,6 @@ module.exports = function(privileges) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.getBase = function(privilege, cids, uid, callback) {
|
|
|
|
|
var categories = require('../categories');
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
async.parallel({
|
|
|
|
|
categories: function(next) {
|
|
|
|
|
categories.getCategoriesFields(cids, ['disabled'], next);
|
|
|
|
@ -298,7 +294,7 @@ module.exports = function(privileges) {
|
|
|
|
|
uids = uids.filter(function(uid, index, array) {
|
|
|
|
|
return array.indexOf(uid) === index;
|
|
|
|
|
});
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
allowedTo: function(next) {
|
|
|
|
|
helpers.isUsersAllowedTo(privilege, uids, cid, next);
|
|
|
|
@ -322,12 +318,10 @@ module.exports = function(privileges) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.give = function(privileges, cid, groupName, callback) {
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
giveOrRescind(groups.join, privileges, cid, groupName, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.rescind = function(privileges, cid, groupName, callback) {
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
giveOrRescind(groups.leave, privileges, cid, groupName, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -338,7 +332,6 @@ module.exports = function(privileges) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
privileges.categories.canMoveAllTopics = function(currentCid, targetCid, uid, callback) {
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
async.parallel({
|
|
|
|
|
isAdministrator: function(next) {
|
|
|
|
|
user.isAdministrator(uid, next);
|
|
|
|
@ -359,8 +352,6 @@ module.exports = function(privileges) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.userPrivileges = function(cid, uid, callback) {
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
async.parallel({
|
|
|
|
|
find: async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:find'),
|
|
|
|
|
read: function(next) {
|
|
|
|
@ -391,7 +382,6 @@ module.exports = function(privileges) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
privileges.categories.groupPrivileges = function(cid, groupName, callback) {
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
async.parallel({
|
|
|
|
|
'groups:find': async.apply(groups.isMember, groupName, 'cid:' + cid + ':privileges:groups:find'),
|
|
|
|
|
'groups:read': function(next) {
|
|
|
|
@ -418,4 +408,4 @@ module.exports = function(privileges) {
|
|
|
|
|
}, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
};
|