diff --git a/src/categories.js b/src/categories.js index 539a643f80..46af3f1c5a 100644 --- a/src/categories.js +++ b/src/categories.js @@ -7,7 +7,7 @@ var db = require('./database'); var user = require('./user'); var Groups = require('./groups'); var plugins = require('./plugins'); -var privileges = require('./privileges'); + (function(Categories) { @@ -102,6 +102,7 @@ var privileges = require('./privileges'); }; Categories.getCategoriesByPrivilege = function(set, uid, privilege, callback) { + var privileges = require('./privileges'); async.waterfall([ function(next) { db.getSortedSetRange(set, 0, -1, next); @@ -238,6 +239,7 @@ var privileges = require('./privileges'); }; function getChildrenRecursive(category, uid, callback) { + var privileges = require('./privileges'); async.waterfall([ function (next) { db.getSortedSetRange('cid:' + category.cid + ':children', 0, -1, next); diff --git a/src/categories/create.js b/src/categories/create.js index e2d6960e45..09df61cb07 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -3,7 +3,7 @@ var async = require('async'); var db = require('../database'); -var privileges = require('../privileges'); + var groups = require('../groups'); var plugins = require('../plugins'); var utils = require('../../public/src/utils'); @@ -50,7 +50,7 @@ module.exports = function(Categories) { category = data.category; var defaultPrivileges = ['find', 'read', 'topics:read', 'topics:create', 'topics:reply', 'posts:edit', 'posts:delete', 'topics:delete', 'upload:post:image']; - + var privileges = require('../privileges'); async.series([ async.apply(db.setObject, 'category:' + category.cid, category), function (next) { @@ -139,6 +139,7 @@ module.exports = function(Categories) { }; Categories.copyPrivilegesFrom = function(fromCid, toCid, callback) { + var privileges = require('../privileges'); async.each(privileges.privilegeList, function(privilege, next) { copyPrivilege(privilege, fromCid, toCid, next); }, callback); diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 0baf08af91..bebb50f4a9 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -5,7 +5,6 @@ var async = require('async'); var _ = require('underscore'); var user = require('../user'); -var categories = require('../categories'); var groups = require('../groups'); var helpers = require('./helpers'); var plugins = require('../plugins'); @@ -220,6 +219,7 @@ module.exports = function(privileges) { if (!cid) { return callback(null, false); } + var categories = require('../categories'); categories.getCategoryField(cid, 'disabled', function(err, disabled) { if (err) { return callback(err); @@ -269,6 +269,7 @@ module.exports = function(privileges) { }; privileges.categories.getBase = function(privilege, cids, uid, callback) { + var categories = require('../categories'); async.parallel({ categories: function(next) { categories.getCategoriesFields(cids, ['disabled'], next);