Changeset 4907 for branches


Ignore:
Timestamp:
Feb 19, 2010, 12:10:16 AM (15 years ago)
Author:
rub
Message:

Feature 0001142: notification on category, current user language depends on last group user

Thanks to cljosse and Eric for their help!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/functions_mail.inc.php

    r3937 r4907  
    222222  global $switch_lang, $user, $lang, $lang_info;
    223223
    224   if (count($switch_lang['stack']) == 0)
    225   {
    226     $prev_language = $user['language'];
     224  // explanation of switch_lang
     225  // $switch_lang['language'] contains data of language
     226  // $switch_lang['stack'] contains stack LIFO
     227  // $switch_lang['initialisation'] allow to know if it's first call
     228
     229  // Treatment with current user
     230  // Language of current user is saved (it's considered OK on firt call)
     231  if (!isset($switch_lang['initialisation']) and !isset($switch_lang['language'][$user['language']]))
     232  {
     233    $switch_lang['initialisation'] = true;
     234    $switch_lang['language'][$user['language']]['lang_info'] = $lang_info;
     235    $switch_lang['language'][$user['language']]['lang'] = $lang;
     236  }
     237
     238  // Change current infos
     239  $switch_lang['stack'][] = $user['language'];
     240  $user['language'] = $language;
     241
     242  // Load new data if necessary
     243  if (!isset($switch_lang['language'][$language]))
     244  {
     245    // Re-Init language arrays
     246    $lang_info = array();
     247    $lang  = array();
     248
     249    // language files
     250    load_language('common.lang', '', array('language'=>$language) );
     251    // No test admin because script is checked admin (user selected no)
     252    // Translations are in admin file too
     253    load_language('admin.lang', '', array('language'=>$language) );
     254    trigger_action('loading_lang');
     255    load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
     256
     257    $switch_lang['language'][$language]['lang_info'] = $lang_info;
     258    $switch_lang['language'][$language]['lang'] = $lang;
    227259  }
    228260  else
    229261  {
    230     $prev_language = end($switch_lang['stack']);
    231   }
    232 
    233   $switch_lang['stack'][] = $language;
    234 
    235   if ($prev_language != $language)
    236   {
    237     if (!isset($switch_lang['language'][$prev_language]))
    238     {
    239       $switch_lang[$prev_language]['lang_info'] = $lang_info;
    240       $switch_lang[$prev_language]['lang'] = $lang;
    241     }
    242 
    243     if (!isset($switch_lang['language'][$language]))
    244     {
    245       // Re-Init language arrays
    246       $lang_info = array();
    247       $lang  = array();
    248 
    249       // language files
    250       load_language('common.lang', '', array('language'=>$language) );
    251       // No test admin because script is checked admin (user selected no)
    252       // Translations are in admin file too
    253       load_language('admin.lang', '', array('language'=>$language) );
    254       trigger_action('loading_lang');
    255       load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
    256 
    257       $switch_lang[$language]['lang_info'] = $lang_info;
    258       $switch_lang[$language]['lang'] = $lang;
    259     }
    260     else
    261     {
    262       $lang_info = $switch_lang[$language]['lang_info'];
    263       $lang = $switch_lang[$language]['lang'];
    264     }
    265 
    266     $user['language'] = $language;
     262    $lang_info = $switch_lang['language'][$language]['lang_info'];
     263    $lang = $switch_lang['language'][$language]['lang'];
    267264  }
    268265}
     
    277274  global $switch_lang, $user, $lang, $lang_info;
    278275
    279   $last_language = array_pop($switch_lang['stack']);
    280 
    281276  if (count($switch_lang['stack']) > 0)
    282277  {
    283     $language = end($switch_lang['stack']);
    284   }
    285   else
    286   {
    287     $language = $user['language'];
    288   }
    289 
    290   if ($last_language != $language)
    291   {
    292     if (!isset($switch_lang['language'][$language]))
    293     {
    294       $lang_info = $switch_lang[$language]['lang_info'];
    295       $lang = $switch_lang[$language]['lang'];
     278    // Get last value
     279    $language = array_pop($switch_lang['stack']);
     280
     281    // Change current infos
     282    if (isset($switch_lang['language'][$language]))
     283    {
     284      $lang_info = $switch_lang['language'][$language]['lang_info'];
     285      $lang = $switch_lang['language'][$language]['lang'];
    296286    }
    297287    $user['language'] = $language;
Note: See TracChangeset for help on using the changeset viewer.