aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2010-02-18 23:12:47 +0000
committerrub <rub@piwigo.org>2010-02-18 23:12:47 +0000
commit9c5a2aee191419b11aeef672b97f40fdc04d24ae (patch)
tree4c97797a98d3bde05cc1ca8316fbd9c703192394
parentb73d129a17b8f633b283ab46824ed8a1e42827f5 (diff)
merge -c4907 from branch 2.0 to trunk
Feature 0001142: notification on category, current user language depends on last group user Thanks to cljosse and Eric for their help! git-svn-id: http://piwigo.org/svn/trunk@4908 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/functions_mail.inc.php88
1 files changed, 39 insertions, 49 deletions
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index 8ea8ec8ae..3220d592e 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -221,49 +221,46 @@ function switch_lang_to($language)
{
global $switch_lang, $user, $lang, $lang_info;
- if (count($switch_lang['stack']) == 0)
- {
- $prev_language = $user['language'];
- }
- else
+ // explanation of switch_lang
+ // $switch_lang['language'] contains data of language
+ // $switch_lang['stack'] contains stack LIFO
+ // $switch_lang['initialisation'] allow to know if it's first call
+
+ // Treatment with current user
+ // Language of current user is saved (it's considered OK on firt call)
+ if (!isset($switch_lang['initialisation']) and !isset($switch_lang['language'][$user['language']]))
{
- $prev_language = end($switch_lang['stack']);
+ $switch_lang['initialisation'] = true;
+ $switch_lang['language'][$user['language']]['lang_info'] = $lang_info;
+ $switch_lang['language'][$user['language']]['lang'] = $lang;
}
- $switch_lang['stack'][] = $language;
+ // Change current infos
+ $switch_lang['stack'][] = $user['language'];
+ $user['language'] = $language;
- if ($prev_language != $language)
+ // Load new data if necessary
+ if (!isset($switch_lang['language'][$language]))
{
- if (!isset($switch_lang['language'][$prev_language]))
- {
- $switch_lang[$prev_language]['lang_info'] = $lang_info;
- $switch_lang[$prev_language]['lang'] = $lang;
- }
+ // Re-Init language arrays
+ $lang_info = array();
+ $lang = array();
- if (!isset($switch_lang['language'][$language]))
- {
- // Re-Init language arrays
- $lang_info = array();
- $lang = array();
-
- // language files
- load_language('common.lang', '', array('language'=>$language) );
- // No test admin because script is checked admin (user selected no)
- // Translations are in admin file too
- load_language('admin.lang', '', array('language'=>$language) );
- trigger_action('loading_lang');
- load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
-
- $switch_lang[$language]['lang_info'] = $lang_info;
- $switch_lang[$language]['lang'] = $lang;
- }
- else
- {
- $lang_info = $switch_lang[$language]['lang_info'];
- $lang = $switch_lang[$language]['lang'];
- }
+ // language files
+ load_language('common.lang', '', array('language'=>$language) );
+ // No test admin because script is checked admin (user selected no)
+ // Translations are in admin file too
+ load_language('admin.lang', '', array('language'=>$language) );
+ trigger_action('loading_lang');
+ load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
- $user['language'] = $language;
+ $switch_lang['language'][$language]['lang_info'] = $lang_info;
+ $switch_lang['language'][$language]['lang'] = $lang;
+ }
+ else
+ {
+ $lang_info = $switch_lang['language'][$language]['lang_info'];
+ $lang = $switch_lang['language'][$language]['lang'];
}
}
@@ -276,23 +273,16 @@ function switch_lang_back()
{
global $switch_lang, $user, $lang, $lang_info;
- $last_language = array_pop($switch_lang['stack']);
-
if (count($switch_lang['stack']) > 0)
{
- $language = end($switch_lang['stack']);
- }
- else
- {
- $language = $user['language'];
- }
+ // Get last value
+ $language = array_pop($switch_lang['stack']);
- if ($last_language != $language)
- {
- if (!isset($switch_lang['language'][$language]))
+ // Change current infos
+ if (isset($switch_lang['language'][$language]))
{
- $lang_info = $switch_lang[$language]['lang_info'];
- $lang = $switch_lang[$language]['lang'];
+ $lang_info = $switch_lang['language'][$language]['lang_info'];
+ $lang = $switch_lang['language'][$language]['lang'];
}
$user['language'] = $language;
}