diff --git a/public/src/forum/admin/categories.js b/public/src/forum/admin/categories.js
index 12b5cf7aee..57cd6210f8 100644
--- a/public/src/forum/admin/categories.js
+++ b/public/src/forum/admin/categories.js
@@ -361,50 +361,22 @@ define(['uploader'], function(uploader) {
Categories.refreshPrivilegeList = function (cid) {
var modalEl = $('#category-permissions-modal'),
- readMembers = modalEl.find('#category-permissions-read'),
- writeMembers = modalEl.find('#category-permissions-write'),
- moderatorsEl = modalEl.find('#category-permissions-mods');
+ memberList = $('.members');
socket.emit('admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
- var readLength = privilegeList['+r'].length,
- writeLength = privilegeList['+w'].length,
- modLength = privilegeList.mods.length,
+ var membersLength = privilegeList.length,
liEl, x, userObj;
- readMembers.html('');
- if (readLength > 0) {
- for(x = 0; x < readLength; x++) {
- userObj = privilegeList['+r'][x];
+ memberList.html('');
+ if (membersLength > 0) {
+ for(x = 0; x < membersLength; x++) {
+ userObj = privilegeList[x];
liEl = $('
').attr('data-uid', userObj.uid).html('');
- readMembers.append(liEl);
+ memberList.append(liEl);
}
} else {
- liEl = $('').addClass('empty').html('All users can read and see this category');
- readMembers.append(liEl);
- }
-
- writeMembers.html('');
- if (writeLength > 0) {
- for(x=0;x').attr('data-uid', userObj.uid).html('');
- writeMembers.append(liEl);
- }
- } else {
- liEl = $('').addClass('empty').html('All users can write to this category');
- writeMembers.append(liEl);
- }
-
- moderatorsEl.html('');
- if (modLength > 0) {
- for(x = 0;x < modLength; x++) {
- userObj = privilegeList.mods[x];
- liEl = $('').attr('data-uid', userObj.uid).html('');
- moderatorsEl.append(liEl);
- }
- } else {
- liEl = $('').addClass('empty').html('No moderators');
- moderatorsEl.append(liEl);
+ liEl = $('').addClass('empty').html('All users can read and post, and reply to topics in this category');
+ memberList.append(liEl);
}
});
};
diff --git a/src/postTools.js b/src/postTools.js
index 27af4631bd..7e56daf332 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -61,10 +61,12 @@ var winston = require('winston'),
}
callback(null, {
- read: results.topicPrivs.read,
- editable: results.topicPrivs.editable || results.isOwner || results.hasEnoughRep,
- view_deleted: results.topicPrivs.view_deleted || results.isOwner || results.hasEnoughRep,
- move: results.topicPrivs.admin || results.topicPrivs.moderator
+ meta: {
+ read: results.topicPrivs.meta.read,
+ editable: results.topicPrivs.meta.editable || results.isOwner || results.hasEnoughRep,
+ view_deleted: results.topicPrivs.meta.view_deleted || results.isOwner || results.hasEnoughRep,
+ move: results.topicPrivs.admin || results.topicPrivs.mods
+ }
});
});
};
diff --git a/src/socket.io/admin/categories.js b/src/socket.io/admin/categories.js
index fce33b81b0..dba2efca97 100644
--- a/src/socket.io/admin/categories.js
+++ b/src/socket.io/admin/categories.js
@@ -69,50 +69,31 @@ Categories.setPrivilege = function(socket, data, callback) {
};
Categories.getPrivilegeSettings = function(socket, cid, callback) {
- async.parallel({
- "+r": function(next) {
- groups.get('cid:' + cid + ':privileges:+r', { expand: true }, function(err, groupObj) {
- if (!err) {
- next.apply(this, arguments);
- } else {
- next(null, {
- members: []
- });
- }
- });
- },
- "+w": function(next) {
- groups.get('cid:' + cid + ':privileges:+w', { expand: true }, function(err, groupObj) {
- if (!err) {
- next.apply(this, arguments);
- } else {
- next(null, {
- members: []
- });
- }
- });
- },
- "mods": function(next) {
- groups.get('cid:' + cid + ':privileges:mods', { expand: true }, function(err, groupObj) {
- if (!err) {
- next.apply(this, arguments);
- } else {
- next(null, {
- members: []
- });
- }
- });
- }
- }, function(err, data) {
- if(err) {
- return callback(err);
- }
+ var privileges = ['read', 'topics:create', 'topics:reply', 'mods'];
+
+ async.reduce(privileges, [], function(members, privilege, next) {
+ groups.get('cid:' + cid + ':privileges:' + privilege, { expand: true }, function(err, groupObj) {
+ if (!err) {
+ members = members.concat(groupObj.members);
+ }
- callback(null, {
- "+r": data['+r'].members,
- "+w": data['+w'].members,
- "mods": data.mods.members
+ next(null, members);
});
+ }, function(err, members) {
+ // Remove duplicates
+ var present = [],
+ x = members.length,
+ uid;
+ while(x--) {
+ uid = parseInt(members[x].uid, 10);
+ if (present.indexOf(uid) !== -1) {
+ members.splice(x, 1);
+ } else {
+ present.push(uid);
+ }
+ }
+
+ callback(err, members);
});
};
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 30d7f018c1..15d8a6b216 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -130,7 +130,7 @@ SocketPosts.getRawPost = function(socket, pid, callback) {
postTools.privileges(pid, socket.uid, next);
},
function(privileges, next) {
- if (!privileges || !privileges.read) {
+ if (!privileges || !privileges.meta.read) {
return next(new Error('[[error:no-privileges]]'));
}
posts.getPostFields(pid, ['content', 'deleted'], next);
diff --git a/src/topics.js b/src/topics.js
index 5f626b3d4a..fb885db5d8 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -133,7 +133,7 @@ var async = require('async'),
async.filter(tids, function(tid, next) {
threadTools.privileges(tid, uid, function(err, privileges) {
- next(!err && privileges.read);
+ next(!err && privileges.meta.read);
});
}, function(tids) {
Topics.getTopicsByTids(tids, uid, function(err, topicData) {
diff --git a/src/topics/unread.js b/src/topics/unread.js
index b6d7460d12..375d921921 100644
--- a/src/topics/unread.js
+++ b/src/topics/unread.js
@@ -50,7 +50,7 @@ module.exports = function(Topics) {
async.filter(newtids, function(tid, next) {
threadTools.privileges(tid, uid, function(err, privileges) {
- next(!err && privileges.read);
+ next(!err && privileges.meta.read);
});
}, function(newtids) {
unreadTids.push.apply(unreadTids, newtids);