From 621ae9c91ac03d99cd0a0993e19c872c53610fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=B5=D0=B2?= Date: Wed, 1 Apr 2015 15:11:15 +0300 Subject: [PATCH] Add admin hooks for get categories --- src/controllers/admin.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/controllers/admin.js b/src/controllers/admin.js index 24332866f9..48d8b112d2 100644 --- a/src/controllers/admin.js +++ b/src/controllers/admin.js @@ -135,11 +135,17 @@ adminController.categories.get = function(req, res, next) { if (err) { return next(err); } - - res.render('admin/manage/category', { - category: data.category[0], - privileges: data.privileges - }); + + plugins.fireHook('filter:admin.categories.get', {req: req, res: res, category: data.category[0], privileges: data.privileges}, function(err, data) { + if (err) { + return next(err); + } + + res.render('admin/manage/category', { + category: data.category, + privileges: data.privileges + }); + }); }); }; @@ -152,14 +158,20 @@ adminController.categories.getAll = function(req, res, next) { if (err) { return next(err); } - - categoryData.filter(Boolean).forEach(function(category) { - (category.disabled ? disabled : active).push(category); - }); - - res.render('admin/manage/categories', { - active: active, - disabled: disabled + + plugins.fireHook('filter:admin.categories.getAll', {req: req, res: res, categories: categoryData}, function(err, data) { + if (err) { + return next(err); + } + + data.categories.filter(Boolean).forEach(function(category) { + (category.disabled ? disabled : active).push(category); + }); + + res.render('admin/manage/categories', { + active: active, + disabled: disabled + }); }); }); };