aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_mail.inc.php
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2010-02-18 23:10:16 +0000
committerrub <rub@piwigo.org>2010-02-18 23:10:16 +0000
commitce326d88f3b9f8ea946a92e2225c7e628b139e3b (patch)
tree58b30431fd2185de60aac84ea276271306b6819a /include/functions_mail.inc.php
parent3ab6df98e8f4bf47d5359fdf2fe492ffd71e4c6e (diff)
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/branches/2.0@4907 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-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 f1e0ba4ff..301604829 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;
}