From 18f045bf35ebc5ff9cfb8ef79a0a3318db1b6903 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 30 Sep 2014 08:23:34 +0000 Subject: bug 3111: cleaner code for get_browser_language (no more reference as parameter) git-svn-id: http://piwigo.org/svn/trunk@29840 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_user.inc.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'include/functions_user.inc.php') 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; -- cgit v1.2.3