getLanguageCookie() public static method

Deprecation: This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguageCookie() instead.
public static getLanguageCookie ( ) : null | string
return null | string
Exemplo n.º 1
0
 /**
  * getLanguage() will return the language selected by the user, or the default language
  * This function first looks for a cached language code,
  * then checks for a language cookie,
  * then it tries to calculate the preferred language from HTTP headers.
  * Last it returns the default language.
  */
 public function getLanguage()
 {
     // Language is set in object
     if (isset($this->language)) {
         return $this->language;
     }
     // Language is provided in a stored COOKIE
     $languageCookie = SimpleSAML_XHTML_Template::getLanguageCookie();
     if ($languageCookie !== NULL) {
         $this->language = $languageCookie;
         return $languageCookie;
     }
     /* Check if we can find a good language from the Accept-Language http header. */
     $httpLanguage = $this->getHTTPLanguage();
     if ($httpLanguage !== NULL) {
         return $httpLanguage;
     }
     // Language is not set, and we get the default language from the configuration.
     return $this->getDefaultLanguage();
 }
Exemplo n.º 2
0
 /**
  * Apply filter to add or replace attributes.
  *
  * Add or replace existing attributes with the configured values.
  *
  * @param array &$request  The current request
  */
 public function process(&$request)
 {
     assert('is_array($request)');
     assert('array_key_exists("Attributes", $request)');
     $attributes =& $request['Attributes'];
     $attrlang = NULL;
     if (array_key_exists($this->langattr, $attributes)) {
         $attrlang = $attributes[$this->langattr][0];
     }
     $lang = SimpleSAML_XHTML_Template::getLanguageCookie();
     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) && !isset($lang)) {
         // Language set in attribute but not in cookie - update cookie
         SimpleSAML_XHTML_Template::setLanguageCookie($attrlang);
     } elseif (!isset($attrlang) && isset($lang)) {
         // Language set in cookie, but not in attribute. Update attribute
         $request['Attributes'][$this->langattr] = array($lang);
     }
 }
Exemplo n.º 3
0
 /**
  * getLanguage() will return the language selected by the user, or the default language
  * This function first looks for a cached language code,
  * then checks for a language cookie,
  * then it tries to calculate the preferred language from HTTP headers.
  * Last it returns the default language.
  */
 public function getLanguage()
 {
     // Language is set in object
     if (isset($this->language)) {
         return $this->language;
     }
     // Run custom getLanguage function if defined
     $customFunction = $this->configuration->getArray('language.get_language_function', NULL);
     if (isset($customFunction)) {
         assert('is_callable($customFunction)');
         $customLanguage = call_user_func($customFunction, $this);
         if ($customLanguage !== NULL && $customLanguage !== FALSE) {
             return $customLanguage;
         }
     }
     // Language is provided in a stored COOKIE
     $languageCookie = SimpleSAML_XHTML_Template::getLanguageCookie();
     if ($languageCookie !== NULL) {
         $this->language = $languageCookie;
         return $languageCookie;
     }
     /* Check if we can find a good language from the Accept-Language http header. */
     $httpLanguage = $this->getHTTPLanguage();
     if ($httpLanguage !== NULL) {
         return $httpLanguage;
     }
     // Language is not set, and we get the default language from the configuration.
     return $this->getDefaultLanguage();
 }
        if (sizeof($idpList) > 1) {
            $params['saml:IDPList'] = $idpList;
        } else {
            $params['saml:idp'] = $idpList[0];
        }
    }
    $as->login($params);
}
$sessionExpiry = $as->getAuthData('Expire');
if (!is_array($sessionTicket) || $forceAuthn) {
    $sessionTicket = $ticketFactory->createSessionTicket($session->getSessionId(), $sessionExpiry);
    $ticketStore->addTicket($sessionTicket);
}
$parameters = array();
if (array_key_exists('language', $_GET)) {
    $oldLanguagePreferred = SimpleSAML_XHTML_Template::getLanguageCookie();
    if (isset($oldLanguagePreferred)) {
        $parameters['language'] = $oldLanguagePreferred;
    } else {
        if (is_string($_GET['language'])) {
            $parameters['language'] = $_GET['language'];
        }
    }
}
if (isset($_GET['service'])) {
    $attributes = $as->getAttributes();
    $casUsernameAttribute = $casconfig->getValue('attrname', 'eduPersonPrincipalName');
    $userName = $attributes[$casUsernameAttribute][0];
    if ($casconfig->getValue('attributes', true)) {
        $attributesToTransfer = $casconfig->getValue('attributes_to_transfer', array());
        if (sizeof($attributesToTransfer) > 0) {