|
|
@ -1,6 +1,7 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
var async = require('async');
|
|
|
|
|
|
|
|
var validator = require('validator');
|
|
|
|
|
|
|
|
|
|
|
|
var db = require('../../database');
|
|
|
|
var db = require('../../database');
|
|
|
|
var groups = require('../../groups');
|
|
|
|
var groups = require('../../groups');
|
|
|
@ -16,12 +17,9 @@ groupsController.list = function (req, res, next) {
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
db.getSortedSetRange('groups:createtime', 0, -1, next);
|
|
|
|
getGroupNames(next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (groupNames, next) {
|
|
|
|
function (groupNames, next) {
|
|
|
|
groupNames = groupNames.filter(function (name) {
|
|
|
|
|
|
|
|
return name.indexOf(':privileges:') === -1 && name !== 'registered-users';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
pageCount = Math.ceil(groupNames.length / groupsPerPage);
|
|
|
|
pageCount = Math.ceil(groupNames.length / groupsPerPage);
|
|
|
|
|
|
|
|
|
|
|
|
var start = (page - 1) * groupsPerPage;
|
|
|
|
var start = (page - 1) * groupsPerPage;
|
|
|
@ -44,20 +42,48 @@ groupsController.get = function (req, res, callback) {
|
|
|
|
var groupName = req.params.name;
|
|
|
|
var groupName = req.params.name;
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
groups.exists(groupName, next);
|
|
|
|
async.parallel({
|
|
|
|
|
|
|
|
groupNames: function (next) {
|
|
|
|
|
|
|
|
getGroupNames(next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (exists, next) {
|
|
|
|
group: function (next) {
|
|
|
|
if (!exists) {
|
|
|
|
|
|
|
|
return callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next);
|
|
|
|
groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (group) {
|
|
|
|
}, next);
|
|
|
|
group.isOwner = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
function (result) {
|
|
|
|
|
|
|
|
if (!result.group) {
|
|
|
|
|
|
|
|
return callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.group.isOwner = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.groupNames = result.groupNames.map(function (name) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
encodedName: encodeURIComponent(name),
|
|
|
|
|
|
|
|
displayName: validator.escape(String(name)),
|
|
|
|
|
|
|
|
selected: name === groupName,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
res.render('admin/manage/group', {
|
|
|
|
res.render('admin/manage/group', {
|
|
|
|
group: group,
|
|
|
|
group: result.group,
|
|
|
|
|
|
|
|
groupNames: result.groupNames,
|
|
|
|
allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1,
|
|
|
|
allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
], callback);
|
|
|
|
], callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getGroupNames(callback) {
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
|
|
|
function (next) {
|
|
|
|
|
|
|
|
db.getSortedSetRange('groups:createtime', 0, -1, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (groupNames, next) {
|
|
|
|
|
|
|
|
groupNames = groupNames.filter(function (name) {
|
|
|
|
|
|
|
|
return name !== 'registered-users' && !groups.isPrivilegeGroup(name);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
next(null, groupNames);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
], callback);
|
|
|
|
|
|
|
|
}
|
|
|
|