removed showemail setting from user hash, its in user settings now

v1.18.x
Baris Soner Usakli 11 years ago
parent 3be0ad5bce
commit 020a70ecb6

@ -607,76 +607,76 @@ var fs = require('fs'),
}
function getUserDataByUserSlug(userslug, callerUID, callback) {
var userData;
async.waterfall([
function(next) {
user.getUidByUserslug(userslug, next);
},
function(uid, next) {
if (!uid) {
return next(new Error('invalid-user'));
}
user.getUserData(uid, next);
},
function(data, next) {
userData = data;
if (!userData) {
return callback(new Error('invalid-user'));
user.getUidByUserslug(userslug, function(err, uid) {
if(err || !uid) {
return callback(err || new Error('invalid-user'));
}
async.parallel({
userData : function(next) {
user.getUserData(uid, next);
},
userSettings : function(next) {
user.getSettings(uid, next);
},
isAdmin : function(next) {
user.isAdministrator(callerUID, next);
},
followStats: function(next) {
user.getFollowStats(uid, next);
}
}, function(err, results) {
if(err || !results.userData) {
return callback(err || new Error('invalid-user'));
}
user.isAdministrator(callerUID, next);
}
], function(err, isAdmin) {
if(err) {
return callback(err);
}
var userData = results.userData;
var userSettings = results.userSettings;
var isAdmin = results.isAdmin;
userData.joindate = utils.toISOString(userData.joindate);
if(userData.lastonline) {
userData.lastonline = utils.toISOString(userData.lastonline);
} else {
userData.lastonline = userData.joindate;
}
userData.joindate = utils.toISOString(userData.joindate);
if(userData.lastonline) {
userData.lastonline = utils.toISOString(userData.lastonline);
} else {
userData.lastonline = userData.joindate;
}
if (!userData.birthday) {
userData.age = '';
} else {
userData.age = Math.floor((new Date().getTime() - new Date(userData.birthday).getTime()) / 31536000000);
}
if (!userData.birthday) {
userData.age = '';
} else {
userData.age = Math.floor((new Date().getTime() - new Date(userData.birthday).getTime()) / 31536000000);
}
function canSeeEmail() {
return isAdmin || callerUID == userData.uid || (userData.email && (userData.showemail && parseInt(userData.showemail, 10) === 1));
}
function canSeeEmail() {
return isAdmin || callerUID == userData.uid || (userData.email && userSettings.showemail);
}
if (!canSeeEmail()) {
userData.email = "";
}
if (!canSeeEmail()) {
userData.email = "";
}
if (callerUID == userData.uid && (!userData.showemail || parseInt(userData.showemail, 10) === 0)) {
userData.emailClass = "";
} else {
userData.emailClass = "hide";
}
if (callerUID == userData.uid && !userSettings.showemail) {
userData.emailClass = "";
} else {
userData.emailClass = "hide";
}
userData.websiteName = userData.website.replace('http://', '').replace('https://', '');
userData.banned = parseInt(userData.banned, 10) === 1;
userData.uid = userData.uid;
userData.yourid = callerUID;
userData.theirid = userData.uid;
userData.websiteName = userData.website.replace('http://', '').replace('https://', '');
userData.banned = parseInt(userData.banned, 10) === 1;
userData.uid = userData.uid;
userData.yourid = callerUID;
userData.theirid = userData.uid;
userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1;
userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1;
userData.followingCount = results.followStats.followingCount;
userData.followerCount = results.followStats.followerCount;
user.getFollowStats(userData.uid, function (err, followStats) {
if(err) {
return callback(err);
}
userData.followingCount = followStats.followingCount;
userData.followerCount = followStats.followerCount;
callback(null, userData);
});
});
}
};

@ -104,8 +104,7 @@ var bcrypt = require('bcryptjs'),
'postcount': 0,
'lastposttime': 0,
'banned': 0,
'status': 'online',
'showemail': 0
'status': 'online'
};
db.setObject('user:' + uid, userData, function(err) {
@ -213,7 +212,7 @@ var bcrypt = require('bcryptjs'),
settings = {}
}
settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0;
settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : false;
settings.usePagination = settings.usePagination ? parseInt(settings.usePagination, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0;
settings.topicsPerPage = settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20;
settings.postsPerPage = settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : parseInt(meta.config.postsPerPage, 10) || 10;

Loading…
Cancel
Save