allow global mods to see banned users

v1.18.x
barisusakli 9 years ago
parent 2560e6345f
commit 1b9e18c6fc

@ -11,7 +11,7 @@
"users/latest": "Latest Users",
"users/sort-posts": "Users with the most posts",
"users/sort-reputation": "Users with the most reputation",
"users/map": "User Map",
"users/banned": "Banned Users",
"users/search": "User Search",
"notifications": "Notifications",

@ -1,6 +1,6 @@
'use strict';
/* globals define, socket, app, templates, bootbox */
/* globals define, socket, app, templates, bootbox, ajaxify */
define('forum/users', ['translator'], function(translator) {
var Users = {};
@ -34,20 +34,9 @@ define('forum/users', ['translator'], function(translator) {
if ($('#search-user').val()) {
return;
}
var set = '';
var activeSection = getActiveSection();
if (activeSection === 'sort-posts') {
set = 'users:postcount';
} else if (activeSection === 'sort-reputation') {
set = 'users:reputation';
} else if (activeSection === 'online') {
set = 'users:online';
} else if (activeSection === 'users') {
set = 'users:joindate';
}
if (set) {
startLoading(set, $('#users-container').children('.registered-user').length);
if (ajaxify.data.setName) {
startLoading(ajaxify.data.setName, $('#users-container').children('.registered-user').length);
}
}
@ -157,7 +146,7 @@ define('forum/users', ['translator'], function(translator) {
templates.parse('users', 'users', data, function(html) {
translator.translate(html, function(translated) {
translated = $(translated)
translated = $(translated);
$('#users-container').html(translated);
translated.find('span.timeago').timeago();
});

@ -13,7 +13,6 @@ var helpers = require('./helpers');
var usersController = {};
usersController.getOnlineUsers = function(req, res, next) {
async.parallel({
userData: function(next) {
usersController.getUsers('users:online', req.uid, req.query.page, next);
@ -53,6 +52,30 @@ usersController.getUsersSortedByJoinDate = function(req, res, next) {
usersController.renderUsersPage('users:joindate', req, res, next);
};
usersController.getBannedUsers = function(req, res, next) {
async.parallel({
userData: function(next) {
usersController.getUsers('users:banned', req.uid, req.query.page, next);
},
isAdministrator: function(next) {
user.isAdministrator(req.uid, next);
},
isGlobalMod: function(next) {
user.isGlobalModerator(req.uid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
if (!results.isAdministrator && !results.isGlobalMod) {
return next();
}
render(req, res, results.userData, next);
});
};
usersController.renderUsersPage = function(set, req, res, next) {
usersController.getUsers(set, req.uid, req.query.page, function(err, userData) {
if (err) {
@ -67,14 +90,16 @@ usersController.getUsers = function(set, uid, page, callback) {
'users:postcount': '[[pages:users/sort-posts]]',
'users:reputation': '[[pages:users/sort-reputation]]',
'users:joindate': '[[pages:users/latest]]',
'users:online': '[[pages:users/online]]'
'users:online': '[[pages:users/online]]',
'users:banned': '[[pages:users/banned]]'
};
var setToCrumbs = {
'users:postcount': '[[users:top_posters]]',
'users:reputation': '[[users:most_reputation]]',
'users:joindate': '[[global:users]]',
'users:online': '[[global:online]]'
'users:online': '[[global:online]]',
'users:banned': '[[user:banned]]'
};
var breadcrumbs = [{text: setToCrumbs[set]}];
@ -102,6 +127,7 @@ usersController.getUsers = function(set, uid, page, callback) {
breadcrumbs: helpers.buildBreadcrumbs(breadcrumbs)
};
userData['route_' + set] = true;
userData.setName = set;
callback(null, userData);
});
};
@ -115,6 +141,8 @@ usersController.getUsersAndCount = function(set, uid, start, stop, callback) {
if (set === 'users:online') {
var now = Date.now();
db.sortedSetCount('users:online', now - 300000, now, next);
} else if (set === 'users:banned') {
db.sortedSetCard('users:banned', next);
} else {
db.getObjectField('global', 'userCount', next);
}
@ -132,7 +160,7 @@ usersController.getUsersAndCount = function(set, uid, start, stop, callback) {
};
function render(req, res, data, next) {
plugins.fireHook('filter:users.build', { req: req, res: res, templateData: data }, function(err, data) {
plugins.fireHook('filter:users.build', {req: req, res: res, templateData: data }, function(err, data) {
if (err) {
return next(err);
}
@ -152,7 +180,6 @@ function render(req, res, data, next) {
data.templateData.invites = num;
res.render('users', data.templateData);
});
});
}

@ -63,6 +63,7 @@ function userRoutes(app, middleware, controllers) {
setupPageRoute(app, '/users/online', middleware, middlewares, controllers.users.getOnlineUsers);
setupPageRoute(app, '/users/sort-posts', middleware, middlewares, controllers.users.getUsersSortedByPosts);
setupPageRoute(app, '/users/sort-reputation', middleware, middlewares, controllers.users.getUsersSortedByReputation);
setupPageRoute(app, '/users/banned', middleware, middlewares, controllers.users.getBannedUsers);
}

@ -246,13 +246,16 @@ SocketUser.loadMore = function(socket, data, callback) {
return callback(new Error('[[error:no-privileges]]'));
}
var start = parseInt(data.after, 10),
stop = start + 19;
var start = parseInt(data.after, 10);
var stop = start + 19;
async.parallel({
isAdmin: function(next) {
user.isAdministrator(socket.uid, next);
},
isGlobalMod: function(next) {
user.isGlobalModerator(socket.uid, next);
},
users: function(next) {
user.getUsersFromSet(data.set, socket.uid, start, stop, next);
}
@ -261,6 +264,9 @@ SocketUser.loadMore = function(socket, data, callback) {
return callback(err);
}
if (data.set === 'users:banned' && !results.isAdmin && !results.isGlobalMod) {
return callback(new Error('[[error:no-privileges]]'));
}
if (!results.isAdmin && data.set === 'users:online') {
results.users = results.users.filter(function(user) {

Loading…
Cancel
Save