From 8f0f959d53efbc0725dff682dd70cbab08e9ad55 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 13 Jan 2017 12:04:12 +0300 Subject: [PATCH] add `filter:categories.copyPrivilegesFrom` https://github.com/Schamper/nodebb-plugin-poll/issues/77 --- src/categories/create.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/categories/create.js b/src/categories/create.js index 508d8ab348..cebcbcd82b 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -139,9 +139,20 @@ module.exports = function (Categories) { }; Categories.copyPrivilegesFrom = function (fromCid, toCid, callback) { - async.each(privileges.privilegeList, function (privilege, next) { - copyPrivilege(privilege, fromCid, toCid, next); - }, callback); + async.waterfall([ + function (next) { + plugins.fireHook('filter:categories.copyPrivilegesFrom', { + privileges: privileges.privilegeList, + fromCid: fromCid, + toCid: toCid + }, next); + }, + function (data, next) { + async.each(data.privileges, function (privilege, next) { + copyPrivilege(privilege, data.fromCid, data.toCid, next); + }, next); + } + ], callback); }; function copyPrivilege(privilege, fromCid, toCid, callback) {