From 83ad8e00fd4835f819c8d61ff9093f57a2097d2c Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 12 Jul 2010 08:00:36 +0000 Subject: [PATCH] core:LanguageAdaptor: Cleanups. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2410 44740490-163a-0410-bde0-09ae8108e29a --- .../core/lib/Auth/Process/LanguageAdaptor.php | 43 ++++++------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/modules/core/lib/Auth/Process/LanguageAdaptor.php b/modules/core/lib/Auth/Process/LanguageAdaptor.php index 38d77ed57..922be0584 100644 --- a/modules/core/lib/Auth/Process/LanguageAdaptor.php +++ b/modules/core/lib/Auth/Process/LanguageAdaptor.php @@ -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 -- GitLab