mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #6562
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"edit-posts": "Edit Posts",
|
||||
"view-edit-history": "View Edit History",
|
||||
"delete-posts": "Delete Posts",
|
||||
"view_deleted": "View Deleted Posts",
|
||||
"upvote-posts": "Upvote Posts",
|
||||
"downvote-posts": "Downvote Posts",
|
||||
"delete-topics": "Delete Topics",
|
||||
|
||||
@@ -313,8 +313,8 @@ Posts.updatePostVoteCount = function (postData, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Posts.modifyPostByPrivilege = function (post, isAdminOrMod) {
|
||||
if (post.deleted && !(isAdminOrMod || post.selfPost)) {
|
||||
Posts.modifyPostByPrivilege = function (post, privileges) {
|
||||
if (post.deleted && !(post.selfPost || privileges['posts:view_deleted'])) {
|
||||
post.content = '[[topic:post_is_deleted]]';
|
||||
if (post.user) {
|
||||
post.user.signature = '';
|
||||
|
||||
@@ -15,6 +15,7 @@ privileges.privilegeLabels = [
|
||||
{ name: '[[admin/manage/privileges:upvote-posts]]' },
|
||||
{ name: '[[admin/manage/privileges:downvote-posts]]' },
|
||||
{ name: '[[admin/manage/privileges:delete-topics]]' },
|
||||
{ name: '[[admin/manage/privileges:view_deleted]]' },
|
||||
{ name: '[[admin/manage/privileges:purge]]' },
|
||||
{ name: '[[admin/manage/privileges:moderate]]' },
|
||||
];
|
||||
@@ -32,6 +33,7 @@ privileges.userPrivilegeList = [
|
||||
'posts:upvote',
|
||||
'posts:downvote',
|
||||
'topics:delete',
|
||||
'posts:view_deleted',
|
||||
'purge',
|
||||
'moderate',
|
||||
];
|
||||
|
||||
@@ -32,12 +32,14 @@ module.exports = function (privileges) {
|
||||
'topics:read': async.apply(helpers.isUserAllowedTo, 'topics:read', uid, cids),
|
||||
read: async.apply(helpers.isUserAllowedTo, 'read', uid, cids),
|
||||
'posts:edit': async.apply(helpers.isUserAllowedTo, 'posts:edit', uid, cids),
|
||||
'posts:view_deleted': async.apply(helpers.isUserAllowedTo, 'posts:view_deleted', uid, cids),
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
var privileges = pids.map(function (pid, i) {
|
||||
var isAdminOrMod = results.isAdmin || results.isModerator[i];
|
||||
var editable = isAdminOrMod || (results.isOwner[i] && results['posts:edit'][i]);
|
||||
var viewDeletedPosts = isAdminOrMod || (results.isOwner[i] && results['posts:view_deleted'][i]);
|
||||
|
||||
return {
|
||||
editable: editable,
|
||||
@@ -46,6 +48,7 @@ module.exports = function (privileges) {
|
||||
isAdminOrMod: isAdminOrMod,
|
||||
'topics:read': results['topics:read'][i] || isAdminOrMod,
|
||||
read: results.read[i] || isAdminOrMod,
|
||||
'posts:view_deleted': viewDeletedPosts,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = function (privileges) {
|
||||
|
||||
privileges.topics.get = function (tid, uid, callback) {
|
||||
var topic;
|
||||
var privs = ['topics:reply', 'topics:read', 'topics:tag', 'topics:delete', 'posts:edit', 'posts:history', 'posts:delete', 'read'];
|
||||
var privs = ['topics:reply', 'topics:read', 'topics:tag', 'topics:delete', 'posts:edit', 'posts:history', 'posts:delete', 'posts:view_deleted', 'read'];
|
||||
async.waterfall([
|
||||
async.apply(topics.getTopicFields, tid, ['cid', 'uid', 'locked', 'deleted']),
|
||||
function (_topic, next) {
|
||||
@@ -46,6 +46,7 @@ module.exports = function (privileges) {
|
||||
'posts:edit': (privData['posts:edit'] && !locked) || isAdminOrMod,
|
||||
'posts:history': privData['posts:history'] || isAdminOrMod,
|
||||
'posts:delete': (privData['posts:delete'] && !locked) || isAdminOrMod,
|
||||
'posts:view_deleted': privData['posts:view_deleted'] || isAdminOrMod,
|
||||
read: privData.read || isAdminOrMod,
|
||||
view_thread_tools: editable || deletable,
|
||||
editable: editable,
|
||||
|
||||
@@ -165,8 +165,8 @@ SocketPosts.getReplies = function (socket, pid, callback) {
|
||||
topics.addPostData(results.posts, socket.uid, next);
|
||||
},
|
||||
function (postData, next) {
|
||||
postData.forEach(function (postData) {
|
||||
posts.modifyPostByPrivilege(postData, postPrivileges.isAdminOrMod);
|
||||
postData.forEach(function (postData, index) {
|
||||
posts.modifyPostByPrivilege(postData, postPrivileges[index]);
|
||||
});
|
||||
next(null, postData);
|
||||
},
|
||||
|
||||
@@ -150,7 +150,7 @@ module.exports = function (Topics) {
|
||||
post.display_post_menu = topicPrivileges.isAdminOrMod || (post.selfPost && !topicData.locked) || ((loggedIn || topicData.postSharing.length) && !post.deleted);
|
||||
post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;
|
||||
|
||||
posts.modifyPostByPrivilege(post, topicPrivileges.isAdminOrMod);
|
||||
posts.modifyPostByPrivilege(post, topicPrivileges);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
27
src/upgrades/1.10.0/view_deleted_privilege.js
Normal file
27
src/upgrades/1.10.0/view_deleted_privilege.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var groups = require('../../groups');
|
||||
var db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Give deleted post viewing privilege to moderators on all categories',
|
||||
timestamp: Date.UTC(2018, 5, 8),
|
||||
method: function (callback) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
async.eachSeries(cids, function (cid, next) {
|
||||
async.waterfall([
|
||||
async.apply(db.getSortedSetRange.bind(db), 'group:cid:' + cid + ':privileges:moderate:members', 0, -1),
|
||||
function (uids, next) {
|
||||
async.each(uids, uid => groups.join('cid:' + cid + ':privileges:posts:view_deleted', uid, next), next);
|
||||
},
|
||||
], next);
|
||||
}, callback);
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -18,7 +18,6 @@
|
||||
<p>
|
||||
[[admin/manage/categories:privileges.description]]
|
||||
</p>
|
||||
<hr />
|
||||
<div class="privilege-table-container">
|
||||
<!-- IF cid -->
|
||||
<!-- IMPORT admin/partials/categories/privileges.tpl -->
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<th class="arrowed" colspan="9">
|
||||
[[admin/manage/categories:privileges.section-posting]]
|
||||
</th>
|
||||
<th class="arrowed" colspan="2">
|
||||
<th class="arrowed" colspan="3">
|
||||
[[admin/manage/categories:privileges.section-moderation]]
|
||||
</th>
|
||||
</tr><tr><!-- zebrastripe reset --></tr>
|
||||
@@ -64,7 +64,7 @@
|
||||
<th class="arrowed" colspan="9">
|
||||
[[admin/manage/categories:privileges.section-posting]]
|
||||
</th>
|
||||
<th class="arrowed" colspan="2">
|
||||
<th class="arrowed" colspan="3">
|
||||
[[admin/manage/categories:privileges.section-moderation]]
|
||||
</th>
|
||||
</tr><tr><!-- zebrastripe reset --></tr>
|
||||
|
||||
Reference in New Issue
Block a user