|
|
@ -10,7 +10,6 @@ var async = require('async'),
|
|
|
|
user = require('../user'),
|
|
|
|
user = require('../user'),
|
|
|
|
favourites = require('../favourites'),
|
|
|
|
favourites = require('../favourites'),
|
|
|
|
posts = require('../posts'),
|
|
|
|
posts = require('../posts'),
|
|
|
|
privileges = require('../privileges'),
|
|
|
|
|
|
|
|
meta = require('../meta');
|
|
|
|
meta = require('../meta');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function(Topics) {
|
|
|
|
module.exports = function(Topics) {
|
|
|
@ -109,9 +108,6 @@ module.exports = function(Topics) {
|
|
|
|
next(null, editorData);
|
|
|
|
next(null, editorData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
privileges: function(next) {
|
|
|
|
|
|
|
|
privileges.posts.get(pids, uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
parents: function(next) {
|
|
|
|
parents: function(next) {
|
|
|
|
Topics.addParentPosts(postData, next);
|
|
|
|
Topics.addParentPosts(postData, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -129,14 +125,8 @@ module.exports = function(Topics) {
|
|
|
|
postObj.upvoted = results.voteData.upvotes[i];
|
|
|
|
postObj.upvoted = results.voteData.upvotes[i];
|
|
|
|
postObj.downvoted = results.voteData.downvotes[i];
|
|
|
|
postObj.downvoted = results.voteData.downvotes[i];
|
|
|
|
postObj.votes = postObj.votes || 0;
|
|
|
|
postObj.votes = postObj.votes || 0;
|
|
|
|
postObj.display_moderator_tools = results.privileges[i].editable;
|
|
|
|
|
|
|
|
postObj.display_move_tools = results.privileges[i].move && postObj.index !== 0;
|
|
|
|
|
|
|
|
postObj.selfPost = !!parseInt(uid, 10) && parseInt(uid, 10) === parseInt(postObj.uid, 10);
|
|
|
|
postObj.selfPost = !!parseInt(uid, 10) && parseInt(uid, 10) === parseInt(postObj.uid, 10);
|
|
|
|
|
|
|
|
|
|
|
|
if (postObj.deleted && !results.privileges[i].view_deleted) {
|
|
|
|
|
|
|
|
postObj.content = '[[topic:post_is_deleted]]';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Username override for guests, if enabled
|
|
|
|
// Username override for guests, if enabled
|
|
|
|
if (parseInt(meta.config.allowGuestHandles, 10) === 1 && parseInt(postObj.uid, 10) === 0 && postObj.handle) {
|
|
|
|
if (parseInt(meta.config.allowGuestHandles, 10) === 1 && parseInt(postObj.uid, 10) === 0 && postObj.handle) {
|
|
|
|
postObj.user.username = validator.escape(postObj.handle);
|
|
|
|
postObj.user.username = validator.escape(postObj.handle);
|
|
|
@ -148,6 +138,18 @@ module.exports = function(Topics) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Topics.modifyByPrivilege = function(postData, topicPrivileges) {
|
|
|
|
|
|
|
|
postData.forEach(function(post) {
|
|
|
|
|
|
|
|
if (post) {
|
|
|
|
|
|
|
|
post.display_moderator_tools = topicPrivileges.isAdminOrMod || post.selfPost;
|
|
|
|
|
|
|
|
post.display_move_tools = topicPrivileges.isAdminOrMod && post.index !== 0;
|
|
|
|
|
|
|
|
if (post.deleted && !(topicPrivileges.isAdminOrMod || post.selfPost)) {
|
|
|
|
|
|
|
|
post.content = '[[topic:post_is_deleted]]';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Topics.addParentPosts = function(postData, callback) {
|
|
|
|
Topics.addParentPosts = function(postData, callback) {
|
|
|
|
var parentPids = postData.map(function(postObj) {
|
|
|
|
var parentPids = postData.map(function(postObj) {
|
|
|
|
return postObj && postObj.hasOwnProperty('toPid') ? parseInt(postObj.toPid, 10) : null;
|
|
|
|
return postObj && postObj.hasOwnProperty('toPid') ? parseInt(postObj.toPid, 10) : null;
|
|
|
|