From a4d7022e687bcad5039c922d9ac26f8bc72c2c56 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 11 Sep 2015 12:51:10 -0400 Subject: [PATCH] closes #2958 --- src/user/settings.js | 29 +++++++++------ src/views/admin/settings/user.tpl | 60 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/src/user/settings.js b/src/user/settings.js index 5af9f567c1..03922ade45 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -60,27 +60,36 @@ module.exports = function(User) { settings.showemail = parseInt(settings.showemail, 10) === 1; settings.showfullname = parseInt(settings.showfullname, 10) === 1; - settings.openOutgoingLinksInNewTab = parseInt(settings.openOutgoingLinksInNewTab, 10) === 1; - settings.dailyDigestFreq = settings.dailyDigestFreq || 'off'; - settings.usePagination = (settings.usePagination === null || settings.usePagination === undefined) ? parseInt(meta.config.usePagination, 10) === 1 : parseInt(settings.usePagination, 10) === 1; + settings.openOutgoingLinksInNewTab = parseInt(getSetting(settings, 'openOutgoingLinksInNewTab', 0), 10) === 1; + settings.dailyDigestFreq = getSetting(settings, 'dailyDigestFreq', 'off'); + settings.usePagination = parseInt(getSetting(settings, 'usePagination', 0), 10) === 1; settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : defaultTopicsPerPage, defaultTopicsPerPage); settings.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : defaultPostsPerPage, defaultPostsPerPage); settings.notificationSounds = parseInt(settings.notificationSounds, 10) === 1; settings.userLang = settings.userLang || meta.config.defaultLang || 'en_GB'; - settings.topicPostSort = settings.topicPostSort || meta.config.topicPostSort || 'oldest_to_newest'; - settings.categoryTopicSort = settings.categoryTopicSort || meta.config.categoryTopicSort || 'newest_to_oldest'; - settings.followTopicsOnCreate = (settings.followTopicsOnCreate === null || settings.followTopicsOnCreate === undefined) ? true : parseInt(settings.followTopicsOnCreate, 10) === 1; - settings.followTopicsOnReply = parseInt(settings.followTopicsOnReply, 10) === 1; - settings.sendChatNotifications = parseInt(settings.sendChatNotifications, 10) === 1; - settings.sendPostNotifications = parseInt(settings.sendPostNotifications, 10) === 1; + settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest'); + settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest'); + settings.followTopicsOnCreate = parseInt(getSetting(settings, 'followTopicsOnCreate', 1), 10) === 1; + settings.followTopicsOnReply = parseInt(getSetting(settings, 'followTopicsOnReply', 0), 10) === 1; + settings.sendChatNotifications = parseInt(getSetting(settings, 'sendChatNotifications', 0), 10) === 1; + settings.sendPostNotifications = parseInt(getSetting(settings, 'sendPostNotifications', 0), 10) === 1; settings.restrictChat = parseInt(settings.restrictChat, 10) === 1; - settings.topicSearchEnabled = parseInt(settings.topicSearchEnabled, 10) === 1; + settings.topicSearchEnabled = parseInt(getSetting(settings, 'topicSearchEnabled', 0), 10) === 1; settings.bootswatchSkin = settings.bootswatchSkin || 'default'; callback(null, settings); }); } + function getSetting(settings, key, base) { + if (settings[key] || settings[key] === 0) { + return settings[key]; + } else if (meta.config[key] || meta.config[key] === 0) { + return meta.config[key]; + } + return base; + } + User.saveSettings = function(uid, data, callback) { if (invalidPaginationSettings(data)) { return callback(new Error('[[error:invalid-pagination-value]]')); diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index b0bec269e3..5468a07b5d 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -195,4 +195,64 @@ +
+
Default User Settings
+
+
+
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ \ No newline at end of file