Index: extensions/UserAdvManager/trunk/include/functions.inc.php
===================================================================
--- extensions/UserAdvManager/trunk/include/functions.inc.php	(revision 18158)
+++ extensions/UserAdvManager/trunk/include/functions.inc.php	(revision 18205)
@@ -887,4 +887,13 @@
     }
   }
+  if( isset($_GET['UAM_msg']))
+  {
+    UAM_DisplayMsg();
+  }
+  elseif (isset($_GET['key']) and isset($_GET['userid']))
+  {
+    UAM_ConfirmMail();
+  }
+
 }
 
@@ -919,5 +928,113 @@
   }
 }
-
+/**
+ * Triggered on init
+ * 
+ * Check the key and display a message
+ */
+function UAM_ConfirmMail()
+{
+
+  if (isset($_GET['key']) and isset($_GET['userid']))
+  {
+  
+    global $user, $lang, $conf, $page;
+    
+    $key = $_GET['key'];
+    $userid = $_GET['userid'];
+    
+    $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
+    $conf_UAM = unserialize($conf['UserAdvManager']);
+  
+    $query = '
+  SELECT '.USERS_TABLE.'.username
+  FROM '.USERS_TABLE.'
+  WHERE ('.USERS_TABLE.'.id ='.$userid.')
+  ;';
+    $result = pwg_db_fetch_assoc(pwg_query($query));
+  
+    if (VerifyConfirmMail($key))
+    {
+      if (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')
+      {
+        validation_mail($userid);
+      }
+  // We have to get the user's language in database
+  // ----------------------------------------------
+      $query = '
+  SELECT language
+  FROM '.USER_INFOS_TABLE.'
+  WHERE '.USER_INFOS_TABLE.'.user_id ='.$userid.'
+  ;';
+      $data = pwg_db_fetch_assoc(pwg_query($query));
+  
+  // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
+  // -------------------------------------------------------------------------------------------------------------------------------
+      if (empty($data))
+      {
+  // And switch gallery to this language before using personalized and multilangual contents
+  // ---------------------------------------------------------------------------------------
+        $language = pwg_get_session_var('lang_switch', $user['language']);
+        switch_lang_to($language);
+      }
+      else
+      {
+  // And switch gallery to this language before using personalized and multilangual contents
+  // ---------------------------------------------------------------------------------------
+        switch_lang_to($data['language']);
+        load_language('plugin.lang', UAM_PATH);
+      }
+  
+      if (isset($conf_UAM_ConfirmMail[5]) and $conf_UAM_ConfirmMail[5] <> '')
+      {
+        // Management of Extension flags ([username], [mygallery], [myurl])
+        // ----------------------------------------------------------------
+        $patterns[] = '#\[username\]#i';
+        $replacements[] = $result['username'];
+        $patterns[] = '#\[mygallery\]#i';
+        $replacements[] = $conf['gallery_title'];
+        $patterns[] = '#\[myurl\]#i';
+        $replacements[] = get_gallery_home_url();
+  
+        if (function_exists('get_user_language_desc'))
+        {
+          $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
+        }
+        else
+        {
+          $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
+        }
+        $page['infos'][]=$custom_text;
+        //print_r($custom_text);
+      }
+      //log_user($userid, true);
+    }  
+    else
+    {
+      if (isset($conf_UAM_ConfirmMail[6]) and $conf_UAM_ConfirmMail[6] <> '')
+      {
+        // Management of Extension flags ([username], [mygallery], [myurl])
+        // ----------------------------------------------------------------
+        $patterns[] = '#\[username\]#i';
+        $replacements[] = $result['username'];
+        $patterns[] = '#\[mygallery\]#i';
+        $replacements[] = $conf['gallery_title'];
+        $patterns[] = '#\[myurl\]#i';
+        $replacements[] = get_gallery_home_url();
+     
+        if (function_exists('get_user_language_desc'))
+        {
+          $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
+        }
+        else
+        {
+          $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
+        }
+        
+        $page['errors'][]=$custom_text;
+      }
+    }
+  }
+}
 /**
  * Triggered on render_lost_password_mail_content
@@ -1836,5 +1953,12 @@
     SetUnvalidated($user_id);
     
-    return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id;
+    if ( $conf['guest_access'] )
+    {
+      return( get_absolute_root_url().'?key='.$Confirm_Mail_ID.'&userid='.$user_id);
+    }
+    else
+    {
+      return( get_absolute_root_url().'identification.php?key='.$Confirm_Mail_ID.'&userid='.$user_id);
+    }
   }
 }
@@ -1926,12 +2050,19 @@
     pwg_query($query);
 
-				$query = '
+    $query = '
 UPDATE '.USER_INFOS_TABLE.'
 SET registration_date = "'.$dbnow.'"
 WHERE user_id = '.$user_id.'
 ;';
-				pwg_query($query);
+    pwg_query($query);
     
-    return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id;
+    if ( $conf['guest_access'] )
+    {
+      return( get_absolute_root_url().'?key='.$Confirm_Mail_ID.'&userid='.$user_id);
+    }
+    else
+    {
+      return( get_absolute_root_url().'identification.php?key='.$Confirm_Mail_ID.'&userid='.$user_id);
+    }
   }
 }
