Index: extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
===================================================================
--- extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php	(revision 4384)
+++ extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php	(revision 4399)
@@ -14,4 +14,15 @@
 	$infos1_perso = "";
   $infos2_perso = "";
+
+/* We have to get the user's language in database */
+  $query ='
+SELECT user_id, language
+FROM '.USER_INFOS_TABLE.'
+WHERE user_id = '.$id.'
+;';
+  $data = mysql_fetch_assoc(pwg_query($query));
+  $language = $data['language'];
+/* And switch gallery to this language before using personalized and multilangual contents */
+  switch_lang_to($data['language']);
 
   switch($typemail)
@@ -75,4 +86,5 @@
   }
 
+/* Sending the email with subject and contents */
   pwg_mail($email, array(
     'subject' => $subject,
@@ -80,4 +92,115 @@
   ));
 
+/* Switching back to default language */
+switch_lang_back();
+
+/* ********************** */
+/* Email sending debugger */
+/* This is only to trace  */
+/* the send of emails for */
+/* debugging              */
+/* ********************** */  
+//  MailLog($email,$subject, $content);
+/* ********************** */
+}
+
+
+/* Email sending debugger function */
+//function MailLog  ($to, $subject, $content)
+//{
+//   $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ;
+//   fwrite($fo,"======================\n") ;
+//   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
+//   fwrite($fo,$to . "\n" . $subject . "\r\n") ;
+//   fwrite($fo, "\n" . $content . "\r\n") ;
+   //fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ;
+//   fclose($fo) ;
+   //return mail ($to,$subject) ;
+//}
+
+
+/* Function called from UserAdvManager_admin.php to resend validation email with or without new validation key */
+function ResendMail2User($typemail, $user_id, $username, $email, $confirm)
+{
+  global $conf;
+  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
+	$conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
+  
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+  
+	$infos1_perso = "";
+  $infos2_perso = "";
+  
+/* We have to get the user's language in database */
+  $query ='
+SELECT user_id, language
+FROM '.USER_INFOS_TABLE.'
+WHERE user_id = '.$id.'
+;';
+  $data = mysql_fetch_assoc(pwg_query($query));
+  $language = $data['language'];
+/* And switch gallery to this language before using personalized and multilangual contents */
+  switch_lang_to($data['language']);
+
+  switch($typemail)
+  {
+    case 1:
+      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_with_key_of_%s', $username));
+      
+      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and $confirm)
+      {
+        if (function_exists('get_user_language_desc'))
+        {
+          $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
+        }
+				else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
+
+        $infos2 = array
+        (
+          get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
+          get_l10n_args('', ''),
+        );        
+			}
+
+/* Set reminder true */      
+      $query = "
+UPDATE ".USER_CONFIRM_MAIL_TABLE."
+SET reminder = 'true'
+WHERE user_id = '".$user_id."'
+;";
+      pwg_query($query);
+      
+		break;
+      
+    case 2:
+      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_without_key_of_%s',$username));
+      
+      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and !$confirm)
+      {
+        if (function_exists('get_user_language_desc'))
+        {
+          $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
+        }
+        else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
+      }
+      
+/* Set reminder true */      
+      $query = "
+UPDATE ".USER_CONFIRM_MAIL_TABLE."
+SET reminder = 'true'
+WHERE user_id = '".$user_id."'
+;";
+      pwg_query($query);
+      
+    break;
+	}
+  
+  pwg_mail($email, array(
+    'subject' => $subject,
+    'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(),
+  ));
+
+/* Switching back to default language */
+switch_lang_back();
 /* ********************** */
 /* Email sending debugger */
@@ -91,106 +214,24 @@
 
 
-/* Email sending debugger function */
-//function MailLog  ($to, $subject)
-//{
-//   $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ;
-//   fwrite($fo,"======================\n") ;
-//   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
-//   fwrite($fo,$to . "\n" . $subject . "\r\n") ;
-//   fclose($fo) ;
-   //return mail ($to,$subject) ;
-//}
-
-
-/* Function called from UserAdvManager_admin.php to resend validation email with or without new validation key */
-function ResendMail2User($typemail, $user_id, $username, $email, $confirm)
+/* Function called from UserAdvManager_admin.php to send a reminder mail for ghost users */
+function ghostreminder($user_id, $username, $email)
 {
   global $conf;
   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
-	$conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
   
 	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
   
 	$infos1_perso = "";
-  $infos2_perso = "";
-
-  switch($typemail)
-  {
-    case 1:
-      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_with_key_of_%s', $username));
-      
-      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and $confirm)
-      {
-        if (function_exists('get_user_language_desc'))
-        {
-          $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
-        }
-				else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
-
-        $infos2 = array
-        (
-          get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
-          get_l10n_args('', ''),
-        );        
-			}
-
-/* Set reminder true */      
-      $query = "
-UPDATE ".USER_CONFIRM_MAIL_TABLE."
-SET reminder = 'true'
-WHERE user_id = '".$user_id."'
-;";
-      pwg_query($query);
-      
-		break;
-      
-    case 2:
-      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_without_key_of_%s',$username));
-      
-      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and !$confirm)
-      {
-        if (function_exists('get_user_language_desc'))
-        {
-          $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
-        }
-        else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
-      }
-      
-/* Set reminder true */      
-      $query = "
-UPDATE ".USER_CONFIRM_MAIL_TABLE."
-SET reminder = 'true'
-WHERE user_id = '".$user_id."'
-;";
-      pwg_query($query);
-      
-    break;
-	}
-  
-  pwg_mail($email, array(
-    'subject' => $subject,
-    'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(),
-  ));
-
-/* ********************** */
-/* Email sending debugger */
-/* This is only to trace  */
-/* the send of emails for */
-/* debugging              */
-/* ********************** */  
-//  MailLog($email,$subject);
-/* ********************** */
-}
-
-
-/* Function called from UserAdvManager_admin.php to send a reminder mail for ghost users */
-function ghostreminder($user_id, $username, $email)
-{
-  global $conf;
-  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
-  
-	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
-  
-	$infos1_perso = "";
+
+/* We have to get the user's language in database */
+  $query ='
+SELECT user_id, language
+FROM '.USER_INFOS_TABLE.'
+WHERE user_id = '.$id.'
+;';
+  $data = mysql_fetch_assoc(pwg_query($query));
+  $language = $data['language'];
+/* And switch gallery to this language before using personalized and multilangual contents */
+  switch_lang_to($data['language']);
 
   $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_remainder_of_%s', $username));
@@ -212,4 +253,6 @@
   ));
 
+/* Switching back to default language */
+switch_lang_back();
 /* ********************** */
 /* Email sending debugger */
