Skip to content

Commit

Permalink
Fix setupTimezone' and setupInternationalization' for user preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Fuhr committed Nov 12, 2014
1 parent 8d12076 commit 533d220
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions library/Icinga/Application/Web.php
Expand Up @@ -7,6 +7,7 @@
require_once __DIR__ . '/ApplicationBootstrap.php';

use Icinga\Authentication\Manager as AuthenticationManager;
use Icinga\Authentication\Manager;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError;
use Icinga\Application\Logger;
Expand Down Expand Up @@ -296,8 +297,12 @@ private function setupPagination()
*/
protected function setupTimezone()
{
if ($this->user !== null && $this->user->getPreferences() !== null) {
$userTimezone = $this->user->getPreferences()->get('app.timezone');
$auth = Manager::getInstance();

if ($auth->isAuthenticated() &&
($timezone = $auth->getUser()->getPreferences()->getValue('icingaweb', 'timezone')) !== null
) {
$userTimezone = $timezone;
} else {
$userTimezone = null;
}
Expand All @@ -323,21 +328,10 @@ protected function setupInternationalization()
{
parent::setupInternationalization();

$locale = Session::getSession()->get('language');
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;
}
}
$auth = Manager::getInstance();

if ($locale === null && $this->user !== null && $this->user->getPreferences() !== null
&& (($locale = $this->user->getPreferences()->getValue('icingaweb', 'language')) !== null)
if ($auth->isAuthenticated() &&
($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null
) {
try {
Translator::setupLocale($locale);
Expand Down

0 comments on commit 533d220

Please sign in to comment.