filter:group.build

v1.18.x
barisusakli 10 years ago
parent 070fe01463
commit 1e44cab79e

@ -8,6 +8,7 @@ var async = require('async'),
groups = require('../groups'), groups = require('../groups'),
user = require('../user'), user = require('../user'),
helpers = require('./helpers'), helpers = require('./helpers'),
plugins = require('../plugins'),
groupsController = {}; groupsController = {};
groupsController.list = function(req, res, next) { groupsController.list = function(req, res, next) {
@ -47,14 +48,14 @@ groupsController.getGroupsFromSet = function(uid, sort, start, stop, callback) {
groupsController.details = function(req, res, callback) { groupsController.details = function(req, res, callback) {
async.waterfall([ async.waterfall([
async.apply(groups.exists, res.locals.groupName), async.apply(groups.exists, res.locals.groupName),
function(exists, next) { function (exists, next) {
if (!exists) { if (!exists) {
return callback(); return callback();
} }
groups.isHidden(res.locals.groupName, next); groups.isHidden(res.locals.groupName, next);
}, },
function(hidden, next) { function (hidden, next) {
if (!hidden) { if (!hidden) {
return next(); return next();
} }
@ -68,33 +69,36 @@ groupsController.details = function(req, res, callback) {
} }
callback(); callback();
}); });
},
function (next) {
async.parallel({
group: function(next) {
groups.get(res.locals.groupName, {
uid: req.uid,
truncateUserList: true,
userListCount: 20
}, next);
},
posts: function(next) {
groups.getLatestMemberPosts(res.locals.groupName, 10, req.uid, next);
},
isAdmin: async.apply(user.isAdministrator, req.uid)
}, next);
},
function (results, next) {
if (!results.group) {
return callback();
}
results.title = '[[pages:group, ' + results.group.displayName + ']]';
results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.displayName}]);
plugins.fireHook('filter:group.build', {req: req, res: res, templateData: results}, next);
} }
], function(err) { ], function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
async.parallel({ res.render('groups/details', results.templateData);
group: function(next) {
groups.get(res.locals.groupName, {
uid: req.uid,
truncateUserList: true,
userListCount: 20
}, next);
},
posts: function(next) {
groups.getLatestMemberPosts(res.locals.groupName, 10, req.uid, next);
},
isAdmin: async.apply(user.isAdministrator, req.uid)
}, function(err, results) {
if (err || !results.group) {
return callback(err);
}
results.title = '[[pages:group, ' + results.group.displayName + ']]';
results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.displayName}]);
res.render('groups/details', results);
});
}); });
}; };

Loading…
Cancel
Save