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