|
|
|
@ -375,18 +375,19 @@ accountsController.accountEdit = function(req, res, next) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
accountsController.accountSettings = function(req, res, next) {
|
|
|
|
|
accountsController.getBaseUser(req.params.userslug, req.uid, function(err, userData) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var userData;
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
accountsController.getBaseUser(req.params.userslug, req.uid, next);
|
|
|
|
|
},
|
|
|
|
|
function(_userData, next) {
|
|
|
|
|
userData = _userData;
|
|
|
|
|
if (!userData) {
|
|
|
|
|
return helpers.notFound(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
settings: function(next) {
|
|
|
|
|
plugins.fireHook('filter:user.settings', [], next);
|
|
|
|
|
user.getSettings(userData.uid, next);
|
|
|
|
|
},
|
|
|
|
|
userGroups: function(next) {
|
|
|
|
|
groups.getUserGroups([userData.uid], next);
|
|
|
|
@ -394,19 +395,39 @@ accountsController.accountSettings = function(req, res, next) {
|
|
|
|
|
languages: function(next) {
|
|
|
|
|
languages.list(next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function(results, next) {
|
|
|
|
|
userData.languages = results.languages;
|
|
|
|
|
userData.userGroups = results.userGroups[0];
|
|
|
|
|
plugins.fireHook('filter:user.settings', {settings: results.settings, uid: req.uid}, next);
|
|
|
|
|
},
|
|
|
|
|
function(data, next) {
|
|
|
|
|
userData.settings = data.settings;
|
|
|
|
|
userData.disableEmailSubscriptions = parseInt(meta.config.disableEmailSubscriptions, 10) === 1;
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
], function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userData.settings = results.settings;
|
|
|
|
|
userData.languages = results.languages;
|
|
|
|
|
userData.userGroups = results.userGroups[0];
|
|
|
|
|
userData.dailyDigestFreqOptions = [
|
|
|
|
|
{value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq},
|
|
|
|
|
{value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq},
|
|
|
|
|
{value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq},
|
|
|
|
|
{value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
userData.disableEmailSubscriptions = parseInt(meta.config.disableEmailSubscriptions, 10) === 1;
|
|
|
|
|
userData.userGroups.forEach(function(group) {
|
|
|
|
|
group.selected = group.name === userData.settings.groupTitle;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
res.render('account/settings', userData);
|
|
|
|
|
userData.languages.forEach(function(language) {
|
|
|
|
|
language.selected = language.code === userData.settings.language;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
res.render('account/settings', userData);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|