Skip to content
Snippets Groups Projects
Commit 83ad8e00 authored by Olav Morken's avatar Olav Morken
Browse files

core:LanguageAdaptor: Cleanups.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2410 44740490-163a-0410-bde0-09ae8108e29a
parent b48e80cc
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
/**
* Filter to set and get language settings from attributes.
*
*
* @author Andreas Åkre Solberg, UNINETT AS.
* @package simpleSAMLphp
* @version $Id$
......@@ -40,48 +40,31 @@ class sspmod_core_Auth_Process_LanguageAdaptor extends SimpleSAML_Auth_Processin
assert('array_key_exists("Attributes", $request)');
$attributes =& $request['Attributes'];
$attrlang = NULL;
if (array_key_exists($this->langattr, $attributes))
if (array_key_exists($this->langattr, $attributes))
$attrlang = $attributes[$this->langattr][0];
$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'frontpage');
$lang = $t->getLanguage(FALSE, FALSE);
if (isset($attrlang))
if (isset($attrlang))
SimpleSAML_Logger::debug('LanguageAdaptor: Language in attribute was set [' . $attrlang . ']');
if (isset($lang))
SimpleSAML_Logger::debug('LanguageAdaptor: Language in session was set [' . $lang . ']');
if (isset($attrlang)) {
if (!isset($lang)) {
$t->setLanguage($attrlang);
$_GET['language'] = $attrlang;
} else {
// Language was set in both attributes and session.
if ($lang !== $attrlang) {
// Different language set in attributes and session.
}
}
} else {
if (isset($lang)) {
$request['Attributes'][$this->langattr] = array($lang);
} else {
// Language was neighter set in attributes or in session
}
if (isset($attrlang) && !isset($lang)) {
/* Language set in attribute but not in cookie - update cookie. */
$t->setLanguage($attrlang);
$_GET['language'] = $attrlang;
} elseif (!isset($attrlang) && isset($lang)) {
/* Language set in cookie, but not in attribute. Update attribute. */
$request['Attributes'][$this->langattr] = array($lang);
}
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment