Fix Undefined index: HTTP_ACCEPT_LANGUAGE

fixes #8370
This commit is contained in:
Eric Lippmann 2015-03-11 20:50:05 +01:00
parent ba0154ab79
commit d102a61e22
1 changed files with 7 additions and 5 deletions

View File

@ -314,14 +314,16 @@ class Web extends ApplicationBootstrap
protected function detectLocale()
{
$auth = Manager::getInstance();
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$auth->isAuthenticated()
|| ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) === null
if ($auth->isAuthenticated()
&& ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null
) {
$locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
}
return $locale;
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
}
return Translator::DEFAULT_LOCALE;
}
/**
* Setup an autoloader namespace for Icinga\Forms