v1.18.x
barisusakli 10 years ago
parent 19eaa051c2
commit f7aef56e66

@ -121,7 +121,7 @@ module.exports = function(Topics) {
return next(new Error('[[error:guest-handle-invalid]]'));
}
user.isReadyToPost(data.uid, next);
user.isReadyToPost(data.uid, data.cid, next);
},
function(next) {
plugins.fireHook('filter:topic.post', data, next);
@ -184,22 +184,30 @@ module.exports = function(Topics) {
content = data.content,
postData;
var cid;
async.waterfall([
function(next) {
Topics.getTopicField(tid, 'cid', next);
},
function(_cid, next) {
cid = _cid;
async.parallel({
exists: async.apply(Topics.exists, tid),
locked: async.apply(Topics.isLocked, tid),
canReply: async.apply(privileges.topics.can, 'topics:reply', tid, uid),
isAdmin: async.apply(user.isAdministrator, uid)
isAdmin: async.apply(user.isAdministrator, uid),
isModerator: async.apply(user.isModerator, uid, cid)
}, next);
},
function(results, next) {
if (!results.exists) {
return next(new Error('[[error:no-topic]]'));
}
if (results.locked && !results.isAdmin) {
if (results.locked && !results.isAdmin && !results.isModerator) {
return next(new Error('[[error:topic-locked]]'));
}
if (!results.canReply) {
return next(new Error('[[error:no-privileges]]'));
}
@ -208,7 +216,7 @@ module.exports = function(Topics) {
return next(new Error('[[error:guest-handle-invalid]]'));
}
user.isReadyToPost(uid, next);
user.isReadyToPost(uid, cid, next);
},
function(next) {
plugins.fireHook('filter:topic.reply', data, next);

@ -6,7 +6,7 @@ var async = require('async'),
module.exports = function(User) {
User.isReadyToPost = function(uid, callback) {
User.isReadyToPost = function(uid, cid, callback) {
if (parseInt(uid, 10) === 0) {
return callback();
}
@ -20,6 +20,9 @@ module.exports = function(User) {
},
isAdmin: function(next) {
User.isAdministrator(uid, next);
},
isModerator: function(next) {
User.isModerator(uid, cid, next);
}
}, function(err, results) {
if (err) {
@ -30,7 +33,7 @@ module.exports = function(User) {
return callback(new Error('[[error:no-user]]'));
}
if (results.isAdmin) {
if (results.isAdmin || results.isModerator) {
return callback();
}

Loading…
Cancel
Save