v1.18.x
Julian Lam 8 years ago
parent 7ba76fc0b6
commit 3272c0b98c

@ -45,7 +45,7 @@ flagsController.get = function (req, res, next) {
// If res.locals.cids is populated, then slim down the categories list // If res.locals.cids is populated, then slim down the categories list
if (res.locals.cids) { if (res.locals.cids) {
results.categories = results.categories.filter(function(category) { results.categories = results.categories.filter(function (category) {
return res.locals.cids.indexOf(String(category.cid)) !== -1; return res.locals.cids.indexOf(String(category.cid)) !== -1;
}); });
} }

@ -7,11 +7,11 @@ var adminFlagsController = require('./admin/flags');
var modsController = {}; var modsController = {};
modsController.flagged = function(req, res, next) { modsController.flagged = function (req, res, next) {
async.parallel([ async.parallel([
async.apply(user.isAdminOrGlobalMod, req.uid), async.apply(user.isAdminOrGlobalMod, req.uid),
async.apply(user.isModeratorOfAnyCategory, req.uid) async.apply(user.isModeratorOfAnyCategory, req.uid)
], function(err, results) { ], function (err, results) {
if (err || !(results[0] || results[1])) { if (err || !(results[0] || results[1])) {
return next(err); return next(err);
} }

@ -71,9 +71,9 @@ module.exports = function (Posts) {
}); });
} else { } else {
// Multiple cids // Multiple cids
async.map(cid, function(cid, next) { async.map(cid, function (cid, next) {
Posts.filterPidsByCid(pids, cid, next); Posts.filterPidsByCid(pids, cid, next);
}, function(err, pidsArr) { }, function (err, pidsArr) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

@ -148,7 +148,7 @@ module.exports = function (SocketPosts) {
async.parallel([ async.parallel([
async.apply(user.isAdminOrGlobalMod, socket.uid), async.apply(user.isAdminOrGlobalMod, socket.uid),
async.apply(user.isModeratorOfAnyCategory, socket.uid) async.apply(user.isModeratorOfAnyCategory, socket.uid)
], function(err, results) { ], function (err, results) {
next(err, results[0] || results[1]); next(err, results[0] || results[1]);
}); });
}, },

@ -234,14 +234,18 @@ var meta = require('./meta');
privileges.users.isModerator(uid, cid, callback); privileges.users.isModerator(uid, cid, callback);
}; };
User.isModeratorOfAnyCategory = function(uid, callback) { User.isModeratorOfAnyCategory = function (uid, callback) {
// Checks all active categories and determines whether passed-in uid is a mod of any of them // Checks all active categories and determines whether passed-in uid is a mod of any of them
db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) { db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) {
async.filter(cids, function(cid, next) { async.filter(cids, function (cid, next) {
User.isModerator(uid, cid, function(err, isMod) { User.isModerator(uid, cid, function (err, isMod) {
if (err) {
// do nothing because async doesn't support errors in filter yet
}
next(!!isMod); next(!!isMod);
}); });
}, function(result) { }, function (result) {
callback(err, result); callback(err, result);
}); });
}); });
@ -291,12 +295,12 @@ var meta = require('./meta');
}); });
}; };
User.getAdminsandGlobalModsandModerators = function(callback) { User.getAdminsandGlobalModsandModerators = function (callback) {
async.parallel([ async.parallel([
async.apply(groups.getMembers, 'administrators', 0, -1), async.apply(groups.getMembers, 'administrators', 0, -1),
async.apply(groups.getMembers, 'Global Moderators', 0, -1), async.apply(groups.getMembers, 'Global Moderators', 0, -1),
async.apply(User.getModeratorUids) async.apply(User.getModeratorUids)
], function(err, results) { ], function (err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -305,15 +309,15 @@ var meta = require('./meta');
}); });
}; };
User.getModeratorUids = function(callback) { User.getModeratorUids = function (callback) {
async.waterfall([ async.waterfall([
async.apply(db.getSortedSetRange, 'categories:cid', 0, -1), async.apply(db.getSortedSetRange, 'categories:cid', 0, -1),
function(cids, next) { function (cids, next) {
var groupNames = cids.map(function(cid) { var groupNames = cids.map(function (cid) {
return 'cid:' + cid + ':privileges:mods'; return 'cid:' + cid + ':privileges:mods';
}); });
groups.getMembersOfGroups(groupNames, function(err, memberSets) { groups.getMembersOfGroups(groupNames, function (err, memberSets) {
if (err) { if (err) {
return next(err); return next(err);
} }

@ -155,9 +155,9 @@ describe('new Translator(language)', function (){
}); });
}); });
it('should translate [[pages:users/latest]] properly', function(done) { it('should translate [[pages:users/latest]] properly', function (done) {
var translator = new Translator('en_GB'); var translator = new Translator('en_GB');
translator.translate('[[pages:users/latest]]').then(function(translated) { translator.translate('[[pages:users/latest]]').then(function (translated) {
assert.strictEqual('[[pages:users/latest]]', 'Latest Users'); assert.strictEqual('[[pages:users/latest]]', 'Latest Users');
done(); done();
}); });

Loading…
Cancel
Save