Skip to content

Node.js based forum software built for the modern web

more category hooks

barisusaklidff1a04585d5
diff --git a/src/categories/create.js b/src/categories/create.js
index 4895e98c34..1b47f87760 100644
--- a/src/categories/create.js
+++ b/src/categories/create.js
@@ -54,6 +54,7 @@ module.exports = function(Categories) {
], next);
},
function(results, next) {
+ plugins.fireHook('action:category.create', category);
next(null, category);
}
], callback);
diff --git a/src/categories/delete.js b/src/categories/delete.js
index 0ebac949d7..1679ab6731 100644
--- a/src/categories/delete.js
+++ b/src/categories/delete.js
@@ -3,6 +3,7 @@
var async = require('async'),
db = require('../database'),
batch = require('../batch'),
+ plugins = require('../plugins'),
threadTools = require('../threadTools');
@@ -17,7 +18,10 @@ module.exports = function(Categories) {
if (err) {
return callback(err);
}
- purgeCategory(cid, callback);
+ async.series([
+ async.apply(purgeCategory, cid),
+ async.apply(plugins.fireHook, 'action:category.delete', cid)
+ ], callback);
});
};
diff --git a/src/categories/update.js b/src/categories/update.js
index 6fcf7d4b57..f1d9ee773c 100644
--- a/src/categories/update.js
+++ b/src/categories/update.js
@@ -20,7 +20,13 @@ module.exports = function(Categories) {
var fields = Object.keys(category);
async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[key], next);
- }, next);
+ }, function(err) {
+ if (err) {
+ return next(err);
+ }
+ plugins.fireHook('action:category.update', {cid: cid, modified: category});
+ next();
+ });
});
});
}