Fix userhomepage derps

v1.18.x
yariplus 9 years ago
parent 853aa37cd2
commit f815f2d981

@ -107,6 +107,11 @@
"select-skin": "Select a Skin",
"select-homepage": "Select a Custom Homepage",
"homepage": "Homepage",
"homepage_description": "Select a page to use as the forum homepage or 'None' to use the default homepage.",
"custom_route": "Custom Homepage Route",
"sso.title": "Single Sign-on Services",
"sso.associated": "Associated with",
"sso.not-associated": "Click here to associate with"

@ -7,6 +7,9 @@ var async = require('async'),
languages = require('../../languages'),
meta = require('../../meta'),
plugins = require('../../plugins'),
privileges = require('../../privileges'),
categories = require('../../categories'),
db = require('../../database'),
helpers = require('../helpers'),
accountHelpers = require('./helpers');
@ -34,6 +37,52 @@ settingsController.get = function(req, res, callback) {
},
languages: function(next) {
languages.list(next);
},
homePageRoutes: function(next) {
async.waterfall([
function(next) {
db.getSortedSetRange('cid:0:children', 0, -1, next);
},
function(cids, next) {
privileges.categories.filterCids('find', cids, 0, next);
},
function(cids, next) {
categories.getMultipleCategoryFields(cids, ['name', 'slug'], next);
},
function(categoryData, next) {
categoryData = categoryData.map(function(category) {
return {
route: 'category/' + category.slug,
name: 'Category: ' + category.name
};
});
next(null, categoryData);
}
], function(err, categoryData) {
if (err || !categoryData) categoryData = [];
plugins.fireHook('filter:homepage.get', {routes: [
{
route: 'categories',
name: 'Categories'
},
{
route: 'recent',
name: 'Recent'
},
{
route: 'popular',
name: 'Popular'
}
].concat(categoryData)}, function(err, data) {
data.routes.push({
route: 'custom',
name: 'Custom'
});
next(null, data.routes);
});
});
}
}, next);
},
@ -41,6 +90,7 @@ settingsController.get = function(req, res, callback) {
userData.settings = results.settings;
userData.languages = results.languages;
userData.userGroups = results.userGroups[0];
userData.homePageRoutes = results.homePageRoutes;
plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next);
},
function(data, next) {
@ -95,6 +145,8 @@ settingsController.get = function(req, res, callback) {
userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1;
userData.allowUserHomePage = parseInt(meta.config.allowUserHomePage, 10) === 1;
userData.title = '[[pages:account/settings]]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]);

@ -36,7 +36,7 @@ Controllers.home = function(req, res, next) {
var route = meta.config.homePageRoute || meta.config.homePageCustom || 'categories';
user.getSettings(req.uid, function(err, settings) {
if (!err) route = settings.homePageRoute || route;
if (!err && settings.homePageRoute !== 'undefined' && settings.homePageRoute !== 'none') route = settings.homePageRoute || route;
var hook = 'action:homepage.get:' + route;

Loading…
Cancel
Save