Skip to content

Node.js based forum software built for the modern web

add `filter:categories.copyPrivilegesFrom`

barisusakli8f0f959d53ef
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) {