Skip to content

Node.js based forum software built for the modern web

closes #2904

barisusaklib2087f94e21e
diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js
index fe72b5136f..1ffce0b7ce 100644
--- a/src/privileges/helpers.js
+++ b/src/privileges/helpers.js
@@ -83,30 +83,5 @@ function isGuestAllowedTo(privilege, cids, callback) {
groups.isMemberOfGroups('guests', groupKeys, callback);
}
-helpers.hasEnoughReputationFor = function(privilege, uid, callback) {
- if (parseInt(meta.config['privileges:disabled'], 10) || !parseInt(uid, 10)) {
- return callback(null, false);
- }
-
- user.getUserField(uid, 'reputation', function(err, reputation) {
- if (err) {
- return callback(null, false);
- }
-
- reputation = parseInt(reputation, 10);
-
- if (Array.isArray(privilege)) {
- for(var i=0; i<privilege.length; ++i) {
- if (reputation >= parseInt(meta.config[privilege[i]], 10)) {
- return callback(null, true);
- }
- }
-
- callback(null, false);
- } else {
- callback(null, reputation >= parseInt(meta.config[privilege], 10));
- }
- });
-};
module.exports = helpers;
\ No newline at end of file
diff --git a/src/privileges/posts.js b/src/privileges/posts.js
index 5e012dc9e9..8dfd89bff2 100644
--- a/src/privileges/posts.js
+++ b/src/privileges/posts.js
@@ -21,45 +21,34 @@ module.exports = function(privileges) {
if (!Array.isArray(pids) || !pids.length) {
return callback(null, []);
}
+
async.parallel({
- manage: function(next) {
- helpers.hasEnoughReputationFor(['privileges:manage_content', 'privileges:manage_topic'], uid, next);
- },
- isAdministrator: function(next) {
+ isAdmin: function(next){
user.isAdministrator(uid, next);
},
- }, function(err, userResults) {
- if(err) {
+ isModerator: function(next) {
+ posts.isModerator(pids, uid, next);
+ },
+ isOwner: function(next) {
+ posts.isOwner(pids, uid, next);
+ }
+ }, function(err, results) {
+ if (err) {
return callback(err);
}
- var userPriv = userResults.isAdministrator || userResults.manage;
-
- async.parallel({
- isOwner: function(next) {
- posts.isOwner(pids, uid, next);
- },
- isModerator: function(next) {
- posts.isModerator(pids, uid, next);
- }
- }, function(err, postResults) {
- if (err) {
- return callback(err);
- }
-
- var privileges = [];
+ var privileges = [];
- for (var i=0; i<pids.length; ++i) {
- var editable = userPriv || postResults.isModerator[i] || postResults.isOwner[i];
- privileges.push({
- editable: editable,
- view_deleted: editable,
- move: userResults.isAdministrator || postResults.isModerator[i]
- });
- }
+ for (var i=0; i<pids.length; ++i) {
+ var editable = results.isAdmin || results.isModerator[i] || results.isOwner[i];
+ privileges.push({
+ editable: editable,
+ view_deleted: editable,
+ move: results.isAdmin || results.isModerator[i]
+ });
+ }
- callback(null, privileges);
- });
+ callback(null, privileges);
});
};
@@ -126,7 +115,7 @@ module.exports = function(privileges) {
return callback(new Error('[[error:post-edit-duration-expired, ' + meta.config.postEditDuration + ']]'));
}
callback(null, results.isEditable.editable);
- });
+ });
};
privileges.posts.canMove = function(pid, uid, callback) {
@@ -154,16 +143,11 @@ module.exports = function(privileges) {
if (isLocked) {
return callback(null, {isLocked: true});
}
- helpers.some([
- function(next) {
- posts.isOwner(pid, uid, next);
- },
- function(next) {
- helpers.hasEnoughReputationFor(['privileges:manage_content', 'privileges:manage_topic'], uid, next);
- }
- ], function(err, editable) {
- next(err, {editable: editable});
- });
+
+ posts.isOwner(pid, uid, next);
+ },
+ function(isOwner, next) {
+ next(null, {editable: isOwner});
}
], callback);
}
@@ -184,7 +168,7 @@ module.exports = function(privileges) {
if (err || !cid) {
return next(err, false);
}
-
+
user.isModerator(uid, cid, next);
});
},
diff --git a/src/privileges/topics.js b/src/privileges/topics.js
index 8bd43ad7c5..5820c0e7a6 100644
--- a/src/privileges/topics.js
+++ b/src/privileges/topics.js
@@ -25,7 +25,6 @@ module.exports = function(privileges) {
isOwner: function(next) {
next(null, parseInt(uid, 10) === parseInt(topic.uid, 10));
},
- manage_topic: async.apply(helpers.hasEnoughReputationFor, 'privileges:manage_topic', uid),
isAdministrator: async.apply(user.isAdministrator, uid),
isModerator: async.apply(user.isModerator, uid, topic.cid),
disabled: async.apply(categories.getCategoryField, topic.cid, 'disabled')
@@ -38,7 +37,7 @@ module.exports = function(privileges) {
var disabled = parseInt(results.disabled, 10) === 1;
var isAdminOrMod = results.isAdministrator || results.isModerator;
- var editable = isAdminOrMod || results.manage_topic;
+ var editable = isAdminOrMod;
var deletable = isAdminOrMod || results.isOwner;
plugins.fireHook('filter:privileges.topics.get', {
@@ -47,7 +46,7 @@ module.exports = function(privileges) {
view_thread_tools: editable || deletable,
editable: editable,
deletable: deletable,
- view_deleted: isAdminOrMod || results.manage_topic || results.isOwner,
+ view_deleted: isAdminOrMod || results.isOwner,
disabled: disabled,
tid: tid,
uid: uid
@@ -106,9 +105,6 @@ module.exports = function(privileges) {
function(next) {
topics.isOwner(tid, uid, next);
},
- function(next) {
- helpers.hasEnoughReputationFor('privileges:manage_topic', uid, next);
- },
function(next) {
isAdminOrMod(tid, uid, next);
}
diff --git a/src/views/admin/settings/reputation.tpl b/src/views/admin/settings/reputation.tpl
index ae0a6b706e..f5d5171115 100644
--- a/src/views/admin/settings/reputation.tpl
+++ b/src/views/admin/settings/reputation.tpl
@@ -19,24 +19,6 @@
</div>
-<div class="panel panel-default">
- <div class="panel-heading">Privilege Thresholds</div>
- <div class="panel-body">
- <form>
- <p class="help-block">
- Use privilege thresholds to manage how much reputation a user must gain to receive moderator access.
- </p>
- <strong>Manage Thread</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_topic"><br />
- <strong>Manage Content</strong><br /> <input type="text" class="form-control" value="1000" data-field="privileges:manage_content"><br />
- <div class="checkbox">
- <label>
- <input type="checkbox" data-field="privileges:disabled"> <strong>Disable Privilege Threshold System</strong>
- </label>
- </div>
- </form>
- </div>
-</div>
-
<div class="panel panel-default">
<div class="panel-heading">Activity Thresholds</div>
<div class="panel-body">