|
|
|
@ -52,7 +52,22 @@ var path = require('path'),
|
|
|
|
|
config.defaultLang = meta.config.defaultLang || 'en_GB';
|
|
|
|
|
config.environment = process.env.NODE_ENV;
|
|
|
|
|
|
|
|
|
|
res.json(200, config);
|
|
|
|
|
if (!req.user) {
|
|
|
|
|
return res.json(200, config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(req.user) {
|
|
|
|
|
user.getSettings(req.user.uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config.usePagination = settings.usePagination;
|
|
|
|
|
config.topicsPerPage = settings.topicsPerPage;
|
|
|
|
|
config.postsPerPage = settings.postsPerPage;
|
|
|
|
|
res.json(200, config);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/home', function (req, res) {
|
|
|
|
@ -189,33 +204,38 @@ var path = require('path'),
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var postsPerPage = parseInt(meta.config.postsPerPage ? meta.config.postsPerPage : 20, 10);
|
|
|
|
|
var start = (page - 1) * postsPerPage;
|
|
|
|
|
var end = start + postsPerPage - 1;
|
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (privileges.read) {
|
|
|
|
|
topics.getTopicWithPosts(req.params.id, uid, start, end, false, function (err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
var start = (page - 1) * settings.postsPerPage;
|
|
|
|
|
var end = start + settings.postsPerPage - 1;
|
|
|
|
|
|
|
|
|
|
if(page > data.pageCount) {
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (privileges.read) {
|
|
|
|
|
topics.getTopicWithPosts(req.params.id, uid, start, end, false, function (err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.currentPage = page;
|
|
|
|
|
data.privileges = privileges;
|
|
|
|
|
if(page > data.pageCount) {
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
|
|
|
|
return res.json(404, {});
|
|
|
|
|
}
|
|
|
|
|
data.currentPage = page;
|
|
|
|
|
data.privileges = privileges;
|
|
|
|
|
|
|
|
|
|
res.json(data);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
res.send(403);
|
|
|
|
|
}
|
|
|
|
|
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
|
|
|
|
return res.json(404, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.json(data);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
res.send(403);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -230,30 +250,34 @@ var path = require('path'),
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var topicsPerPage = parseInt(meta.config.topicsPerPage ? meta.config.topicsPerPage : 20, 10);
|
|
|
|
|
var start = (page - 1) * topicsPerPage;
|
|
|
|
|
var end = start + topicsPerPage - 1;
|
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Category Whitelisting
|
|
|
|
|
categoryTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (!err && privileges.read) {
|
|
|
|
|
categories.getCategoryById(req.params.id, start, end, uid, function (err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
var start = (page - 1) * settings.topicsPerPage;
|
|
|
|
|
var end = start + settings.topicsPerPage - 1;
|
|
|
|
|
|
|
|
|
|
data.currentPage = page;
|
|
|
|
|
data.privileges = privileges;
|
|
|
|
|
categoryTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (!err && privileges.read) {
|
|
|
|
|
categories.getCategoryById(req.params.id, start, end, uid, function (err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data && parseInt(data.disabled, 10) === 0) {
|
|
|
|
|
res.json(data);
|
|
|
|
|
} else {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
}, req.params.id, uid);
|
|
|
|
|
} else {
|
|
|
|
|
res.send(403);
|
|
|
|
|
}
|
|
|
|
|
data.currentPage = page;
|
|
|
|
|
data.privileges = privileges;
|
|
|
|
|
|
|
|
|
|
if (data && parseInt(data.disabled, 10) === 0) {
|
|
|
|
|
res.json(data);
|
|
|
|
|
} else {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
}, req.params.id, uid);
|
|
|
|
|
} else {
|
|
|
|
|
res.send(403);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|