diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_user.inc.php | 22 | ||||
-rw-r--r-- | include/user.inc.php | 4 |
2 files changed, 9 insertions, 17 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 3e69ef0c2..d4a0ebaf6 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -219,18 +219,12 @@ SELECT id mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts); } - $override = null; - if ($notify_admin and $conf['browser_language']) + $override = array(); + if ($language = get_browser_language()) { - // if function get_browser_language finds a language in the browser - // which matches a language activated in Piwigo, then it sets - // $override['language'] to 'ru' (for example) and returns - // true. $override won't stay null - if (!get_browser_language($override['language'])) - { - $override=null; - } + $override['language'] = $language; } + create_user_infos($user_id, $override); if ($notify_admin and $conf['email_admin_on_new_user']) @@ -813,18 +807,16 @@ function get_default_language() * Tries to find the browser language among available languages. * @todo : try to match 'fr_CA' before 'fr' * - * @param string &$lang - * @return bool + * @return string */ -function get_browser_language(&$lang) +function get_browser_language() { $browser_language = substr(@$_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2); foreach (get_languages() as $language_code => $language_name) { if (substr($language_code, 0, 2) == $browser_language) { - $lang = $language_code; - return true; + return $language_code; } } return false; diff --git a/include/user.inc.php b/include/user.inc.php index d1bf87c70..4de5cc6c3 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -68,9 +68,9 @@ if ($conf['apache_authentication']) $user = build_user( $user['id'], ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ? ); -if ($conf['browser_language'] and (is_a_guest() or is_generic()) ) +if ($conf['browser_language'] and (is_a_guest() or is_generic()) and $language = get_browser_language()) { - get_browser_language($user['language']); + $user['language'] = $language; } trigger_notify('user_init', $user); ?> |