more category hooks

This commit is contained in:
barisusakli
2015-06-19 15:39:33 -04:00
parent abfd58a1a9
commit dff1a04585
3 changed files with 13 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ module.exports = function(Categories) {
], next); ], next);
}, },
function(results, next) { function(results, next) {
plugins.fireHook('action:category.create', category);
next(null, category); next(null, category);
} }
], callback); ], callback);

View File

@@ -3,6 +3,7 @@
var async = require('async'), var async = require('async'),
db = require('../database'), db = require('../database'),
batch = require('../batch'), batch = require('../batch'),
plugins = require('../plugins'),
threadTools = require('../threadTools'); threadTools = require('../threadTools');
@@ -17,7 +18,10 @@ module.exports = function(Categories) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
purgeCategory(cid, callback); async.series([
async.apply(purgeCategory, cid),
async.apply(plugins.fireHook, 'action:category.delete', cid)
], callback);
}); });
}; };

View File

@@ -20,7 +20,13 @@ module.exports = function(Categories) {
var fields = Object.keys(category); var fields = Object.keys(category);
async.each(fields, function(key, next) { async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[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();
});
}); });
}); });
} }