mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
added parseInt
This commit is contained in:
@@ -32,7 +32,7 @@ define(['uploader'], function(uploader) {
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
fields[x].checked = app.config[key] === '1' ? true : false;
|
||||
fields[x].checked = parseInt(app.config[key], 10) === 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@
|
||||
};
|
||||
|
||||
data.setName = key;
|
||||
module.setObject(key+':'+value, data, callback);
|
||||
module.setObject(key + ':' + value, data, callback);
|
||||
}
|
||||
|
||||
module.sortedSetRemove = function(key, value, callback) {
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
}
|
||||
|
||||
async.each(topicData.posts, function(postData, next) {
|
||||
if (postData.deleted === '0') {
|
||||
dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();
|
||||
if (parseInt(postData.deleted, 10) === 0) {
|
||||
dateStamp = new Date(parseInt(parseInt(postData.edited, 10) === 0 ? postData.timestamp : postData.edited, 10)).toUTCString();
|
||||
|
||||
feed.item({
|
||||
title: 'Reply to ' + topicData.topic_name + ' on ' + dateStamp,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
}, function (err, groups) {
|
||||
// Remove deleted and hidden groups from this list
|
||||
callback(err, groups.filter(function (group) {
|
||||
if (group.deleted === '1' || group.hidden === '1') {
|
||||
if (parseInt(group.deleted, 10) === 1 || parseInt(group.hidden, 10) === 1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
Groups.isDeleted = function(gid, callback) {
|
||||
db.getObjectField('gid:' + gid, 'deleted', function(err, deleted) {
|
||||
callback(err, deleted === '1');
|
||||
callback(err, parseInt(deleted, 10) === 1);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -240,7 +240,7 @@
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (groupObj.deleted === '1') {
|
||||
if (parseInt(groupObj.deleted, 10) === 1) {
|
||||
|
||||
db.deleteObjectField('group:gid', groupObj.name, function(err) {
|
||||
db.delete('gid:' + gid, function(err) {
|
||||
|
||||
@@ -28,7 +28,7 @@ var user = require('./user'),
|
||||
user.getUserFields(uid, ['password', 'banned'], function(err, userData) {
|
||||
if (err) return next(err);
|
||||
|
||||
if (userData.banned && userData.banned === '1') {
|
||||
if (userData.banned && parseInt(userData.banned, 10) === 1) {
|
||||
return next({
|
||||
status: "error",
|
||||
message: "user-banned"
|
||||
|
||||
@@ -164,7 +164,7 @@ var db = require('./database'),
|
||||
};
|
||||
|
||||
posts.getPostField(pid, 'deleted', function(err, deleted) {
|
||||
if(deleted === '1') {
|
||||
if(parseInt(deleted, 10) === 1) {
|
||||
return callback(new Error('Post already deleted!'));
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ var db = require('./database'),
|
||||
|
||||
// Restore topic if it is the only post
|
||||
topics.getTopicField(postData.tid, 'postcount', function(err, count) {
|
||||
if (count === '1') {
|
||||
if (parseInt(count, 10) === 1) {
|
||||
threadTools.restore(postData.tid, uid);
|
||||
}
|
||||
});
|
||||
@@ -210,7 +210,7 @@ var db = require('./database'),
|
||||
};
|
||||
|
||||
posts.getPostField(pid, 'deleted', function(err, deleted) {
|
||||
if(deleted === '0') {
|
||||
if(parseInt(deleted, 10) === 0) {
|
||||
return callback(new Error('Post already restored'));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ var db = require('./database'),
|
||||
|
||||
db.sortedSetAdd('categories:recent_posts:cid:' + cid, timestamp, pid);
|
||||
|
||||
if(topicData.pinned === '0') {
|
||||
if(parseInt(topicData.pinned, 10) === 0) {
|
||||
db.sortedSetAdd('categories:' + cid + ':tid', timestamp, tid);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ var db = require('./database'),
|
||||
post.userslug = userData.userslug || '';
|
||||
post.user_rep = userData.reputation || 0;
|
||||
post.user_postcount = userData.postcount || 0;
|
||||
post.user_banned = userData.banned === '1';
|
||||
post.user_banned = parseInt(userData.banned, 10) === 1;
|
||||
post.picture = userData.picture || require('gravatar').url('', {}, https = nconf.get('https'));
|
||||
post.signature = signature;
|
||||
|
||||
@@ -250,7 +250,7 @@ var db = require('./database'),
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(err, postData) {
|
||||
if (postData.deleted === '1') {
|
||||
if (parseInt(postData.deleted, 10) === 1) {
|
||||
return callback(null);
|
||||
} else {
|
||||
postData.relativeTime = new Date(parseInt(postData.timestamp || 0, 10)).toISOString();
|
||||
@@ -267,7 +267,7 @@ var db = require('./database'),
|
||||
topics.getTopicFields(postData.tid, ['title', 'cid', 'slug', 'deleted'], function(err, topicData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else if (topicData.deleted === '1') {
|
||||
} else if (parseInt(topicData.deleted, 10) === 1) {
|
||||
return callback(null);
|
||||
}
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'icon', 'slug'], function(err, categoryData) {
|
||||
|
||||
@@ -241,7 +241,7 @@ var nconf = require('nconf'),
|
||||
app.get('/categories/active', function (req, res) {
|
||||
categories.getAllCategories(0, function (err, data) {
|
||||
data.categories = data.categories.filter(function (category) {
|
||||
return (!category.disabled || category.disabled === "0");
|
||||
return (!category.disabled || parseInt(category.disabled, 10) === 0);
|
||||
});
|
||||
res.json(data);
|
||||
});
|
||||
@@ -250,7 +250,7 @@ var nconf = require('nconf'),
|
||||
app.get('/categories/disabled', function (req, res) {
|
||||
categories.getAllCategories(0, function (err, data) {
|
||||
data.categories = data.categories.filter(function (category) {
|
||||
return category.disabled === "1";
|
||||
return parseInt(category.disabled, 10) === 1;
|
||||
});
|
||||
res.json(data);
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ var path = require('path'),
|
||||
var uid = (req.user) ? req.user.uid : 0;
|
||||
categories.getAllCategories(uid, function (err, data) {
|
||||
data.categories = data.categories.filter(function (category) {
|
||||
return (!category.disabled || category.disabled === "0");
|
||||
return (!category.disabled || parseInt(category.disabled, 10) === 0);
|
||||
});
|
||||
|
||||
function iterator(category, callback) {
|
||||
@@ -54,7 +54,7 @@ var path = require('path'),
|
||||
}
|
||||
|
||||
async.each(data.categories, iterator, function (err) {
|
||||
data.motd_class = (meta.config.show_motd === '1' || meta.config.show_motd === undefined) ? '' : ' none';
|
||||
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
|
||||
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
|
||||
|
||||
data.motd = require('marked')(meta.config.motd || "<div class=\"pull-right btn-group\"><a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-default btn-lg\"><i class=\"fa fa-comment\"></i><span class='hidden-mobile'> Get NodeBB</span></a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-default btn-lg\"><i class=\"fa fa-github\"></i><span class='hidden-mobile'> Fork us on Github</span></a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-default btn-lg\"><i class=\"fa fa-twitter\"></i><span class='hidden-mobile'> @dcplabs</span></a></div>\n\n# NodeBB <span>v" + pkg.version + "</span>\nWelcome to NodeBB, the discussion platform of the future.");
|
||||
@@ -117,7 +117,7 @@ var path = require('path'),
|
||||
var uid = (req.user) ? req.user.uid : 0;
|
||||
topics.getTopicWithPosts(req.params.id, uid, 0, 10, function (err, data) {
|
||||
if (!err) {
|
||||
if (data.deleted === '1' && data.expose_tools === 0) {
|
||||
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
||||
return res.json(404, {});
|
||||
}
|
||||
res.json(data);
|
||||
@@ -132,10 +132,11 @@ var path = require('path'),
|
||||
categoryTools.privileges(req.params.id, uid, function(err, privileges) {
|
||||
if (!err && privileges.read) {
|
||||
categories.getCategoryById(req.params.id, uid, function (err, data) {
|
||||
if (!err && data && data.disabled === "0")
|
||||
if (!err && data && parseInt(data.disabled, 10) === 0) {
|
||||
res.json(data);
|
||||
else
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}, req.params.id, uid);
|
||||
} else {
|
||||
res.send(403);
|
||||
|
||||
@@ -318,10 +318,11 @@ var fs = require('fs'),
|
||||
return next(err);
|
||||
|
||||
if (userData) {
|
||||
if (userData.showemail && userData.showemail === "1")
|
||||
if (userData.showemail && parseInt(userData.showemail, 10) === 1) {
|
||||
userData.showemail = "checked";
|
||||
else
|
||||
} else {
|
||||
userData.showemail = "";
|
||||
}
|
||||
res.json(userData);
|
||||
} else {
|
||||
res.json(404, {
|
||||
@@ -501,21 +502,21 @@ var fs = require('fs'),
|
||||
}
|
||||
|
||||
function canSeeEmail() {
|
||||
return callerUID == uid || (data.email && (data.showemail && data.showemail === "1"));
|
||||
return callerUID == uid || (data.email && (data.showemail && parseInt(data.showemail, 10) === 1));
|
||||
}
|
||||
|
||||
if (!canSeeEmail()) {
|
||||
data.email = "";
|
||||
}
|
||||
|
||||
if (callerUID == uid && (!data.showemail || data.showemail === "0")) {
|
||||
if (callerUID == uid && (!data.showemail || parseInt(data.showemail, 10) === 0)) {
|
||||
data.emailClass = "";
|
||||
} else {
|
||||
data.emailClass = "hide";
|
||||
}
|
||||
|
||||
data.websiteName = data.website.replace('http://', '').replace('https://', '');
|
||||
data.banned = data.banned === '1';
|
||||
data.banned = parseInt(data.banned, 10) === 1;
|
||||
data.uid = uid;
|
||||
data.yourid = callerUID;
|
||||
data.theirid = uid;
|
||||
|
||||
@@ -292,7 +292,7 @@ var db = require('./database'),
|
||||
pids.reverse();
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
posts.getPostField(pid, 'deleted', function(err, deleted) {
|
||||
if (deleted === '0') {
|
||||
if (parseInt(deleted, 10) === 0) {
|
||||
next(true);
|
||||
} else {
|
||||
next(false);
|
||||
|
||||
@@ -170,7 +170,7 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
postData = postData.filter(function(post) {
|
||||
return parseInt(current_user, 10) !== 0 || post.deleted === "0";
|
||||
return parseInt(current_user, 10) !== 0 || parseInt(post.deleted, 10) === 0;
|
||||
});
|
||||
|
||||
function getFavouritesData(next) {
|
||||
@@ -454,18 +454,18 @@ var async = require('async'),
|
||||
|
||||
getTopicInfo(topicData, function(topicInfo) {
|
||||
|
||||
topicData['pin-icon'] = topicData.pinned === '1' ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = topicData.locked === '1' ? 'fa-lock' : 'none';
|
||||
topicData['deleted-class'] = topicData.deleted === '1' ? 'deleted' : '';
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
topicData['deleted-class'] = parseInt(topicData.deleted, 10) === 1 ? 'deleted' : '';
|
||||
|
||||
topicData.unreplied = topicData.postcount === '1';
|
||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||
topicData.username = topicInfo.username || 'anonymous';
|
||||
topicData.userslug = topicInfo.userslug || '';
|
||||
topicData.picture = topicInfo.picture || gravatar.url('', {}, https = nconf.get('https'));
|
||||
topicData.categoryIcon = topicInfo.categoryData.icon;
|
||||
topicData.categoryName = topicInfo.categoryData.name;
|
||||
topicData.categorySlug = topicInfo.categoryData.slug;
|
||||
topicData.badgeclass = (topicInfo.hasread && current_user != 0) ? '' : 'badge-important';
|
||||
topicData.badgeclass = (topicInfo.hasread && parseInt(current_user, 10) !== 0) ? '' : 'badge-important';
|
||||
topicData.teaser_text = topicInfo.teaserInfo.text || '',
|
||||
topicData.teaser_username = topicInfo.teaserInfo.username || '';
|
||||
topicData.teaser_userslug = topicInfo.teaserInfo.userslug || '';
|
||||
@@ -555,7 +555,7 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
function getReadStatus(next) {
|
||||
if (uid && parseInt(uid) > 0) {
|
||||
if (uid && parseInt(uid, 10) > 0) {
|
||||
Topics.hasReadTopic(tid, uid, function(read) {
|
||||
next(null, read);
|
||||
});
|
||||
@@ -580,8 +580,8 @@ var async = require('async'),
|
||||
hasRead = results[1],
|
||||
teaser = results[2];
|
||||
|
||||
topicData['pin-icon'] = topicData.pinned === '1' ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = topicData.locked === '1' ? 'fa-lock' : 'none';
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
|
||||
topicData.badgeclass = hasRead ? '' : 'badge-important';
|
||||
topicData.teaser_text = teaser.text || '';
|
||||
@@ -808,7 +808,7 @@ var async = require('async'),
|
||||
if(err) {
|
||||
return callback(err, null);
|
||||
}
|
||||
callback(null, locked === "1");
|
||||
callback(null, parseInt(locked, 10) === 1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -182,12 +182,6 @@ var bcrypt = require('bcrypt'),
|
||||
});
|
||||
};
|
||||
|
||||
User.filterBannedUsers = function(users) {
|
||||
return users.filter(function(user) {
|
||||
return (!user.banned || user.banned === '0');
|
||||
});
|
||||
};
|
||||
|
||||
User.updateProfile = function(uid, data, callback) {
|
||||
|
||||
var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature'];
|
||||
@@ -550,7 +544,7 @@ var bcrypt = require('bcrypt'),
|
||||
}
|
||||
|
||||
function iterator(uid, callback) {
|
||||
if(uid === "0") {
|
||||
if(parseInt(uid, 10) === 0) {
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ var path = require('path'),
|
||||
function (next) {
|
||||
topics.getTopicWithPosts(tid, ((req.user) ? req.user.uid : 0), 0, -1, function (err, topicData) {
|
||||
if (topicData) {
|
||||
if (topicData.deleted === '1' && topicData.expose_tools === 0) {
|
||||
if (parseInt(topicData.deleted, 10) === 1 && parseInt(topicData.expose_tools, 10) === 0) {
|
||||
return next(new Error('Topic deleted'), null);
|
||||
}
|
||||
}
|
||||
@@ -587,7 +587,7 @@ var path = require('path'),
|
||||
categories.getCategoryById(cid, 0, function (err, categoryData) {
|
||||
|
||||
if (categoryData) {
|
||||
if (categoryData.disabled === '1') {
|
||||
if (parseInt(categoryData.disabled, 10) === 1) {
|
||||
return next(new Error('Category disabled'), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ websockets.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:topics.post', function(data) {
|
||||
if (uid < 1 && meta.config.allowGuestPosting === '0') {
|
||||
if (uid < 1 && parseInt(meta.config.allowGuestPosting, 10) === 0) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Post Unsuccessful',
|
||||
message: 'You don't seem to be logged in, so you cannot reply.',
|
||||
@@ -420,7 +420,7 @@ websockets.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:posts.reply', function(data) {
|
||||
if (uid < 1 && meta.config.allowGuestPosting === '0') {
|
||||
if (uid < 1 && parseInt(meta.config.allowGuestPosting, 10) === 0) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Reply Unsuccessful',
|
||||
message: 'You don't seem to be logged in, so you cannot reply.',
|
||||
@@ -772,7 +772,7 @@ websockets.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:composer.push', function(data) {
|
||||
if (uid > 0 || meta.config.allowGuestPosting === '1') {
|
||||
if (parseInt(uid, 10) > 0 || parseInt(meta.config.allowGuestPosting, 10) === 1) {
|
||||
if (parseInt(data.tid) > 0) {
|
||||
topics.getTopicData(data.tid, function(err, topicData) {
|
||||
if (data.body)
|
||||
|
||||
Reference in New Issue
Block a user