Merge pull request #4205 from pichalite/user-search

search banned users only on /users/banned route
v1.18.x
Julian Lam 9 years ago
commit 694b9e38b9

@ -107,7 +107,8 @@ define('forum/users', ['translator'], function(translator) {
page: page, page: page,
searchBy: 'username', searchBy: 'username',
sortBy: $('.search select').val() || getSortBy(), sortBy: $('.search select').val() || getSortBy(),
onlineOnly: $('.search .online-only').is(':checked') || (getActiveSection() === 'online') onlineOnly: $('.search .online-only').is(':checked') || (getActiveSection() === 'online'),
bannedOnly: getActiveSection() === 'banned'
}, function(err, data) { }, function(err, data) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);

@ -19,6 +19,7 @@ module.exports = function(SocketUser) {
searchBy: data.searchBy, searchBy: data.searchBy,
sortBy: data.sortBy, sortBy: data.sortBy,
onlineOnly: data.onlineOnly, onlineOnly: data.onlineOnly,
bannedOnly: data.bannedOnly,
uid: socket.uid uid: socket.uid
}, function(err, result) { }, function(err, result) {
if (err) { if (err) {

@ -84,7 +84,7 @@ module.exports = function(User) {
function filterAndSortUids(uids, data, callback) { function filterAndSortUids(uids, data, callback) {
var sortBy = data.sortBy || 'joindate'; var sortBy = data.sortBy || 'joindate';
var fields = ['uid', 'status', 'lastonline', sortBy]; var fields = ['uid', 'status', 'lastonline', 'banned', sortBy];
User.getUsersFields(uids, fields, function(err, userData) { User.getUsersFields(uids, fields, function(err, userData) {
if (err) { if (err) {
@ -96,6 +96,12 @@ module.exports = function(User) {
return user && user.status !== 'offline' && (Date.now() - parseInt(user.lastonline, 10) < 300000); return user && user.status !== 'offline' && (Date.now() - parseInt(user.lastonline, 10) < 300000);
}); });
} }
if(data.bannedOnly) {
userData = userData.filter(function(user) {
return user && user.banned;
});
}
sortUsers(userData, sortBy); sortUsers(userData, sortBy);

Loading…
Cancel
Save