mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
fixxed categories.get; privileges object and currentPage were missing on original route
This commit is contained in:
@@ -79,15 +79,17 @@ categoriesController.unreadTotal = function(req, res, next) {
|
|||||||
categoriesController.get = function(req, res, next) {
|
categoriesController.get = function(req, res, next) {
|
||||||
var cid = req.params.category_id,
|
var cid = req.params.category_id,
|
||||||
page = req.query.page || 1,
|
page = req.query.page || 1,
|
||||||
uid = req.user ? req.user.uid : 0;
|
uid = req.user ? req.user.uid : 0,
|
||||||
|
privileges = null;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
categoryTools.privileges(cid, uid, function(err, privileges) {
|
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
if (!privileges.read) {
|
if (!categoryPrivileges.read) {
|
||||||
next(new Error('not-enough-privileges'));
|
next(new Error('not-enough-privileges'));
|
||||||
} else {
|
} else {
|
||||||
|
privileges = categoryPrivileges;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -147,9 +149,7 @@ categoriesController.get = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
next(null, {
|
next(null, categoryData);
|
||||||
topics: categoryData
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
], function (err, data) {
|
], function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -160,8 +160,8 @@ categoriesController.get = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.topics.link) {
|
if(data.link) {
|
||||||
return res.redirect(data.topics.link);
|
return res.redirect(data.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
var category_url = cid + (req.params.slug ? '/' + req.params.slug : '');
|
var category_url = cid + (req.params.slug ? '/' + req.params.slug : '');
|
||||||
@@ -170,16 +170,23 @@ categoriesController.get = function(req, res, next) {
|
|||||||
category_url += '?' + queryString;
|
category_url += '?' + queryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.privileges = privileges;
|
||||||
|
data.currentPage = page;
|
||||||
|
|
||||||
// Paginator for noscript
|
// Paginator for noscript
|
||||||
data.topics.pages = [];
|
data.pages = [];
|
||||||
for(var x=1;x<=data.topics.pageCount;x++) {
|
for(var x=1;x<=data.pageCount;x++) {
|
||||||
data.topics.pages.push({
|
data.pages.push({
|
||||||
page: x,
|
page: x,
|
||||||
active: x === parseInt(page, 10)
|
active: x === parseInt(page, 10)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('category', data.topics);
|
if (res.locals.isAPI) {
|
||||||
|
res.json(data);
|
||||||
|
} else {
|
||||||
|
res.render('category', data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user