reverting some of my code and fixed #1322 properly

v1.18.x
barisusakli 11 years ago
parent 682fa1f874
commit bdefebeea0

@ -755,9 +755,18 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],
}
function onNewPostsLoaded(html, posts) {
for (var x = 0, numPosts = posts.length; x < numPosts; x++) {
toggle_mod_tools(posts[x].pid, posts[x].display_moderator_tools);
}
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++) {
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);

Loading…
Cancel
Save