v1.18.x
barisusakli 11 years ago
parent e56b18822b
commit ddb02978c8

@ -3,48 +3,45 @@
var usersController = {};
var async = require('async'),
user = require('./../user'),
db = require('./../database');
user = require('../user'),
db = require('../database');
usersController.getOnlineUsers = function(req, res, next) {
var websockets = require('../socket.io');
user.getUsersFromSet('users:online', 0, 49, function (err, users) {
if(err) {
var uid = req.user ? req.user.uid : 0;
async.parallel({
users: function(next) {
user.getUsersFromSet('users:online', 0, 49, next);
},
count: function(next) {
db.sortedSetCard('users:online', next);
},
isAdministrator: function(next) {
user.isAdministrator(uid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
var uid = req.user ? req.user.uid : 0;
user.isAdministrator(uid, function (err, isAdministrator) {
if(err) {
return next(err);
}
if (!isAdministrator) {
users = users.filter(function(user) {
return user.status !== 'offline';
});
}
var anonymousUserCount = websockets.getOnlineAnonCount();
if (!results.isAdministrator) {
results.users = results.users.filter(function(user) {
return user && user.status !== 'offline';
});
}
db.sortedSetCard('users:online', function(err, count) {
if (err) {
return next(err);
}
var anonymousUserCount = websockets.getOnlineAnonCount();
var userData = {
search_display: 'none',
loadmore_display: count > 50 ? 'block' : 'hide',
users: users,
anonymousUserCount: anonymousUserCount,
show_anon: anonymousUserCount?'':'hide'
};
var userData = {
search_display: 'none',
loadmore_display: results.count > 50 ? 'block' : 'hide',
users: results.users,
anonymousUserCount: anonymousUserCount,
show_anon: anonymousUserCount ? '' : 'hide'
};
res.render('users', userData);
});
});
res.render('users', userData);
});
};
@ -61,27 +58,29 @@ usersController.getUsersSortedByJoinDate = function(req, res, next) {
};
function getUsers(set, res, next) {
user.getUsersFromSet(set, 0, 49, function (err, data) {
async.parallel({
users: function(next) {
user.getUsersFromSet(set, 0, 49, next);
},
count: function(next) {
db.sortedSetCard(set, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
data = data.filter(function(user) {
results.users = results.users.filter(function(user) {
return user && parseInt(user.uid, 10);
});
db.sortedSetCard(set, function(err, count) {
if (err) {
return next(err);
}
var userData = {
search_display: 'none',
loadmore_display: count > 50 ? 'block' : 'hide',
users: data,
show_anon: 'hide'
};
res.render('users', userData);
});
var userData = {
search_display: 'none',
loadmore_display: results.count > 50 ? 'block' : 'hide',
users: results.users,
show_anon: 'hide'
};
res.render('users', userData);
});
}

Loading…
Cancel
Save