v1.18.x
barisusakli 11 years ago
parent 2bb5918b6c
commit 175230e337

@ -11,7 +11,8 @@ var async = require('async'),
plugins = require('./../plugins'), plugins = require('./../plugins'),
widgets = require('./../widgets'), widgets = require('./../widgets'),
groups = require('./../groups'), groups = require('./../groups'),
pkg = require('./../../package.json'); pkg = require('./../../package.json'),
validator = require('validator');
@ -39,24 +40,26 @@ adminController.home = function(req, res, next) {
}; };
adminController.categories.active = function(req, res, next) { adminController.categories.active = function(req, res, next) {
categories.getAllCategories(0, function (err, data) { filterAndRenderCategories(req, res, next, true);
data.categories = data.categories.filter(function (category) {
return !category.disabled;
});
res.render('admin/categories', data);
});
}; };
adminController.categories.disabled = function(req, res, next) { adminController.categories.disabled = function(req, res, next) {
filterAndRenderCategories(req, res, next, false);
};
function filterAndRenderCategories(req, res, next, active) {
categories.getAllCategories(0, function (err, data) { categories.getAllCategories(0, function (err, data) {
data.categories = data.categories.filter(function (category) { data.categories = data.categories.filter(function (category) {
return category.disabled; return active ? !category.disabled : category.disabled;
});
data.categories.forEach(function(category) {
category.description = validator.escape(category.description);
}); });
res.render('admin/categories', data); res.render('admin/categories', data);
}); });
}; }
adminController.database.get = function(req, res, next) { adminController.database.get = function(req, res, next) {
db.info(function (err, data) { db.info(function (err, data) {
@ -79,7 +82,7 @@ adminController.events.get = function(req, res, next) {
if(err || !data) { if(err || !data) {
return next(err); return next(err);
} }
data = data.toString().split('\n').reverse().join('\n'); data = data.toString().split('\n').reverse().join('\n');
res.render('admin/events', { res.render('admin/events', {
eventdata: data eventdata: data

Loading…
Cancel
Save