mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-15 03:11:14 +02:00
closes #1725
removed move button from main post, disable moving main post, fixed moving posts.
This commit is contained in:
@@ -18,12 +18,6 @@ var winston = require('winston'),
|
||||
|
||||
(function(PostTools) {
|
||||
|
||||
PostTools.isMain = function(pid, tid, callback) {
|
||||
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
|
||||
callback(err, parseInt(pid, 10) === parseInt(mainPid, 10));
|
||||
});
|
||||
};
|
||||
|
||||
PostTools.edit = function(uid, pid, title, content, options, callback) {
|
||||
options = options || {};
|
||||
|
||||
@@ -57,7 +51,7 @@ var winston = require('winston'),
|
||||
async.parallel({
|
||||
topic: function(next) {
|
||||
var tid = postData.tid;
|
||||
PostTools.isMain(pid, tid, function(err, isMainPost) {
|
||||
posts.isMain(pid, function(err, isMainPost) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
11
src/posts.js
11
src/posts.js
@@ -476,6 +476,17 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
Posts.isMain = function(pid, callback) {
|
||||
Posts.getPostField(pid, 'tid', function(err, tid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
|
||||
callback(err, parseInt(pid, 10) === parseInt(mainPid, 10));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Posts.updatePostVoteCount = function(pid, voteCount, callback) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
|
||||
@@ -79,7 +79,12 @@ module.exports = function(privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.canMove = function(pid, uid, callback) {
|
||||
isAdminOrMod(pid, uid, callback);
|
||||
posts.isMain(pid, function(err, isMain) {
|
||||
if (err || isMain) {
|
||||
return callback(err || new Error('[[error:cant-move-mainpost]]'));
|
||||
}
|
||||
isAdminOrMod(pid, uid, callback);
|
||||
});
|
||||
};
|
||||
|
||||
function isAdminOrMod(pid, uid, callback) {
|
||||
|
||||
@@ -62,7 +62,7 @@ SocketModules.composer.push = function(socket, pid, callback) {
|
||||
topics.getTopicTags(postData.tid, next);
|
||||
},
|
||||
isMain: function(next) {
|
||||
postTools.isMain(pid, postData.tid, next);
|
||||
posts.isMain(pid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
@@ -82,15 +82,9 @@ SocketModules.composer.push = function(socket, pid, callback) {
|
||||
};
|
||||
|
||||
SocketModules.composer.editCheck = function(socket, pid, callback) {
|
||||
posts.getPostField(pid, 'tid', function(err, tid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
postTools.isMain(pid, tid, function(err, isMain) {
|
||||
callback(err, {
|
||||
titleEditable: isMain
|
||||
});
|
||||
posts.isMain(pid, function(err, isMain) {
|
||||
callback(err, {
|
||||
titleEditable: isMain
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -233,7 +233,7 @@ SocketTopics.movePost = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
privileges.posts.canMove(data.tid, socket.uid, function(err, canMove) {
|
||||
privileges.posts.canMove(data.pid, socket.uid, function(err, canMove) {
|
||||
if (err || !canMove) {
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ module.exports = function(Topics) {
|
||||
postData[i].downvoted = results.voteData[i].downvoted;
|
||||
postData[i].votes = postData[i].votes || 0;
|
||||
postData[i].display_moderator_tools = results.privileges[i].editable;
|
||||
postData[i].display_move_tools = results.privileges[i].move;
|
||||
postData[i].display_move_tools = results.privileges[i].move && postData[i].index !== 0;
|
||||
postData[i].selfPost = parseInt(uid, 10) === parseInt(postData[i].uid, 10);
|
||||
|
||||
if(postData[i].deleted && !results.privileges[i].view_deleted) {
|
||||
|
||||
Reference in New Issue
Block a user