Merge remote-tracking branch 'origin/master' into 0.7.0

v1.18.x
barisusakli 10 years ago
commit 4413c70d3c

@ -130,7 +130,7 @@ var async = require('async'),
};
Categories.getModerators = function(cid, callback) {
Groups.getMembers('cid:' + cid + ':privileges:mods', function(err, uids) {
Groups.getMembers('cid:' + cid + ':privileges:mods', 0, -1, function(err, uids) {
if (err || !Array.isArray(uids) || !uids.length) {
return callback(err, []);
}

@ -1,8 +1,9 @@
"use strict";
var groups = require('../groups'),
async = require('async'),
var async = require('async'),
nconf = require('nconf'),
groups = require('../groups'),
user = require('../user'),
helpers = require('./helpers'),
groupsController = {};
@ -47,4 +48,25 @@ groupsController.details = function(req, res, next) {
});
};
groupsController.members = function(req, res, next) {
async.waterfall([
function(next) {
groups.getGroupNameByGroupSlug(req.params.slug, next);
},
function(groupName, next) {
user.getUsersFromSet('group:' + groupName + ':members', 0, 49, next);
},
], function(err, users) {
if (err) {
return next(err);
}
res.render('groups/members', {
users: users,
nextStart: 50,
loadmore_display: users.length > 50 ? 'block' : 'hide',
});
});
};
module.exports = groupsController;

@ -113,9 +113,10 @@ var async = require('async'),
}
if (options.truncateUserList) {
if (uids.length > 4) {
var userListCount = parseInt(options.userListCount, 10) || 4;
if (uids.length > userListCount) {
numUsers = uids.length;
uids.length = 4;
uids.length = userListCount;
truncated = true;
}
}
@ -271,8 +272,8 @@ var async = require('async'),
});
};
Groups.getMembers = function(groupName, callback) {
db.getSortedSetRevRange('group:' + groupName + ':members', 0, -1, callback);
Groups.getMembers = function(groupName, start, end, callback) {
db.getSortedSetRevRange('group:' + groupName + ':members', start, end, callback);
};
Groups.isMember = function(uid, groupName, callback) {
@ -761,7 +762,9 @@ var async = require('async'),
Groups.getLatestMemberPosts = function(groupSlug, max, uid, callback) {
async.waterfall([
async.apply(Groups.getGroupNameByGroupSlug, groupSlug),
Groups.getMembers,
function(groupName, next) {
Groups.getMembers(groupName, 0, -1, next);
},
function(uids, next) {
if (!Array.isArray(uids) || !uids.length) {
return callback(null, []);

@ -94,6 +94,7 @@ function groupRoutes(app, middleware, controllers) {
setupPageRoute(app, '/groups', middleware, middlewares, controllers.groups.list);
setupPageRoute(app, '/groups/:slug', middleware, middlewares, controllers.groups.details);
setupPageRoute(app, '/groups/:slug/members', middleware, middlewares, controllers.groups.members);
}
function setupPageRoute(router, name, middleware, middlewares, controller) {

@ -403,10 +403,10 @@ SocketPosts.flag = function(socket, pid, callback) {
function(post, next) {
async.parallel({
admins: function(next) {
groups.getMembers('administrators', next);
groups.getMembers('administrators', 0, -1, next);
},
moderators: function(next) {
groups.getMembers('cid:' + post.topic.cid + ':privileges:mods', next);
groups.getMembers('cid:' + post.topic.cid + ':privileges:mods', 0, -1, next);
}
}, next);
},

Loading…
Cancel
Save