mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
closes #1412
This commit is contained in:
@@ -79,5 +79,7 @@
|
||||
"offline": "Offline",
|
||||
|
||||
"email": "Email",
|
||||
"language": "Language"
|
||||
"language": "Language",
|
||||
|
||||
"guest": "Guest"
|
||||
}
|
||||
|
||||
@@ -102,5 +102,9 @@
|
||||
"composer.thumb_file_label": "Or upload a file",
|
||||
"composer.thumb_remove": "Clear fields",
|
||||
"composer.drag_and_drop_images": "Drag and Drop Images Here",
|
||||
"composer.upload_instructions": "Upload images by dragging & dropping them."
|
||||
"composer.upload_instructions": "Upload images by dragging & dropping them.",
|
||||
|
||||
"more_users_and_guests": "%1 more user(s) and %2 guest(s)",
|
||||
"more_users": "%1 more user(s)",
|
||||
"more_guests": "%1 more guest(s)"
|
||||
}
|
||||
|
||||
@@ -209,20 +209,29 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools',
|
||||
|
||||
var title = '';
|
||||
if(remainingUsers && anonymousCount) {
|
||||
title = remainingUsers + ' more user(s) and ' + anonymousCount + ' guest(s)';
|
||||
title = '[[topic:more_users_and_guests, ' + remainingUsers + ', ' + anonymousCount + ']]';
|
||||
} else if(remainingUsers) {
|
||||
title = remainingUsers + ' more user(s)';
|
||||
title = '[[topic:more_users, ' + remainingUsers + ']]';
|
||||
} else {
|
||||
title = anonymousCount + ' guest(s)';
|
||||
title = '[[topic:more_guests, ' + anonymousCount + ']]';
|
||||
}
|
||||
|
||||
anonLink.tooltip({
|
||||
translator.translate(title, function(translated) {
|
||||
$('.anonymous-box').tooltip({
|
||||
placement: 'top',
|
||||
title: title
|
||||
title: translated
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Get users who are currently replying to the topic entered
|
||||
getReplyingUsers();
|
||||
}
|
||||
|
||||
app.populateOnlineUsers();
|
||||
});
|
||||
|
||||
function getReplyingUsers() {
|
||||
var activeEl = $('.thread_active_users');
|
||||
socket.emit('modules.composer.getUsersByTid', ajaxify.variables.get('topic_id'), function(err, uids) {
|
||||
if (uids && uids.length) {
|
||||
for(var x=0;x<uids.length;x++) {
|
||||
@@ -232,9 +241,6 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools',
|
||||
});
|
||||
}
|
||||
|
||||
app.populateOnlineUsers();
|
||||
});
|
||||
|
||||
socket.on('user.isOnline', function(err, data) {
|
||||
app.populateOnlineUsers();
|
||||
});
|
||||
|
||||
49
src/posts.js
49
src/posts.js
@@ -232,7 +232,7 @@ var db = require('./database'),
|
||||
}
|
||||
|
||||
post.user = {
|
||||
username: userData.username || 'anonymous',
|
||||
username: userData.username || 'Guest',
|
||||
userslug: userData.userslug || '',
|
||||
reputation: userData.reputation || 0,
|
||||
postcount: userData.postcount || 0,
|
||||
@@ -282,17 +282,11 @@ var db = require('./database'),
|
||||
|
||||
post.relativeTime = utils.toISOString(post.timestamp);
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
user.getUserFields(post.uid, ['username', 'userslug', 'picture'], function(err, userData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
post.user = userData;
|
||||
next();
|
||||
});
|
||||
async.parallel({
|
||||
user: function(next) {
|
||||
user.getNameSlugPicture(post.uid, next);
|
||||
},
|
||||
function(next) {
|
||||
topicCategory: function(next) {
|
||||
topics.getTopicFields(post.tid, ['title', 'cid', 'slug', 'deleted'], function(err, topicData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -305,35 +299,36 @@ var db = require('./database'),
|
||||
return next(err);
|
||||
}
|
||||
|
||||
post.category = categoryData;
|
||||
topicData.title = validator.escape(topicData.title);
|
||||
post.topic = topicData;
|
||||
next();
|
||||
|
||||
next(null, {topic: topicData, category: categoryData});
|
||||
});
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
content: function(next) {
|
||||
if (!post.content) {
|
||||
return next();
|
||||
return next(null, post.content);
|
||||
}
|
||||
|
||||
postTools.parse(post.content, function(err, content) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
postTools.parse(post.content, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if(stripTags) {
|
||||
var s = S(content);
|
||||
post.user = results.user;
|
||||
post.topic = results.topicCategory.topic;
|
||||
post.category = results.topicCategory.category;
|
||||
|
||||
if (stripTags) {
|
||||
var s = S(results.content);
|
||||
post.content = s.stripTags.apply(s, utils.getTagsExcept(['img', 'i', 'p'])).s;
|
||||
} else {
|
||||
post.content = content;
|
||||
post.content = results.content;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
], function(err) {
|
||||
callback(err, post);
|
||||
callback(null, post);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ Sockets.init = function(server) {
|
||||
socket.broadcast.emit('user.anonConnect');
|
||||
socket.emit('event:connect', {
|
||||
status: 1,
|
||||
username: 'Anonymous',
|
||||
username: '[[global:guest]]',
|
||||
isAdmin: false,
|
||||
uid: 0
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ SocketMeta.updateHeader = function(socket, data, callback) {
|
||||
} else {
|
||||
callback(null, {
|
||||
uid: 0,
|
||||
username: "Anonymous User",
|
||||
username: '[[global:guest]]',
|
||||
email: '',
|
||||
picture: gravatar.url('', {
|
||||
s: '24'
|
||||
|
||||
@@ -61,22 +61,9 @@ var async = require('async'),
|
||||
return callback(err || new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
user.getUserFields(topic.uid, ['username', 'userslug', 'picture'] , function(err, userData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!userData) {
|
||||
userData = {};
|
||||
}
|
||||
|
||||
topic.user = {
|
||||
username: userData.username || 'Anonymous',
|
||||
userslug: userData.userslug || '',
|
||||
picture: userData.picture || gravatar.url('', {}, true)
|
||||
};
|
||||
|
||||
callback(null, topic);
|
||||
user.getNameSlugPicture(topic.uid, function(err, userData) {
|
||||
topic.user = userData;
|
||||
callback(err, topic);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -219,7 +206,8 @@ var async = require('async'),
|
||||
if (userCache[topicData.uid]) {
|
||||
return next(null, userCache[topicData.uid]);
|
||||
}
|
||||
user.getUserFields(topicData.uid, ['username', 'userslug', 'picture'], next);
|
||||
|
||||
user.getNameSlugPicture(topicData.uid, next);
|
||||
}
|
||||
}, function(err, topicInfo) {
|
||||
if(err) {
|
||||
@@ -332,18 +320,13 @@ var async = require('async'),
|
||||
return callback(new Error('[[error:no-teaser]]'));
|
||||
}
|
||||
|
||||
user.getUserFields(postData.uid, ['username', 'userslug', 'picture'], function(err, userData) {
|
||||
user.getNameSlugPicture(postData.uid, function(err, userData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
pid: postData.pid,
|
||||
username: userData.username || 'anonymous',
|
||||
userslug: userData.userslug || '',
|
||||
picture: userData.picture || gravatar.url('', {}, true),
|
||||
timestamp: utils.toISOString(postData.timestamp)
|
||||
});
|
||||
postData.timestamp = utils.toISOString(postData.timestamp);
|
||||
postData.user = userData;
|
||||
callback(null, postData);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
14
src/user.js
14
src/user.js
@@ -285,6 +285,20 @@ var bcrypt = require('bcryptjs'),
|
||||
});
|
||||
};
|
||||
|
||||
User.getNameSlugPicture = function(uid, callback) {
|
||||
User.getUserFields(uid, ['username', 'userslug', 'picture'], function(err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
username: data.username || '[[global:guest]]',
|
||||
userslug: data.userslug || '',
|
||||
picture: data.picture || gravatar.url('', {}, true)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
User.getUidByUsername = function(username, callback) {
|
||||
db.getObjectField('username:uid', username, callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user