|
|
|
@ -149,84 +149,6 @@ usersController.getUsersForSearch = function(req, res, next) {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
usersController.getMap = function(req, res, next) {
|
|
|
|
|
var socketIO = require('../socket.io');
|
|
|
|
|
var rooms = require('../socket.io/rooms');
|
|
|
|
|
|
|
|
|
|
var roomNames = ['user_list', 'categories', 'unread_topics', 'recent_topics', 'popular_topics', 'tags'];
|
|
|
|
|
var links = {
|
|
|
|
|
user_list: '/users',
|
|
|
|
|
categories: '/categories',
|
|
|
|
|
unread_topics: '/unread',
|
|
|
|
|
recent_topics: '/recent',
|
|
|
|
|
popular_topics: '/popular',
|
|
|
|
|
tags: '/tags'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var keys = Object.keys(rooms.roomClients());
|
|
|
|
|
|
|
|
|
|
keys = keys.filter(function(key) {
|
|
|
|
|
return key.startsWith('topic_') || key.startsWith('category_');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
roomNames = roomNames.concat(keys);
|
|
|
|
|
|
|
|
|
|
async.map(roomNames, function(roomName, next) {
|
|
|
|
|
socketIO.getUsersInRoom(0, roomName, 0, 39, function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (roomName.startsWith('category_')) {
|
|
|
|
|
var cid = roomName.split('_')[1];
|
|
|
|
|
categories.getCategoryFields(cid, ['slug', 'name'], function(err, categoryData) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
data.room = validator.escape(categoryData.name);
|
|
|
|
|
data.link = '/category/' + categoryData.slug;
|
|
|
|
|
data.core = false;
|
|
|
|
|
next(null, data);
|
|
|
|
|
});
|
|
|
|
|
} else if (roomName.startsWith('topic_')) {
|
|
|
|
|
var tid = roomName.split('_')[1];
|
|
|
|
|
topics.getTopicFields(tid, ['slug', 'title'], function(err, topicData) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
data.room = validator.escape(topicData.title);
|
|
|
|
|
data.link = '/topic/' + topicData.slug;
|
|
|
|
|
data.core = false;
|
|
|
|
|
next(null, data);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
data.core = true;
|
|
|
|
|
next(null, data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
data.sort(function(a, b) {
|
|
|
|
|
return b.users.length - a.users.length;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
data.forEach(function(room) {
|
|
|
|
|
if (!room.link) {
|
|
|
|
|
room.link = links[room.room];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
res.render('usersMap', {
|
|
|
|
|
rooms: data,
|
|
|
|
|
'reputation:disabled': parseInt(meta.config['reputation:disabled'], 10) === 1,
|
|
|
|
|
title: '[[pages:users/map]]',
|
|
|
|
|
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:users]]', url: '/users'}, {text: '[[global:map]]'}])
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function render(req, res, data, next) {
|
|
|
|
|
plugins.fireHook('filter:users.build', {req: req, res: res, templateData: data}, function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|