|
|
@ -26,27 +26,18 @@ var winston = require('winston'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PostTools.privileges = function(pid, uid, callback) {
|
|
|
|
PostTools.privileges = function(pid, uid, callback) {
|
|
|
|
if(parseInt(uid, 10) === 0) {
|
|
|
|
async.parallel({
|
|
|
|
callback({
|
|
|
|
topicPrivs: function(next) {
|
|
|
|
editable: false,
|
|
|
|
|
|
|
|
view_deleted: false
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getThreadPrivileges(next) {
|
|
|
|
|
|
|
|
posts.getPostField(pid, 'tid', function(err, tid) {
|
|
|
|
posts.getPostField(pid, 'tid', function(err, tid) {
|
|
|
|
threadTools.privileges(tid, uid, next);
|
|
|
|
threadTools.privileges(tid, uid, next);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isOwner: function(next) {
|
|
|
|
function isOwnPost(next) {
|
|
|
|
|
|
|
|
posts.getPostField(pid, 'uid', function(err, author) {
|
|
|
|
posts.getPostField(pid, 'uid', function(err, author) {
|
|
|
|
next(null, parseInt(author, 10) === parseInt(uid, 10));
|
|
|
|
next(null, parseInt(author, 10) === parseInt(uid, 10));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hasEnoughRep: function(next) {
|
|
|
|
function hasEnoughRep(next) {
|
|
|
|
|
|
|
|
if (parseInt(meta.config['privileges:disabled'], 10)) {
|
|
|
|
if (parseInt(meta.config['privileges:disabled'], 10)) {
|
|
|
|
return next(null, false);
|
|
|
|
return next(null, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -58,11 +49,12 @@ var winston = require('winston'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [getThreadPrivileges, isOwnPost, hasEnoughRep]
|
|
|
|
async.parallel([getThreadPrivileges, isOwnPost, hasEnoughRep], function(err, results) {
|
|
|
|
}, function(err, results) {
|
|
|
|
callback({
|
|
|
|
callback({
|
|
|
|
editable: results[0].editable || results[1] || results[2],
|
|
|
|
read: results.topicPrivs.read,
|
|
|
|
view_deleted: results[0].view_deleted || results[1] || results[2]
|
|
|
|
editable: results.topicPrivs.editable || results.isOwner || results.hasEnoughRep,
|
|
|
|
|
|
|
|
view_deleted: results.topicPrivs.view_deleted || results.isOwner || results.hasEnoughRep
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|