mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 02:25:55 +01:00
remove some parseInts
This commit is contained in:
@@ -41,6 +41,7 @@ module.exports = function (Categories) {
|
||||
numRecentReplies: 1,
|
||||
class: (data.class ? data.class : 'col-md-3 col-xs-6'),
|
||||
imageClass: 'cover',
|
||||
isSection: 0,
|
||||
};
|
||||
|
||||
if (data.backgroundImage) {
|
||||
|
||||
@@ -52,7 +52,7 @@ categoryController.get = function (req, res, callback) {
|
||||
userPrivileges = results.privileges;
|
||||
rssToken = results.rssToken;
|
||||
|
||||
if (!results.categoryData.slug || (results.categoryData && parseInt(results.categoryData.disabled, 10) === 1)) {
|
||||
if (!results.categoryData.slug || (results.categoryData && results.categoryData.disabled)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ helpers.buildCategoryBreadcrumbs = function (cid, callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!parseInt(data.disabled, 10) && !parseInt(data.isSection, 10)) {
|
||||
if (!data.disabled && !data.isSection) {
|
||||
breadcrumbs.unshift({
|
||||
text: validator.escape(String(data.name)),
|
||||
url: nconf.get('relative_path') + '/category/' + data.slug,
|
||||
|
||||
@@ -13,7 +13,7 @@ var primaryDB = require('./database/' + databaseName);
|
||||
|
||||
primaryDB.parseIntField = function (data, field) {
|
||||
if (data.hasOwnProperty(field)) {
|
||||
data[field] = parseInt(data[field], 10);
|
||||
data[field] = parseInt(data[field], 10) || 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ module.exports = function (privileges) {
|
||||
categories.getCategoryField(cid, 'disabled', next);
|
||||
},
|
||||
function (disabled, next) {
|
||||
if (parseInt(disabled, 10) === 1) {
|
||||
if (disabled) {
|
||||
return callback(null, false);
|
||||
}
|
||||
helpers.some([
|
||||
|
||||
@@ -15,6 +15,7 @@ module.exports = function (privileges) {
|
||||
privileges.topics = {};
|
||||
|
||||
privileges.topics.get = function (tid, uid, callback) {
|
||||
uid = parseInt(uid, 10);
|
||||
var topic;
|
||||
var privs = ['topics:reply', 'topics:read', 'topics:tag', 'topics:delete', 'posts:edit', 'posts:history', 'posts:delete', 'posts:view_deleted', 'read', 'purge'];
|
||||
async.waterfall([
|
||||
@@ -30,23 +31,20 @@ module.exports = function (privileges) {
|
||||
},
|
||||
function (results, next) {
|
||||
var privData = _.zipObject(privs, results.privileges);
|
||||
var disabled = parseInt(results.disabled, 10) === 1;
|
||||
var locked = parseInt(topic.locked, 10) === 1;
|
||||
var deleted = parseInt(topic.deleted, 10) === 1;
|
||||
var isOwner = !!parseInt(uid, 10) && parseInt(uid, 10) === parseInt(topic.uid, 10);
|
||||
var isOwner = uid > 0 && uid === topic.uid;
|
||||
var isAdminOrMod = results.isAdministrator || results.isModerator;
|
||||
var editable = isAdminOrMod;
|
||||
var deletable = isAdminOrMod || (isOwner && privData['topics:delete']);
|
||||
var purge = results.isAdministrator || privData.purge;
|
||||
|
||||
plugins.fireHook('filter:privileges.topics.get', {
|
||||
'topics:reply': (privData['topics:reply'] && !locked && !deleted) || isAdminOrMod,
|
||||
'topics:reply': (privData['topics:reply'] && !topic.locked && !topic.deleted) || isAdminOrMod,
|
||||
'topics:read': privData['topics:read'] || isAdminOrMod,
|
||||
'topics:tag': privData['topics:tag'] || isAdminOrMod,
|
||||
'topics:delete': (isOwner && privData['topics:delete']) || isAdminOrMod,
|
||||
'posts:edit': (privData['posts:edit'] && !locked) || isAdminOrMod,
|
||||
'posts:edit': (privData['posts:edit'] && !topic.locked) || isAdminOrMod,
|
||||
'posts:history': privData['posts:history'] || isAdminOrMod,
|
||||
'posts:delete': (privData['posts:delete'] && !locked) || isAdminOrMod,
|
||||
'posts:delete': (privData['posts:delete'] && !topic.locked) || isAdminOrMod,
|
||||
'posts:view_deleted': privData['posts:view_deleted'] || isAdminOrMod,
|
||||
read: privData.read || isAdminOrMod,
|
||||
view_thread_tools: editable || deletable,
|
||||
@@ -55,7 +53,7 @@ module.exports = function (privileges) {
|
||||
purge: purge,
|
||||
view_deleted: isAdminOrMod || isOwner,
|
||||
isAdminOrMod: isAdminOrMod,
|
||||
disabled: disabled,
|
||||
disabled: results.disabled,
|
||||
tid: tid,
|
||||
uid: uid,
|
||||
}, next);
|
||||
@@ -146,8 +144,8 @@ module.exports = function (privileges) {
|
||||
},
|
||||
function (results, next) {
|
||||
uids = uids.filter(function (uid, index) {
|
||||
return parseInt(results.disabled, 10) !== 1 &&
|
||||
((results.allowedTo[index] && parseInt(topicData.deleted, 10) !== 1) || results.isAdmins[index] || results.isModerators[index]);
|
||||
return !results.disabled &&
|
||||
((results.allowedTo[index] && !topicData.deleted) || results.isAdmins[index] || results.isModerators[index]);
|
||||
});
|
||||
|
||||
next(null, uids);
|
||||
|
||||
@@ -62,6 +62,7 @@ describe('Categories', function () {
|
||||
assert(categoryData);
|
||||
assert.equal(categoryObj.name, categoryData.name);
|
||||
assert.equal(categoryObj.description, categoryData.description);
|
||||
assert.strictEqual(categoryObj.disabled, 0);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user