fixed to account header

v1.18.x
barisusakli 11 years ago
parent c217834165
commit 76ad2b8fb2

@ -18,10 +18,6 @@ define('forum/account/header', function() {
$this.toggleClass('hide', $this.hasClass('private')); $this.toggleClass('hide', $this.hasClass('private'));
}); });
} }
if (app.isAdmin) {
$('#editLink, #settingsLink').removeClass('hide');
}
} }
function selectActivePill() { function selectActivePill() {

@ -112,6 +112,7 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
userData.yourid = callerUID; userData.yourid = callerUID;
userData.theirid = userData.uid; userData.theirid = userData.uid;
userData.isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10); userData.isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10);
userData.showSettings = userData.isSelf || isAdmin;
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['email:confirmed'] = !!parseInt(userData['email:confirmed'], 10); userData['email:confirmed'] = !!parseInt(userData['email:confirmed'], 10);
userData.profile_links = results.profile_links; userData.profile_links = results.profile_links;
@ -213,7 +214,7 @@ function getFollow(route, name, req, res, next) {
accountsController.getFavourites = function(req, res, next) { accountsController.getFavourites = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0; var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
getBaseUser(req.params.userslug, function(err, userData) { getBaseUser(req.params.userslug, callerUID, function(err, userData) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -231,8 +232,6 @@ accountsController.getFavourites = function(req, res, next) {
return next(err); return next(err);
} }
userData.theirid = userData.uid;
userData.yourid = callerUID;
userData.posts = favourites.posts; userData.posts = favourites.posts;
userData.nextStart = favourites.nextStart; userData.nextStart = favourites.nextStart;
@ -244,7 +243,7 @@ accountsController.getFavourites = function(req, res, next) {
accountsController.getPosts = function(req, res, next) { accountsController.getPosts = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0; var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
getBaseUser(req.params.userslug, function(err, userData) { getBaseUser(req.params.userslug, callerUID, function(err, userData) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -258,8 +257,6 @@ accountsController.getPosts = function(req, res, next) {
return next(err); return next(err);
} }
userData.theirid = userData.uid;
userData.yourid = callerUID;
userData.posts = userPosts.posts; userData.posts = userPosts.posts;
userData.nextStart = userPosts.nextStart; userData.nextStart = userPosts.nextStart;
@ -271,7 +268,7 @@ accountsController.getPosts = function(req, res, next) {
accountsController.getTopics = function(req, res, next) { accountsController.getTopics = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0; var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
getBaseUser(req.params.userslug, function(err, userData) { getBaseUser(req.params.userslug, callerUID, function(err, userData) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -286,8 +283,6 @@ accountsController.getTopics = function(req, res, next) {
return next(err); return next(err);
} }
userData.theirid = userData.uid;
userData.yourid = callerUID;
userData.topics = userTopics.topics; userData.topics = userTopics.topics;
userData.nextStart = userTopics.nextStart; userData.nextStart = userTopics.nextStart;
@ -296,7 +291,7 @@ accountsController.getTopics = function(req, res, next) {
}); });
}; };
function getBaseUser(userslug, callback) { function getBaseUser(userslug, callerUID, callback) {
user.getUidByUserslug(userslug, function (err, uid) { user.getUidByUserslug(userslug, function (err, uid) {
if (err || !uid) { if (err || !uid) {
return callback(err); return callback(err);
@ -306,6 +301,9 @@ function getBaseUser(userslug, callback) {
user: function(next) { user: function(next) {
user.getUserFields(uid, ['uid', 'username', 'userslug'], next); user.getUserFields(uid, ['uid', 'username', 'userslug'], next);
}, },
isAdmin: function(next) {
user.isAdministrator(callerUID, next);
},
profile_links: function(next) { profile_links: function(next) {
plugins.fireHook('filter:user.profileLinks', [], next); plugins.fireHook('filter:user.profileLinks', [], next);
} }
@ -313,9 +311,15 @@ function getBaseUser(userslug, callback) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
if (!results.user) { if (!results.user) {
return callback(); return callback();
} }
results.user.yourid = callerUID;
results.user.theirid = uid;
results.user.isSelf = parseInt(callerUID, 10) === parseInt(uid, 10);
results.user.showSettings = results.user.isSelf || results.isAdmin;
results.user.profile_links = results.profile_links; results.user.profile_links = results.profile_links;
callback(null, results.user); callback(null, results.user);
}); });
@ -337,7 +341,7 @@ accountsController.accountEdit = function(req, res, next) {
accountsController.accountSettings = function(req, res, next) { accountsController.accountSettings = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0; var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
getBaseUser(req.params.userslug, function(err, userData) { getBaseUser(req.params.userslug, callerUID, function(err, userData) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -358,8 +362,6 @@ accountsController.accountSettings = function(req, res, next) {
return next(err); return next(err);
} }
userData.yourid = callerUID;
userData.theirid = userData.uid;
userData.settings = results.settings; userData.settings = results.settings;
userData.languages = results.languages; userData.languages = results.languages;

Loading…
Cancel
Save