mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
closes #1735
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
var async = require('async'),
|
||||
|
||||
posts = require('../posts'),
|
||||
topics = require('../topics'),
|
||||
user = require('../user'),
|
||||
helpers = require('./helpers'),
|
||||
groups = require('../groups'),
|
||||
@@ -64,13 +65,23 @@ module.exports = function(privileges) {
|
||||
privileges.posts.canEdit = function(pid, uid, callback) {
|
||||
helpers.some([
|
||||
function(next) {
|
||||
posts.isOwner(pid, uid, next);
|
||||
},
|
||||
function(next) {
|
||||
helpers.hasEnoughReputationFor('privileges:manage_content', uid, next);
|
||||
},
|
||||
function(next) {
|
||||
helpers.hasEnoughReputationFor('privileges:manage_topic', uid, next);
|
||||
isPostTopicLocked(pid, function(err, isLocked) {
|
||||
if (err || isLocked) {
|
||||
return next(err, false);
|
||||
}
|
||||
|
||||
helpers.some([
|
||||
function(next) {
|
||||
posts.isOwner(pid, uid, next);
|
||||
},
|
||||
function(next) {
|
||||
helpers.hasEnoughReputationFor('privileges:manage_content', uid, next);
|
||||
},
|
||||
function(next) {
|
||||
helpers.hasEnoughReputationFor('privileges:manage_topic', uid, next);
|
||||
}
|
||||
], next);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
isAdminOrMod(pid, uid, next);
|
||||
@@ -87,6 +98,15 @@ module.exports = function(privileges) {
|
||||
});
|
||||
};
|
||||
|
||||
function isPostTopicLocked(pid, callback) {
|
||||
posts.getPostField(pid, 'tid', function(err, tid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
topics.isLocked(tid, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function isAdminOrMod(pid, uid, callback) {
|
||||
helpers.some([
|
||||
function(next) {
|
||||
|
||||
Reference in New Issue
Block a user