mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 08:17:57 +02:00
closes #2958
This commit is contained in:
@@ -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]]'));
|
||||
|
||||
@@ -195,4 +195,64 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-2 col-xs-12 settings-header">Default User Settings</div>
|
||||
<div class="col-sm-10 col-xs-12">
|
||||
<form>
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="openOutgoingLinksInNewTab">
|
||||
<span class="mdl-switch__label"><strong>[[user:open_links_in_new_tab]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="topicSearchEnabled">
|
||||
<span class="mdl-switch__label"><strong>[[user:enable_topic_searching]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>[[user:digest_label]]</label>
|
||||
<select class="form-control" data-field="dailyDigestFreq">
|
||||
<option value="off">Off</option>
|
||||
<option value="day">Daily</option>
|
||||
<option value="week">Weekly</option>
|
||||
<option value="month">Monthly</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="sendChatNotifications">
|
||||
<span class="mdl-switch__label"><strong>[[user:send_chat_notifications]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="sendPostNotifications">
|
||||
<span class="mdl-switch__label"><strong>[[user:send_post_notifications]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="followTopicsOnCreate">
|
||||
<span class="mdl-switch__label"><strong>[[user:follow_topics_you_create]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="followTopicsOnReply">
|
||||
<span class="mdl-switch__label"><strong>[[user:follow_topics_you_reply_to]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IMPORT admin/settings/footer.tpl -->
|
||||
Reference in New Issue
Block a user