mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	closes #6308
This commit is contained in:
		| @@ -103,7 +103,7 @@ | |||||||
| 	"topics_per_page": "Topics per Page", | 	"topics_per_page": "Topics per Page", | ||||||
| 	"posts_per_page": "Posts per Page", | 	"posts_per_page": "Posts per Page", | ||||||
| 	"max_items_per_page": "Maximum %1", | 	"max_items_per_page": "Maximum %1", | ||||||
|  | 	"acp_language": "Admin Page Language", | ||||||
| 	"notification_sounds" : "Play a sound when you receive a notification", | 	"notification_sounds" : "Play a sound when you receive a notification", | ||||||
| 	"notifications_and_sounds": "Notifications & Sounds", | 	"notifications_and_sounds": "Notifications & Sounds", | ||||||
| 	"incoming-message-sound": "Incoming message sound", | 	"incoming-message-sound": "Incoming message sound", | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| 'use strict'; | 'use strict'; | ||||||
|  |  | ||||||
| var async = require('async'); | var async = require('async'); | ||||||
|  | var _ = require('lodash'); | ||||||
|  |  | ||||||
| var user = require('../../user'); | var user = require('../../user'); | ||||||
| var languages = require('../../languages'); | var languages = require('../../languages'); | ||||||
| @@ -40,6 +41,9 @@ settingsController.get = function (req, res, callback) { | |||||||
| 		function (results, next) { | 		function (results, next) { | ||||||
| 			userData.settings = results.settings; | 			userData.settings = results.settings; | ||||||
| 			userData.languages = results.languages; | 			userData.languages = results.languages; | ||||||
|  | 			if (userData.isAdmin && userData.isSelf) { | ||||||
|  | 				userData.acpLanguages = _.cloneDeep(results.languages); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			var types = [ | 			var types = [ | ||||||
| 				'notification', | 				'notification', | ||||||
| @@ -135,6 +139,12 @@ settingsController.get = function (req, res, callback) { | |||||||
| 				language.selected = language.code === userData.settings.userLang; | 				language.selected = language.code === userData.settings.userLang; | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
|  | 			if (userData.isAdmin && userData.isSelf) { | ||||||
|  | 				userData.acpLanguages.forEach(function (language) { | ||||||
|  | 					language.selected = language.code === userData.settings.acpLang; | ||||||
|  | 				}); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			var notifFreqOptions = [ | 			var notifFreqOptions = [ | ||||||
| 				'all', | 				'all', | ||||||
| 				'everyTen', | 				'everyTen', | ||||||
|   | |||||||
| @@ -86,6 +86,7 @@ apiController.loadConfig = function (req, callback) { | |||||||
| 			config.topicsPerPage = settings.topicsPerPage; | 			config.topicsPerPage = settings.topicsPerPage; | ||||||
| 			config.postsPerPage = settings.postsPerPage; | 			config.postsPerPage = settings.postsPerPage; | ||||||
| 			config.userLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.userLang || config.defaultLang; | 			config.userLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.userLang || config.defaultLang; | ||||||
|  | 			config.acpLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.acpLang; | ||||||
| 			config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab; | 			config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab; | ||||||
| 			config.topicPostSort = settings.topicPostSort || config.topicPostSort; | 			config.topicPostSort = settings.topicPostSort || config.topicPostSort; | ||||||
| 			config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; | 			config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; | ||||||
|   | |||||||
| @@ -71,12 +71,13 @@ Languages.list = function (callback) { | |||||||
| 				if (err) { | 				if (err) { | ||||||
| 					return next(err); | 					return next(err); | ||||||
| 				} | 				} | ||||||
|  | 				var lang; | ||||||
| 				try { | 				try { | ||||||
| 					var lang = JSON.parse(file); | 					lang = JSON.parse(file); | ||||||
| 					next(null, lang); |  | ||||||
| 				} catch (e) { | 				} catch (e) { | ||||||
| 					next(e); | 					return next(e); | ||||||
| 				} | 				} | ||||||
|  | 				next(null, lang); | ||||||
| 			}); | 			}); | ||||||
| 		}, function (err, languages) { | 		}, function (err, languages) { | ||||||
| 			if (err) { | 			if (err) { | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ module.exports = function (middleware) { | |||||||
| 			plugins: [], | 			plugins: [], | ||||||
| 			authentication: [], | 			authentication: [], | ||||||
| 		}; | 		}; | ||||||
|  | 		res.locals.config = res.locals.config || {}; | ||||||
| 		async.waterfall([ | 		async.waterfall([ | ||||||
| 			function (next) { | 			function (next) { | ||||||
| 				async.parallel({ | 				async.parallel({ | ||||||
| @@ -51,9 +51,6 @@ module.exports = function (middleware) { | |||||||
| 					custom_header: function (next) { | 					custom_header: function (next) { | ||||||
| 						plugins.fireHook('filter:admin.header.build', custom_header, next); | 						plugins.fireHook('filter:admin.header.build', custom_header, next); | ||||||
| 					}, | 					}, | ||||||
| 					config: function (next) { |  | ||||||
| 						controllers.api.getConfig(req, res, next); |  | ||||||
| 					}, |  | ||||||
| 					configs: function (next) { | 					configs: function (next) { | ||||||
| 						meta.configs.list(next); | 						meta.configs.list(next); | ||||||
| 					}, | 					}, | ||||||
| @@ -64,8 +61,6 @@ module.exports = function (middleware) { | |||||||
| 				userData.uid = req.uid; | 				userData.uid = req.uid; | ||||||
| 				userData['email:confirmed'] = parseInt(userData['email:confirmed'], 10) === 1; | 				userData['email:confirmed'] = parseInt(userData['email:confirmed'], 10) === 1; | ||||||
|  |  | ||||||
| 				res.locals.config = results.config; |  | ||||||
|  |  | ||||||
| 				var acpPath = req.path.slice(1).split('/'); | 				var acpPath = req.path.slice(1).split('/'); | ||||||
| 				acpPath.forEach(function (path, i) { | 				acpPath.forEach(function (path, i) { | ||||||
| 					acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1); | 					acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1); | ||||||
| @@ -73,9 +68,9 @@ module.exports = function (middleware) { | |||||||
| 				acpPath = acpPath.join(' > '); | 				acpPath = acpPath.join(' > '); | ||||||
|  |  | ||||||
| 				var templateValues = { | 				var templateValues = { | ||||||
| 					config: results.config, | 					config: res.locals.config, | ||||||
| 					configJSON: jsesc(JSON.stringify(results.config), { isScriptContext: true }), | 					configJSON: jsesc(JSON.stringify(res.locals.config), { isScriptContext: true }), | ||||||
| 					relative_path: results.config.relative_path, | 					relative_path: res.locals.config.relative_path, | ||||||
| 					adminConfigJSON: encodeURIComponent(JSON.stringify(results.configs)), | 					adminConfigJSON: encodeURIComponent(JSON.stringify(results.configs)), | ||||||
| 					user: userData, | 					user: userData, | ||||||
| 					userJSON: jsesc(JSON.stringify(userData), { isScriptContext: true }), | 					userJSON: jsesc(JSON.stringify(userData), { isScriptContext: true }), | ||||||
|   | |||||||
| @@ -120,6 +120,9 @@ module.exports = function (middleware) { | |||||||
|  |  | ||||||
| 	function translate(str, req, res, next) { | 	function translate(str, req, res, next) { | ||||||
| 		var language = (res.locals.config && res.locals.config.userLang) || 'en-GB'; | 		var language = (res.locals.config && res.locals.config.userLang) || 'en-GB'; | ||||||
|  | 		if (res.locals.renderAdminHeader) { | ||||||
|  | 			language = (res.locals.config && res.locals.config.acpLang) || 'en-GB'; | ||||||
|  | 		} | ||||||
| 		language = req.query.lang ? validator.escape(String(req.query.lang)) : language; | 		language = req.query.lang ? validator.escape(String(req.query.lang)) : language; | ||||||
| 		translator.translate(str, language, function (translated) { | 		translator.translate(str, language, function (translated) { | ||||||
| 			next(null, translator.unescape(translated)); | 			next(null, translator.unescape(translated)); | ||||||
|   | |||||||
| @@ -70,6 +70,7 @@ module.exports = function (User) { | |||||||
| 				settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : defaultTopicsPerPage, defaultTopicsPerPage); | 				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.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : defaultPostsPerPage, defaultPostsPerPage); | ||||||
| 				settings.userLang = settings.userLang || meta.config.defaultLang || 'en-GB'; | 				settings.userLang = settings.userLang || meta.config.defaultLang || 'en-GB'; | ||||||
|  | 				settings.acpLang = settings.acpLang || settings.userLang; | ||||||
| 				settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest'); | 				settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest'); | ||||||
| 				settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest'); | 				settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest'); | ||||||
| 				settings.followTopicsOnCreate = parseInt(getSetting(settings, 'followTopicsOnCreate', 1), 10) === 1; | 				settings.followTopicsOnCreate = parseInt(getSetting(settings, 'followTopicsOnCreate', 1), 10) === 1; | ||||||
| @@ -118,6 +119,7 @@ module.exports = function (User) { | |||||||
| 			topicsPerPage: Math.min(data.topicsPerPage, parseInt(maxTopicsPerPage, 10) || 20), | 			topicsPerPage: Math.min(data.topicsPerPage, parseInt(maxTopicsPerPage, 10) || 20), | ||||||
| 			postsPerPage: Math.min(data.postsPerPage, parseInt(maxPostsPerPage, 10) || 20), | 			postsPerPage: Math.min(data.postsPerPage, parseInt(maxPostsPerPage, 10) || 20), | ||||||
| 			userLang: data.userLang || meta.config.defaultLang, | 			userLang: data.userLang || meta.config.defaultLang, | ||||||
|  | 			acpLang: data.acpLang || meta.config.defaultLang, | ||||||
| 			followTopicsOnCreate: data.followTopicsOnCreate, | 			followTopicsOnCreate: data.followTopicsOnCreate, | ||||||
| 			followTopicsOnReply: data.followTopicsOnReply, | 			followTopicsOnReply: data.followTopicsOnReply, | ||||||
| 			restrictChat: data.restrictChat, | 			restrictChat: data.restrictChat, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user