Fix `setupTimezone' and `setupInternationalization' for user preferences
This commit is contained in:
parent
8d120762de
commit
533d2207fd
|
@ -7,6 +7,7 @@ namespace Icinga\Application;
|
||||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||||
|
|
||||||
use Icinga\Authentication\Manager as AuthenticationManager;
|
use Icinga\Authentication\Manager as AuthenticationManager;
|
||||||
|
use Icinga\Authentication\Manager;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotReadableError;
|
use Icinga\Exception\NotReadableError;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
|
@ -296,8 +297,12 @@ class Web extends ApplicationBootstrap
|
||||||
*/
|
*/
|
||||||
protected function setupTimezone()
|
protected function setupTimezone()
|
||||||
{
|
{
|
||||||
if ($this->user !== null && $this->user->getPreferences() !== null) {
|
$auth = Manager::getInstance();
|
||||||
$userTimezone = $this->user->getPreferences()->get('app.timezone');
|
|
||||||
|
if ($auth->isAuthenticated() &&
|
||||||
|
($timezone = $auth->getUser()->getPreferences()->getValue('icingaweb', 'timezone')) !== null
|
||||||
|
) {
|
||||||
|
$userTimezone = $timezone;
|
||||||
} else {
|
} else {
|
||||||
$userTimezone = null;
|
$userTimezone = null;
|
||||||
}
|
}
|
||||||
|
@ -323,21 +328,10 @@ class Web extends ApplicationBootstrap
|
||||||
{
|
{
|
||||||
parent::setupInternationalization();
|
parent::setupInternationalization();
|
||||||
|
|
||||||
$locale = Session::getSession()->get('language');
|
$auth = Manager::getInstance();
|
||||||
if ($locale !== null) {
|
|
||||||
try {
|
|
||||||
Translator::setupLocale($locale);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Logger::debug(
|
|
||||||
'Cannot set locale "' . $locale . '" configured in session' .
|
|
||||||
' "' . session_id() . '" (' . $e->getMessage() . ')'
|
|
||||||
);
|
|
||||||
$locale = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($locale === null && $this->user !== null && $this->user->getPreferences() !== null
|
if ($auth->isAuthenticated() &&
|
||||||
&& (($locale = $this->user->getPreferences()->getValue('icingaweb', 'language')) !== null)
|
($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
Translator::setupLocale($locale);
|
Translator::setupLocale($locale);
|
||||||
|
|
Loading…
Reference in New Issue