function domain_locale_init in Domain Locale 7
Implements hook_init().
- Switch the current language to the site default is user language is not supported on the current domain
- In that case, redirect to the root in the default language
File
- ./
domain_locale.module, line 243 - Provides domain specific language settings.
Code
function domain_locale_init() {
global $language, $_domain;
$enabled_domain_langs = domain_locale_lookup($_domain['domain_id']);
// If the user lang is not supported.
if ($enabled_domain_langs && !isset($enabled_domain_langs[$language->language])) {
$language_default = domain_locale_language_default();
if ($language_default) {
$languages = language_list();
// Set the current language to the default language.
$language = $languages[$language_default->language];
// Check if we are on a secure connection.
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
$http = 'https://';
}
else {
$http = 'http://';
}
// Set URL suffix to the language prefix, if available.
if (isset($language_default->prefix)) {
$url_suffix = '/' . $language_default->prefix;
}
else {
$url_suffix = '';
}
drupal_goto($http . $_domain['subdomain'] . $url_suffix);
}
}
}