mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
fix dependency errors
This commit is contained in:
@@ -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,7 +102,6 @@ var plugins = require('./plugins');
|
||||
};
|
||||
|
||||
Categories.getCategoriesByPrivilege = function(set, uid, privilege, callback) {
|
||||
var privileges = require('./privileges');
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
db.getSortedSetRange(set, 0, -1, next);
|
||||
@@ -239,7 +238,6 @@ var plugins = require('./plugins');
|
||||
};
|
||||
|
||||
function getChildrenRecursive(category, uid, callback) {
|
||||
var privileges = require('./privileges');
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRange('cid:' + category.cid + ':children', 0, -1, next);
|
||||
|
||||
@@ -5,6 +5,7 @@ var async = require('async');
|
||||
var db = require('../database');
|
||||
var groups = require('../groups');
|
||||
var plugins = require('../plugins');
|
||||
var privileges = require('../privileges');
|
||||
var utils = require('../../public/src/utils');
|
||||
|
||||
module.exports = function(Categories) {
|
||||
@@ -49,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) {
|
||||
@@ -138,7 +139,6 @@ 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);
|
||||
|
||||
@@ -6,6 +6,7 @@ var batch = require('../batch');
|
||||
var plugins = require('../plugins');
|
||||
var topics = require('../topics');
|
||||
var groups = require('../groups');
|
||||
var privileges = require('../privileges');
|
||||
|
||||
module.exports = function(Categories) {
|
||||
|
||||
@@ -45,7 +46,6 @@ module.exports = function(Categories) {
|
||||
], next);
|
||||
},
|
||||
function(next) {
|
||||
var privileges = require('../privileges');
|
||||
async.each(privileges.privilegeList, function(privilege, next) {
|
||||
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
|
||||
}, next);
|
||||
|
||||
@@ -9,7 +9,7 @@ var _ = require('underscore');
|
||||
var db = require('../database');
|
||||
var posts = require('../posts');
|
||||
var topics = require('../topics');
|
||||
var categories = require('../categories');
|
||||
var privileges = require('../privileges');
|
||||
|
||||
|
||||
module.exports = function(Categories) {
|
||||
@@ -18,7 +18,7 @@ module.exports = function(Categories) {
|
||||
if (!parseInt(count, 10)) {
|
||||
return callback(null, []);
|
||||
}
|
||||
var privileges = require('../privileges');
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, count - 1, next);
|
||||
@@ -36,7 +36,7 @@ module.exports = function(Categories) {
|
||||
if (!Array.isArray(categoryData) || !categoryData.length) {
|
||||
return callback();
|
||||
}
|
||||
var privileges = require('../privileges');
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
async.map(categoryData, getRecentTopicTids, next);
|
||||
@@ -121,7 +121,7 @@ module.exports = function(Categories) {
|
||||
});
|
||||
|
||||
async.parallel({
|
||||
categoryData: async.apply(categories.getCategoriesFields, cids, ['cid', 'parentCid']),
|
||||
categoryData: async.apply(Categories.getCategoriesFields, cids, ['cid', 'parentCid']),
|
||||
teasers: async.apply(topics.getTeasers, _topicData),
|
||||
}, next);
|
||||
},
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
var async = require('async');
|
||||
var _ = require('underscore');
|
||||
|
||||
var user = require('../user');
|
||||
var groups = require('../groups');
|
||||
var helpers = require('./helpers');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function(privileges) {
|
||||
|
||||
@@ -15,6 +12,9 @@ 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,6 +156,7 @@ 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);
|
||||
@@ -178,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,
|
||||
@@ -196,6 +197,7 @@ 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);
|
||||
@@ -220,6 +222,7 @@ module.exports = function(privileges) {
|
||||
return callback(null, false);
|
||||
}
|
||||
var categories = require('../categories');
|
||||
var user = require('../user');
|
||||
categories.getCategoryField(cid, 'disabled', function(err, disabled) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -270,6 +273,7 @@ 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);
|
||||
@@ -294,7 +298,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);
|
||||
@@ -318,10 +322,12 @@ 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);
|
||||
};
|
||||
|
||||
@@ -332,6 +338,7 @@ 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);
|
||||
@@ -352,6 +359,8 @@ 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) {
|
||||
@@ -382,6 +391,7 @@ 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) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var groups = require('../groups');
|
||||
|
||||
var helpers = {};
|
||||
|
||||
@@ -27,6 +26,7 @@ helpers.isUserAllowedTo = function(privilege, uid, cids, callback) {
|
||||
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
|
||||
}
|
||||
|
||||
var groups = require('../groups');
|
||||
async.parallel({
|
||||
hasUserPrivilege: function(next) {
|
||||
groups.isMemberOfGroups(uid, userKeys, next);
|
||||
@@ -49,6 +49,7 @@ helpers.isUserAllowedTo = function(privilege, uid, cids, callback) {
|
||||
};
|
||||
|
||||
helpers.isUsersAllowedTo = function(privilege, uids, cid, callback) {
|
||||
var groups = require('../groups');
|
||||
async.parallel({
|
||||
hasUserPrivilege: function(next) {
|
||||
groups.isMembers(uids, 'cid:' + cid + ':privileges:' + privilege, next);
|
||||
@@ -75,7 +76,7 @@ function isGuestAllowedTo(privilege, cids, callback) {
|
||||
for (var i=0; i<cids.length; ++i) {
|
||||
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
|
||||
}
|
||||
|
||||
var groups = require('../groups');
|
||||
groups.isMemberOfGroups('guests', groupKeys, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var meta = require('../meta');
|
||||
var posts = require('../posts');
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var helpers = require('./helpers');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function(privileges) {
|
||||
|
||||
@@ -18,7 +13,8 @@ module.exports = function(privileges) {
|
||||
if (!Array.isArray(pids) || !pids.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
var posts = require('../posts');
|
||||
var user = require('../user');
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
posts.getCidsByPids(pids, next);
|
||||
@@ -59,6 +55,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.can = function(privilege, pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
posts.getCidByPid(pid, function(err, cid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -69,6 +66,8 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.filter = function(privilege, pids, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
var topics = require('../topics');
|
||||
if (!Array.isArray(pids) || !pids.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
@@ -127,6 +126,7 @@ module.exports = function(privileges) {
|
||||
return post.pid;
|
||||
});
|
||||
|
||||
var plugins = require('../plugins');
|
||||
plugins.fireHook('filter:privileges.posts.filter', {
|
||||
privilege: privilege,
|
||||
uid: uid,
|
||||
@@ -155,7 +155,12 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.canDelete = function(pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
var topics = require('../topics');
|
||||
var meta = require('../meta');
|
||||
|
||||
var postData;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
posts.getPostFields(pid, ['tid', 'timestamp'], next);
|
||||
@@ -196,6 +201,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.canMove = function(pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
posts.isMain(pid, function(err, isMain) {
|
||||
if (err || isMain) {
|
||||
return callback(err || new Error('[[error:cant-move-mainpost]]'));
|
||||
@@ -205,6 +211,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.canPurge = function(pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
posts.getCidByPid(pid, next);
|
||||
@@ -223,6 +230,10 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
function isPostEditable(pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
var topics = require('../topics');
|
||||
var meta = require('../meta');
|
||||
|
||||
var tid;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -253,6 +264,8 @@ module.exports = function(privileges) {
|
||||
}
|
||||
|
||||
function isAdminOrMod(pid, uid, callback) {
|
||||
var posts = require('../posts');
|
||||
var user = require('../user');
|
||||
helpers.some([
|
||||
function(next) {
|
||||
posts.getCidByPid(pid, function(err, cid) {
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var meta = require('../meta');
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var helpers = require('./helpers');
|
||||
var categories = require('../categories');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function(privileges) {
|
||||
|
||||
privileges.topics = {};
|
||||
|
||||
privileges.topics.get = function(tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var categories = require('../categories');
|
||||
var plugins = require('../plugins');
|
||||
var topic;
|
||||
async.waterfall([
|
||||
async.apply(topics.getTopicFields, tid, ['cid', 'uid', 'locked', 'deleted']),
|
||||
@@ -68,6 +67,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.topics.can = function(privilege, tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -83,6 +83,7 @@ module.exports = function(privileges) {
|
||||
}
|
||||
var cids;
|
||||
var topicsData;
|
||||
var topics = require('../topics');
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
topics.getTopicsFields(tids, ['tid', 'cid', 'deleted'], next);
|
||||
@@ -113,6 +114,7 @@ module.exports = function(privileges) {
|
||||
return topic.tid;
|
||||
});
|
||||
|
||||
var plugins = require('../plugins');
|
||||
plugins.fireHook('filter:privileges.topics.filter', {
|
||||
privilege: privilege,
|
||||
uid: uid,
|
||||
@@ -133,6 +135,9 @@ module.exports = function(privileges) {
|
||||
return array.indexOf(uid) === index;
|
||||
});
|
||||
|
||||
var topics = require('../topics');
|
||||
var categories = require('../categories');
|
||||
var user = require('../user');
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
topics.getTopicFields(tid, ['tid', 'cid', 'deleted'], next);
|
||||
@@ -168,6 +173,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.topics.canPurge = function(tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
topics.getTopicField(tid, 'cid', next);
|
||||
@@ -186,6 +192,9 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.topics.canDelete = function(tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var meta = require('../meta');
|
||||
var topicData;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -230,6 +239,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.topics.isOwnerOrAdminOrMod = function(tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
helpers.some([
|
||||
function(next) {
|
||||
topics.isOwner(tid, uid, next);
|
||||
@@ -242,6 +252,8 @@ module.exports = function(privileges) {
|
||||
|
||||
|
||||
privileges.topics.isAdminOrMod = function(tid, uid, callback) {
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
helpers.some([
|
||||
function(next) {
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var groups = require('../groups');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function(privileges) {
|
||||
|
||||
privileges.users = {};
|
||||
|
||||
privileges.users.isAdministrator = function(uid, callback) {
|
||||
var groups = require('../groups');
|
||||
if (Array.isArray(uid)) {
|
||||
groups.isMembers(uid, 'administrators', callback);
|
||||
} else {
|
||||
@@ -19,6 +17,7 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.users.isGlobalModerator = function(uid, callback) {
|
||||
var groups = require('../groups');
|
||||
if (Array.isArray(uid)) {
|
||||
groups.isMembers(uid, 'Global Moderators', callback);
|
||||
} else {
|
||||
@@ -63,7 +62,7 @@ module.exports = function(privileges) {
|
||||
var groupListNames = uniqueCids.map(function(cid) {
|
||||
return 'cid:' + cid + ':privileges:groups:moderate';
|
||||
});
|
||||
|
||||
var groups = require('../groups');
|
||||
async.parallel({
|
||||
user: async.apply(groups.isMemberOfGroups, uid, groupNames),
|
||||
group: async.apply(groups.isMemberOfGroupsList, uid, groupListNames)
|
||||
@@ -91,6 +90,7 @@ module.exports = function(privileges) {
|
||||
}
|
||||
|
||||
function isModeratorsOfCategory(cid, uids, callback) {
|
||||
var groups = require('../groups');
|
||||
async.parallel([
|
||||
async.apply(privileges.users.isGlobalModerator, uids),
|
||||
async.apply(groups.isMembers, uids, 'cid:' + cid + ':privileges:mods'),
|
||||
@@ -109,6 +109,7 @@ module.exports = function(privileges) {
|
||||
}
|
||||
|
||||
function isModeratorOfCategory(cid, uid, callback) {
|
||||
var groups = require('../groups');
|
||||
async.parallel([
|
||||
async.apply(privileges.users.isGlobalModerator, uid),
|
||||
async.apply(groups.isMember, uid, 'cid:' + cid + ':privileges:mods'),
|
||||
@@ -124,6 +125,7 @@ module.exports = function(privileges) {
|
||||
}
|
||||
|
||||
function filterIsModerator(cid, uid, isModerator, callback) {
|
||||
var plugins = require('../plugins');
|
||||
plugins.fireHook('filter:user.isModerator', {uid: uid, cid: cid, isModerator: isModerator}, function(err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
||||
Reference in New Issue
Block a user