mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
reverting some of my code and fixed #1322 properly
This commit is contained in:
@@ -755,8 +755,17 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],
|
||||
}
|
||||
|
||||
function onNewPostsLoaded(html, posts) {
|
||||
function getPostPrivileges(pid) {
|
||||
socket.emit('posts.getPrivileges', pid, function(err, privileges) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
toggle_mod_tools(html, privileges);
|
||||
});
|
||||
}
|
||||
|
||||
for (var x = 0, numPosts = posts.length; x < numPosts; x++) {
|
||||
toggle_mod_tools(posts[x].pid, posts[x].display_moderator_tools);
|
||||
getPostPrivileges(posts[x].pid);
|
||||
}
|
||||
|
||||
infiniteLoaderActive = false;
|
||||
@@ -771,9 +780,9 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],
|
||||
showBottomPostBar();
|
||||
}
|
||||
|
||||
|
||||
function toggle_mod_tools(pid, editable) {
|
||||
$('#post-container li[data-pid="' + pid + '"]').find('.edit, .delete').toggleClass('none', !editable);
|
||||
function toggle_mod_tools(postHtml, privileges) {
|
||||
postHtml.find('.edit, .delete').toggleClass('none', !privileges.editable);
|
||||
postHtml.find('.move').toggleClass('none', !privileges.move);
|
||||
}
|
||||
|
||||
function updatePostCount() {
|
||||
|
||||
@@ -219,6 +219,16 @@ function deleteOrRestore(command, socket, data, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
SocketPosts.getPrivileges = function(socket, pid, callback) {
|
||||
postTools.privileges(pid, socket.uid, function(err, privileges) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
privileges.pid = parseInt(pid, 10);
|
||||
callback(null, privileges);
|
||||
});
|
||||
};
|
||||
|
||||
SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
|
||||
|
||||
favourites.getFavouritedUidsByPids([pid], function(err, data) {
|
||||
|
||||
@@ -222,8 +222,8 @@ module.exports = function(Topics) {
|
||||
postData.index = index;
|
||||
postData.favourited = false;
|
||||
postData.votes = 0;
|
||||
postData.display_moderator_tools = false;
|
||||
postData.display_move_tools = false;
|
||||
postData.display_moderator_tools = true;
|
||||
postData.display_move_tools = privileges.admin || privileges.moderator;
|
||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||
|
||||
next(null, postData);
|
||||
|
||||
Reference in New Issue
Block a user