aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_user.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2014-09-30 08:23:34 +0000
committerplegall <plg@piwigo.org>2014-09-30 08:23:34 +0000
commit18f045bf35ebc5ff9cfb8ef79a0a3318db1b6903 (patch)
tree192b6c4696c6481399f5634b6222c8cbef057d02 /include/functions_user.inc.php
parent7e5722ce78f89e4f7dbd91a8785b449aa122878b (diff)
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
Diffstat (limited to '')
-rw-r--r--include/functions_user.inc.php22
1 files changed, 7 insertions, 15 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;