Changeset 2425 for trunk


Ignore:
Timestamp:
Jul 6, 2008, 12:36:39 AM (16 years ago)
Author:
rvelices
Message:
  • fix some side effects with browser language (wrong display/user creation in admin and mails to admin in user browser language)
Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_user.inc.php

    r2411 r2425  
    152152    }
    153153
    154     create_user_infos($next_id);
     154    $override = null;
     155    if ($with_notification and $conf['browser_language'])
     156    {
     157      if ( !get_browser_language($override['language']) )
     158        $override=null;
     159    }
     160    create_user_infos($next_id, $override);
    155161
    156162    if ($with_notification and $conf['email_admin_on_new_user'])
     
    839845function get_default_language()
    840846{
    841   global $conf;
    842   if (isset($conf['browser_language']) and $conf['browser_language'])
    843   {
    844     return get_browser_language();
    845   }
    846   else
    847   {
    848     return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
    849   }
     847  return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
    850848}
    851849
    852850/**
    853   * Returns the browser language value
     851  * Returns true if the browser language value is set into param $lang
    854852  *
    855853  */
    856 function get_browser_language()
     854function get_browser_language(&$lang)
    857855{
    858856  $browser_language = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
     
    861859    if (substr($language_code, 0, 2) == $browser_language)
    862860    {
    863       return $language_code;
    864     }
    865   }
    866   return PHPWG_DEFAULT_LANGUAGE;
     861      $lang = $language_code;
     862      return true;
     863    }
     864  }
     865  return false;
    867866}
    868867
     
    924923        $status = 'normal';
    925924      }
    926       $default_user['language'] = get_default_language();
    927925
    928926      $insert = array_merge(
  • trunk/include/user.inc.php

    r2371 r2425  
    7070          ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
    7171         );
    72 if (is_a_guest() or is_generic())
     72if ($conf['browser_language'] and (is_a_guest() or is_generic()) )
    7373{
    74   $user['language'] = get_default_language();
     74  get_browser_language($user['language']);
    7575}
    7676trigger_action('user_init', $user);
Note: See TracChangeset for help on using the changeset viewer.