|
|
@ -10,6 +10,8 @@ var socketTopics = require('../topics');
|
|
|
|
var privileges = require('../../privileges');
|
|
|
|
var privileges = require('../../privileges');
|
|
|
|
var plugins = require('../../plugins');
|
|
|
|
var plugins = require('../../plugins');
|
|
|
|
var social = require('../../social');
|
|
|
|
var social = require('../../social');
|
|
|
|
|
|
|
|
var user = require('../../user');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function (SocketPosts) {
|
|
|
|
module.exports = function (SocketPosts) {
|
|
|
|
SocketPosts.loadPostTools = function (socket, data, callback) {
|
|
|
|
SocketPosts.loadPostTools = function (socket, data, callback) {
|
|
|
@ -20,10 +22,16 @@ module.exports = function (SocketPosts) {
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
posts: function (next) {
|
|
|
|
posts: function (next) {
|
|
|
|
posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid'], next);
|
|
|
|
posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip'], next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
isAdmin: function (next) {
|
|
|
|
|
|
|
|
user.isAdministrator(socket.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
isGlobalMod: function (next) {
|
|
|
|
|
|
|
|
user.isGlobalModerator(socket.uid, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isAdminOrMod: function (next) {
|
|
|
|
isModerator: function (next) {
|
|
|
|
privileges.categories.isAdminOrMod(data.cid, socket.uid, next);
|
|
|
|
user.isModerator(socket.uid, data.cid, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
canEdit: function (next) {
|
|
|
|
canEdit: function (next) {
|
|
|
|
privileges.posts.canEdit(data.pid, socket.uid, next);
|
|
|
|
privileges.posts.canEdit(data.pid, socket.uid, next);
|
|
|
@ -54,7 +62,12 @@ module.exports = function (SocketPosts) {
|
|
|
|
results.posts.display_delete_tools = results.canDelete.flag;
|
|
|
|
results.posts.display_delete_tools = results.canDelete.flag;
|
|
|
|
results.posts.display_flag_tools = socket.uid && !results.posts.selfPost && results.canFlag.flag;
|
|
|
|
results.posts.display_flag_tools = socket.uid && !results.posts.selfPost && results.canFlag.flag;
|
|
|
|
results.posts.display_moderator_tools = results.posts.display_edit_tools || results.posts.display_delete_tools;
|
|
|
|
results.posts.display_moderator_tools = results.posts.display_edit_tools || results.posts.display_delete_tools;
|
|
|
|
results.posts.display_move_tools = results.isAdminOrMod;
|
|
|
|
results.posts.display_move_tools = results.isAdmin || results.isModerator;
|
|
|
|
|
|
|
|
results.posts.display_ip_ban = (results.isAdmin || results.isGlobalMod) && !results.posts.selfPost;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!results.isAdmin && !results.isGlobalMod && !results.isModerator) {
|
|
|
|
|
|
|
|
results.posts.ip = undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
next(null, results);
|
|
|
|
next(null, results);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
], callback);
|
|
|
|
], callback);
|
|
|
|