|
|
@ -38,7 +38,7 @@ categoriesController.popular = function(req, res, next) {
|
|
|
|
|
|
|
|
|
|
|
|
categoriesController.unread = function(req, res, next) {
|
|
|
|
categoriesController.unread = function(req, res, next) {
|
|
|
|
var uid = req.user.uid;
|
|
|
|
var uid = req.user.uid;
|
|
|
|
|
|
|
|
|
|
|
|
topics.getUnreadTopics(uid, 0, 19, function (err, data) {
|
|
|
|
topics.getUnreadTopics(uid, 0, 19, function (err, data) {
|
|
|
|
if(err) {
|
|
|
|
if(err) {
|
|
|
|
return next(err);
|
|
|
|
return next(err);
|
|
|
@ -50,7 +50,7 @@ categoriesController.unread = function(req, res, next) {
|
|
|
|
|
|
|
|
|
|
|
|
categoriesController.unreadTotal = function(req, res, next) {
|
|
|
|
categoriesController.unreadTotal = function(req, res, next) {
|
|
|
|
var uid = req.user.uid;
|
|
|
|
var uid = req.user.uid;
|
|
|
|
|
|
|
|
|
|
|
|
topics.getTotalUnread(uid, function (err, data) {
|
|
|
|
topics.getTotalUnread(uid, function (err, data) {
|
|
|
|
if(err) {
|
|
|
|
if(err) {
|
|
|
|
return next(err);
|
|
|
|
return next(err);
|
|
|
@ -63,8 +63,7 @@ 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) {
|
|
|
@ -73,15 +72,14 @@ categoriesController.get = function(req, res, next) {
|
|
|
|
if (!categoryPrivileges.read) {
|
|
|
|
if (!categoryPrivileges.read) {
|
|
|
|
next(new Error('not-enough-privileges'));
|
|
|
|
next(new Error('not-enough-privileges'));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
privileges = categoryPrivileges;
|
|
|
|
next(null, categoryPrivileges);
|
|
|
|
next();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
next(err);
|
|
|
|
next(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (next) {
|
|
|
|
function (privileges, next) {
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
return next(err);
|
|
|
@ -97,6 +95,7 @@ categoriesController.get = function(req, res, next) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
categoryData.privileges = privileges;
|
|
|
|
next(err, categoryData);
|
|
|
|
next(err, categoryData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -132,7 +131,7 @@ categoriesController.get = function(req, res, next) {
|
|
|
|
href: nconf.get('url')
|
|
|
|
href: nconf.get('url')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
next(null, categoryData);
|
|
|
|
next(null, categoryData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
], function (err, data) {
|
|
|
|
], function (err, data) {
|
|
|
@ -154,7 +153,6 @@ categoriesController.get = function(req, res, next) {
|
|
|
|
category_url += '?' + queryString;
|
|
|
|
category_url += '?' + queryString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data.privileges = privileges;
|
|
|
|
|
|
|
|
data.currentPage = page;
|
|
|
|
data.currentPage = page;
|
|
|
|
|
|
|
|
|
|
|
|
// Paginator for noscript
|
|
|
|
// Paginator for noscript
|
|
|
|