mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
closes #6311
This commit is contained in:
@@ -10,6 +10,8 @@ var socketTopics = require('../topics');
|
||||
var privileges = require('../../privileges');
|
||||
var plugins = require('../../plugins');
|
||||
var social = require('../../social');
|
||||
var user = require('../../user');
|
||||
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
SocketPosts.loadPostTools = function (socket, data, callback) {
|
||||
@@ -20,10 +22,16 @@ module.exports = function (SocketPosts) {
|
||||
function (next) {
|
||||
async.parallel({
|
||||
posts: function (next) {
|
||||
posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid'], next);
|
||||
posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip'], next);
|
||||
},
|
||||
isAdminOrMod: function (next) {
|
||||
privileges.categories.isAdminOrMod(data.cid, socket.uid, next);
|
||||
isAdmin: function (next) {
|
||||
user.isAdministrator(socket.uid, next);
|
||||
},
|
||||
isGlobalMod: function (next) {
|
||||
user.isGlobalModerator(socket.uid, next);
|
||||
},
|
||||
isModerator: function (next) {
|
||||
user.isModerator(socket.uid, data.cid, next);
|
||||
},
|
||||
canEdit: function (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_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_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);
|
||||
},
|
||||
], callback);
|
||||
|
||||
Reference in New Issue
Block a user