removed dupe privilegeList, added missing privilege to copyPrivsFrom

v1.18.x
barisusakli 9 years ago
parent 1f3fa3a90f
commit c969870cb6

@ -97,14 +97,14 @@ module.exports = function(Categories) {
destination = results.destination;
var tasks = [];
if (copyParent && utils.isNumber(destination.parentCid)) {
tasks.push(async.apply(db.sortedSetRemove, 'cid:' + destination.parentCid + ':children', toCid));
}
if (copyParent && utils.isNumber(results.source.parentCid)) {
tasks.push(async.apply(db.sortedSetAdd, 'cid:' + results.source.parentCid + ':children', results.source.order, toCid));
}
}
destination.description = results.source.description;
destination.descriptionParsed = results.source.descriptionParsed;
@ -115,11 +115,11 @@ module.exports = function(Categories) {
destination.numRecentReplies = results.source.numRecentReplies;
destination.class = results.source.class;
destination.imageClass = results.source.imageClass;
if (copyParent) {
destination.parentCid = results.source.parentCid || 0;
destination.parentCid = results.source.parentCid || 0;
}
tasks.push(async.apply(db.setObject, 'category:' + toCid, destination));
async.series(tasks, next);
@ -133,12 +133,7 @@ module.exports = function(Categories) {
};
Categories.copyPrivilegesFrom = function(fromCid, toCid, callback) {
var privilegeList = [
'find', 'read', 'topics:create', 'topics:read', 'topics:reply', 'purge', 'mods',
'groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:reply', 'groups:purge', 'groups:moderate'
];
async.each(privilegeList, function(privilege, next) {
async.each(privileges.privilegeList, function(privilege, next) {
copyPrivilege(privilege, fromCid, toCid, next);
}, callback);
};

@ -2,6 +2,11 @@
var privileges = {};
privileges.userPrivilegeList = ['find', 'read', 'topics:create', 'topics:read', 'topics:reply', 'purge', 'mods'];
privileges.groupPrivilegeList = ['groups:find', 'groups:read', 'groups:topics:create', 'groups:topics:read', 'groups:topics:reply', 'groups:purge', 'groups:moderate'];
privileges.privilegeList = privileges.userPrivileges.concat(privileges.groupPrivileges);
require('./privileges/categories')(privileges);
require('./privileges/topics')(privileges);
require('./privileges/posts')(privileges);

@ -1,14 +1,14 @@
'use strict';
var async = require('async'),
_ = require('underscore'),
var async = require('async');
var _ = require('underscore');
user = require('../user'),
categories = require('../categories'),
groups = require('../groups'),
helpers = require('./helpers'),
plugins = require('../plugins');
var user = require('../user');
var categories = require('../categories');
var groups = require('../groups');
var helpers = require('./helpers');
var plugins = require('../plugins');
module.exports = function(privileges) {
@ -27,13 +27,6 @@ module.exports = function(privileges) {
{name: 'Moderate'}
];
var userPrivilegeList = [
'find', 'read', 'topics:read', 'topics:create', 'topics:reply', 'purge', 'mods'
];
var groupPrivilegeList = [
'groups:find', 'groups:read', 'groups:topics:read', 'groups:topics:create', 'groups:topics:reply', 'groups:purge', 'groups:moderate'
];
async.parallel({
labels: function(next) {
async.parallel({
@ -44,7 +37,7 @@ module.exports = function(privileges) {
users: function(next) {
var privileges;
async.waterfall([
async.apply(plugins.fireHook, 'filter:privileges.list', userPrivilegeList),
async.apply(plugins.fireHook, 'filter:privileges.list', privileges.userPrivilegeList),
function(privs, next) {
privileges = privs;
groups.getMembersOfGroups(privs.map(function(privilege) {
@ -81,7 +74,7 @@ module.exports = function(privileges) {
groups: function(next) {
var privileges;
async.waterfall([
async.apply(plugins.fireHook, 'filter:privileges.groups.list', groupPrivilegeList),
async.apply(plugins.fireHook, 'filter:privileges.groups.list', privileges.groupPrivilegeList),
function(privs, next) {
privileges = privs;
groups.getMembersOfGroups(privs.map(function(privilege) {

Loading…
Cancel
Save