Index: /extensions/UserAdvManager/trunk/changelog.txt.php
===================================================================
--- /extensions/UserAdvManager/trunk/changelog.txt.php	(revision 17886)
+++ /extensions/UserAdvManager/trunk/changelog.txt.php	(revision 17887)
@@ -340,5 +340,5 @@
             Update it_IT, thanks to : Ericnet and virgigiole
 
--- 2.40.6 : Bug 2744 fixed - User connexion rejection does not work if no group/status/privacy is set 
+-- 2.41.0 : Bug 2744 fixed - User connexion rejection does not work if no group/status/privacy is set 
 */
 ?>
Index: /extensions/UserAdvManager/trunk/include/functions.inc.php
===================================================================
--- /extensions/UserAdvManager/trunk/include/functions.inc.php	(revision 17886)
+++ /extensions/UserAdvManager/trunk/include/functions.inc.php	(revision 17887)
@@ -68,5 +68,5 @@
 
       $userid = get_userid($user['username']);
-        
+     	  
       // Looking for existing entry in last visit table
       // ----------------------------------------------
@@ -102,13 +102,13 @@
       }
     }
-    // Perform user logout after registration if not validated
-    if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']) )
-    {
-      invalidate_user_cache();
-      logout_user();
-      redirect(UAM_PATH.'rejected.php');
-    }
-  }
-
+  }
+
+  // Perform user logout after registration if not validated
+  if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']))
+  {
+    invalidate_user_cache();
+    logout_user();
+    redirect(UAM_PATH.'rejected.php');
+  }
 }
 
@@ -456,11 +456,38 @@
     }
   }
-  elseif ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']))
+  elseif ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and UAM_UsrReg_Verif($user['id']) == false and is_admin()==false and is_webmaster() == false)
   {
     // Logged-in user cleanup, session destruction and redirected to custom page
     // -------------------------------------------------------------------------
-    invalidate_user_cache();
-    logout_user();
-    redirect(UAM_PATH.'rejected.php');
+    if (UAM_UsrReg_Verif($user['id']))
+    {
+      $var2 = "UAM_UsrReg_Verif = True";
+    }
+    else
+    {
+      $var2 = "UAM_UsrReg_Verif = False";
+    }
+    
+    if (is_admin())
+    {
+      $var3 = "is_admin = True";
+    }
+    else
+    {
+      $var3 = "is_admin = False";
+    }
+
+    if (is_webmaster())
+    {
+      $var4 = "is_webmaster = True";
+    }
+    else
+    {
+      $var4 = "is_webmaster = False";
+    }
+    UAMLog($conf_UAM[39],$var2,$var3,$var4);
+    //invalidate_user_cache();
+    //logout_user();
+    //redirect(UAM_PATH.'rejected.php');
   }
 }
@@ -518,9 +545,9 @@
   {
     if (count($collection) > 0)
-    {
+  	{
       // Process if a non-admin nor webmaster user is logged
       // ---------------------------------------------------
       if (in_array($user['id'], $collection))
-      {
+    	{
         // Check lastvisit reminder state
         // ------------------------------
@@ -555,5 +582,5 @@
           redirect(UAM_PATH.'GT_del_account.php');
         }
-      }
+    	}
       else // Process if an admin or webmaster user is logged
       {
@@ -586,5 +613,5 @@
             list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
 
-            $query = "
+		        $query = "
 UPDATE ".USER_LASTVISIT_TABLE."
 SET lastvisit='".$dbnow."'
@@ -660,19 +687,19 @@
               // Reset confirmed user status to unvalidated
               // ------------------------------------------
-              $query = '
+						  $query = '
 UPDATE '.USER_CONFIRM_MAIL_TABLE.'
 SET date_check = NULL
 WHERE user_id = "'.$user_id.'"
 ;';
-              pwg_query($query);
+						  pwg_query($query);
 
               // Get users information for email notification
               // --------------------------------------------
-              $query = '
+						  $query = '
 SELECT id, username, mail_address
 FROM '.USERS_TABLE.'
 WHERE id = '.$user_id.'
 ;';
-              $data = pwg_db_fetch_assoc(pwg_query($query));
+						  $data = pwg_db_fetch_assoc(pwg_query($query));
             
               demotion_mail($user_id, $data['username'], $data['mail_address']);
@@ -726,9 +753,9 @@
   {
     if (count($collection) > 0)
-    {
+  	{
       // Process if a non-admin nor webmaster user is logged
       // ---------------------------------------------------
       if (in_array($user['id'], $collection))
-      {
+    	{
         // Check ConfirmMail reminder state
         // --------------------------------
@@ -753,5 +780,5 @@
         if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true')
         {
-          $typemail = 1;
+     		  $typemail = 1;
           
           // Get current user informations
@@ -780,5 +807,5 @@
           redirect(UAM_PATH.'USR_del_account.php');
         }
-      }
+    	}
       else // Process if an admin or webmaster user is logged
       {
@@ -908,7 +935,7 @@
   $conf_UAM = unserialize($conf['UserAdvManager']);
   
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
-  
-  $infos1_perso = "";
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+  
+	$infos1_perso = "";
   $infos2_perso = "";
   $subject = "";
@@ -1149,5 +1176,5 @@
   $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
   
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
   
 // We have to get the user's language in database
@@ -1207,5 +1234,5 @@
           $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n";
         }
-        else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n";
+				else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n";
 
         $infos2 = array
@@ -1214,5 +1241,5 @@
           get_l10n_args('', ''),
         );        
-      }
+			}
 
 // Set reminder true 
@@ -1225,5 +1252,5 @@
       pwg_query($query);
       
-    break;
+		break;
       
     case 2: //Generating email content for remind without a new key
@@ -1278,5 +1305,5 @@
       
     break;
-  }
+	}
   
   pwg_mail($email, array(
@@ -1304,5 +1331,5 @@
   $subject = "";
   
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
 
 // We have to get the user's language in database
@@ -1386,7 +1413,7 @@
   $conf_UAM = unserialize($conf['UserAdvManager']);
   
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
-  
-  $custom_txt = "";
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+  
+	$custom_txt = "";
   $subject = "";
 
@@ -1491,7 +1518,7 @@
   $conf_UAM = unserialize($conf['UserAdvManager']);
   
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
-  
-  $custom_txt = "";
+	include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+  
+	$custom_txt = "";
   $subject = "";
 
@@ -1783,10 +1810,10 @@
     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;
@@ -1922,59 +1949,59 @@
       if (!empty($registration_date))
       {
-        // Verify Confirmmail with time limit ON
+				// Verify Confirmmail with time limit ON
         // -------------------------------------
-        if (isset ($conf_UAM_ConfirmMail[1]))
-        {
-          // Dates formating and compare
+				if (isset ($conf_UAM_ConfirmMail[1]))
+				{
+					// Dates formating and compare
           // ---------------------------
-          $today = date("d-m-Y"); // Get today's date
-          list($day, $month, $year) = explode('-', $today); // explode date of today             
-          $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
-        
-          list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
-          list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
-          $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
-      
-          $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps 
-          $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
-
-          // Condition with the value set for time limit
+					$today = date("d-m-Y"); // Get today's date
+					list($day, $month, $year) = explode('-', $today); // explode date of today						 
+ 					$daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
+	  		
+	  			list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
+					list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
+					$regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
+			
+					$deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps	
+					$deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
+
+					// Condition with the value set for time limit
           // -------------------------------------------
-          if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
-          {
-            list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
+					if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
+					{
+						list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
 
             // Update ConfirmMail table
             // ------------------------
-            $query = '
+						$query = '
 UPDATE '.USER_CONFIRM_MAIL_TABLE.'
 SET date_check="'.$dbnow.'", reminder="false"
 WHERE id = "'.$id.'"
 ;';
-            pwg_query($query);
+						pwg_query($query);
 
             // Update LastVisit table - Force reminder field to false
             // Usefull when a user has been automatically downgraded and revalidate its registration
             // -------------------------------------------------------------------------------------
-            $query = '
+						$query = '
 UPDATE '.USER_LASTVISIT_TABLE.'
 SET reminder="false"
 WHERE user_id = "'.$data['user_id'].'"
 ;';
-            pwg_query($query);
+						pwg_query($query);
       
-            if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
-            {
-              $query = "
+						if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
+						{
+							$query = "
 DELETE FROM ".USER_GROUP_TABLE."
 WHERE user_id = '".$data['user_id']."'
   AND group_id = '".$conf_UAM[2]."'
 ;";
-              pwg_query($query);
-            }
-      
-            if ($conf_UAM[3] <> -1) // Add user to validated users group 
-            {
-              $query = "
+							pwg_query($query);
+						}
+	    
+						if ($conf_UAM[3] <> -1) // Add user to validated users group 
+						{
+							$query = "
 INSERT INTO ".USER_GROUP_TABLE."
   (user_id, group_id)
@@ -1982,57 +2009,57 @@
   ('".$data['user_id']."', '".$conf_UAM[3]."')
 ;";
-              pwg_query($query);
-            }
-
-            if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
-            {
-              $query = "
+							pwg_query($query);
+						}
+
+						if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
+						{
+							$query = "
 UPDATE ".USER_INFOS_TABLE."
 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."'
 WHERE user_id = '".$data['user_id']."'
 ;";
-              pwg_query($query);
-            }
-
-            if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
-            {
-              $query = "
+							pwg_query($query);
+						}
+
+						if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
+						{
+							$query = "
 UPDATE ".USER_INFOS_TABLE."
 SET level = '".(isset($data['level']) ? $data['level'] : $conf_UAM[36])."'
 WHERE user_id = '".$data['user_id']."'
 ;";
-              pwg_query($query);
-            }
-
-            // Refresh user's category cache
+							pwg_query($query);
+						}
+
+						// Refresh user's category cache
             // -----------------------------
-            invalidate_user_cache();
-  
-            return true;
-          }
-          elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds
-          {
-            return false;
-          }
-        }
-        // Verify Confirmmail with time limit OFF
+						invalidate_user_cache();
+  
+						return true;
+					}
+					elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds
+					{
+						return false;
+					}
+				}
+				// Verify Confirmmail with time limit OFF
         // --------------------------------------
-        else
-        {
-          list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
+				else
+				{
+					list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
 
           // Update ConfirmMail table
           // ------------------------
-          $query = '
+					$query = '
 UPDATE '.USER_CONFIRM_MAIL_TABLE.'
 SET date_check="'.$dbnow.'"
 WHERE id = "'.$id.'"
 ;';
-          pwg_query($query);
+					pwg_query($query);
 
           // Update LastVisit table - Force reminder field to false
           // Usefull when a user has been automatically downgraded and revalidate its registration
           // -------------------------------------------------------------------------------------
-          $query = '
+					$query = '
 UPDATE '.USER_LASTVISIT_TABLE.'
 SET reminder="false"
@@ -2041,24 +2068,24 @@
           pwg_query($query);
       
-          if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
-          {
-            $query = "
+					if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
+					{
+						$query = "
 DELETE FROM ".USER_GROUP_TABLE."
 WHERE user_id = '".$data['user_id']."'
 AND group_id = '".$conf_UAM[2]."'
 ;";
-            pwg_query($query);
-          }
+						pwg_query($query);
+					}
     
-          if ($conf_UAM[3] <> -1)
-          {
-            $query = "
+					if ($conf_UAM[3] <> -1)
+					{
+						$query = "
 DELETE FROM ".USER_GROUP_TABLE."
 WHERE user_id = '".$data['user_id']."'
 AND group_id = '".$conf_UAM[3]."'
 ;";
-            pwg_query($query);
-
-            $query = "
+						pwg_query($query);
+
+						$query = "
 INSERT INTO ".USER_GROUP_TABLE."
   (user_id, group_id)
@@ -2066,40 +2093,40 @@
   ('".$data['user_id']."', '".$conf_UAM[3]."')
 ;";
-            pwg_query($query);
-          }
-
-          if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
-          {
-            $query = "
+						pwg_query($query);
+					}
+
+					if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
+					{
+						$query = "
 UPDATE ".USER_INFOS_TABLE."
 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."'
 WHERE user_id = '".$data['user_id']."'
 ;";
-            pwg_query($query);
-          }
-
-          if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
-          {
-            $query = "
+						pwg_query($query);
+					}
+
+					if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
+					{
+						$query = "
 UPDATE ".USER_INFOS_TABLE."
 SET level = '".(isset($data['level']) ? $data['level'] : $conf_UAM[36])."'
 WHERE user_id = '".$data['user_id']."'
 ;";
-            pwg_query($query);
-          }
-
-          // Refresh user's category cache
+						pwg_query($query);
+					}
+
+					// Refresh user's category cache
           // -----------------------------
-          invalidate_user_cache();
-  
-          return true;
-        }
-      }
-    }
+					invalidate_user_cache();
+  
+					return true;
+				}
+			}
+		}
     else if (!empty($data) and !is_null($data['date_check']))
     {
       return false;
     }
-  }
+	}
   else
     return false;
@@ -2123,5 +2150,5 @@
     list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
 
-    $query = "
+		$query = "
 UPDATE ".USER_CONFIRM_MAIL_TABLE."
 SET date_check='".$dbnow."'
@@ -2132,5 +2159,5 @@
 
   if ($conf_UAM[2] <> -1) // Delete user from waiting group
-  {
+	{
     $query = "
 DELETE FROM ".USER_GROUP_TABLE."
@@ -2138,9 +2165,9 @@
   AND group_id = '".$conf_UAM[2]."'
 ;";
-    pwg_query($query);
-  }
-  
-  if ($conf_UAM[3] <> -1) // Set user's valid group
-  {
+		pwg_query($query);
+  }
+  
+	if ($conf_UAM[3] <> -1) // Set user's valid group
+	{
     $query = "
 DELETE FROM ".USER_GROUP_TABLE."
@@ -2149,6 +2176,6 @@
 ;";
     pwg_query($query);
-  
-    $query = "
+	
+		$query = "
 INSERT INTO ".USER_GROUP_TABLE."
   (user_id, group_id)
@@ -2156,9 +2183,9 @@
   ('".$id."', '".$conf_UAM[3]."')
 ;";
-    pwg_query($query);
-  }
-
-  if ($conf_UAM[4] <> -1) // Set user's valid status
-  {
+		pwg_query($query);
+  }
+
+	if ($conf_UAM[4] <> -1) // Set user's valid status
+	{
     $query = "
 UPDATE ".USER_INFOS_TABLE."
@@ -2166,9 +2193,9 @@
 WHERE user_id = '".$id."'
 ;";
-    pwg_query($query);
-  }
-
-  if ($conf_UAM[36] <> -1) // Set user's valid privacy level
-  {
+		pwg_query($query);
+  }
+
+	if ($conf_UAM[36] <> -1) // Set user's valid privacy level
+	{
     $query = "
 UPDATE ".USER_INFOS_TABLE."
@@ -2176,5 +2203,5 @@
 WHERE user_id = '".$id."'
 ;";
-    pwg_query($query);
+		pwg_query($query);
   }
 }
@@ -2229,16 +2256,16 @@
   $conf_UAM = unserialize($conf['UserAdvManager']);
   
-  if (isset($email) and isset($conf_UAM[11]) and $conf_UAM[11] <> '')
-  {
-    $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
-    for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
-    {
-      $pattern = '/'.$conf_MailExclusion[$i].'/i';
-      if (preg_match($pattern, $email))
-      {
-            return true;
-      }
-    }
-  }
+	if (isset($email) and isset($conf_UAM[11]) and $conf_UAM[11] <> '')
+	{
+		$conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
+		for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
+		{
+			$pattern = '/'.$conf_MailExclusion[$i].'/i';
+			if (preg_match($pattern, $email))
+      {
+        		return true;
+      }
+		}
+	}
   else
   {
@@ -2256,7 +2283,7 @@
 function get_unvalid_user_list()
 {
-  global $conf, $page;
+	global $conf, $page;
           
-  // Get ConfirmMail configuration
+	// Get ConfirmMail configuration
   // -----------------------------
   $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
@@ -2267,5 +2294,5 @@
   $users = array();
 
-  // Search users depending expiration date
+	// Search users depending expiration date
   // --------------------------------------
   $query = '
@@ -2286,5 +2313,5 @@
   OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_UAM_ConfirmMail[1].'")';
 
-  if ($conf_UAM[2] <> '-1' and $conf_UAM[7] == '-1')
+	if ($conf_UAM[2] <> '-1' and $conf_UAM[7] == '-1')
   {
     $query.= '
@@ -2305,27 +2332,27 @@
 ;';
 
-  $result = pwg_query($query);
+	$result = pwg_query($query);
       
   while ($row = pwg_db_fetch_assoc($result))
   {
-    $user = $row;
+  	$user = $row;
     $user['groups'] = array();
 
     array_push($users, $user);
-  }
-
-  // Add groups list
+	}
+
+	// Add groups list
   // ---------------
   $user_ids = array();
   foreach ($users as $i => $user)
   {
-    $user_ids[$i] = $user['id'];
-  }
-  
-  $user_nums = array_flip($user_ids);
+  	$user_ids[$i] = $user['id'];
+	}
+	
+	$user_nums = array_flip($user_ids);
 
   if (count($user_ids) > 0)
   {
-    $query = '
+  	$query = '
 SELECT user_id, group_id
   FROM '.USER_GROUP_TABLE.'
@@ -2333,16 +2360,16 @@
 ;';
         
-    $result = pwg_query($query);
+		$result = pwg_query($query);
         
     while ($row = pwg_db_fetch_assoc($result))
     {
-      array_push(
-        $users[$user_nums[$row['user_id']]]['groups'],
+    	array_push(
+      	$users[$user_nums[$row['user_id']]]['groups'],
         $row['group_id']
-      );
-    }
-  }
-
-  return $users;
+			);
+		}
+	}
+
+	return $users;
 }
 
@@ -2357,7 +2384,7 @@
 function get_unvalid_user_autotasks()
 {
-  global $conf, $page;
+	global $conf, $page;
           
-  // Get ConfirmMail configuration
+	// Get ConfirmMail configuration
   // -----------------------------
   $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
@@ -2365,5 +2392,5 @@
   $users = array();
 
-  // search users depending expiration date
+	// search users depending expiration date
   // --------------------------------------
   $query = '
@@ -2377,12 +2404,12 @@
 ORDER BY ui.registration_date ASC;';
 
-  $result = pwg_query($query);
+	$result = pwg_query($query);
       
   while ($row = pwg_db_fetch_assoc($result))
   {
     array_push($users, $row);
-  }
-
-  return $users;
+	}
+
+	return $users;
 }
 
@@ -2396,5 +2423,5 @@
 function get_ghost_user_list()
 {
-  global $conf, $page;
+	global $conf, $page;
 
   $conf_UAM = unserialize($conf['UserAdvManager']);
@@ -2402,5 +2429,5 @@
   $users = array();
 
-  // Search users depending expiration date
+	// Search users depending expiration date
   // --------------------------------------
   $query = '
@@ -2416,23 +2443,23 @@
 ORDER BY lv.lastvisit ASC;';
 
-  $result = pwg_query($query);
+	$result = pwg_query($query);
       
   while ($row = pwg_db_fetch_assoc($result))
   {
-    $user = $row;
+  	$user = $row;
     $user['groups'] = array();
 
     array_push($users, $user);
-  }
-
-  // Add groups list
+	}
+
+	// Add groups list
   // ---------------
   $user_ids = array();
   foreach ($users as $i => $user)
   {
-    $user_ids[$i] = $user['id'];
-  }
-
-  return $users;
+  	$user_ids[$i] = $user['id'];
+	}
+
+	return $users;
 }
 
@@ -2446,5 +2473,5 @@
 function get_ghosts_autotasks()
 {
-  global $conf, $page;
+	global $conf, $page;
 
   $conf_UAM = unserialize($conf['UserAdvManager']);
@@ -2452,5 +2479,5 @@
   $users = array();
   
-  // Search users depending expiration date and reminder sent
+	// Search users depending expiration date and reminder sent
   // --------------------------------------------------------
   $query = '
@@ -2463,12 +2490,12 @@
 ORDER BY lv.lastvisit ASC;';
 
-  $result = pwg_query($query);
+	$result = pwg_query($query);
       
   while ($row = pwg_db_fetch_assoc($result))
   {
     array_push($users, $row);
-  }
-  
-  return $users;
+	}
+  
+	return $users;
 }
 
@@ -2482,9 +2509,9 @@
 function get_user_list()
 {
-  global $conf, $page;
+	global $conf, $page;
   
   $users = array();
 
-  // Search users depending expiration date with exclusion of Adult_Content generic users
+	// Search users depending expiration date with exclusion of Adult_Content generic users
   // ------------------------------------------------------------------------------------
   $query = '
@@ -2502,23 +2529,23 @@
 ;';
 
-  $result = pwg_query($query);
+	$result = pwg_query($query);
       
   while ($row = pwg_db_fetch_assoc($result))
   {
-    $user = $row;
+  	$user = $row;
     $user['groups'] = array();
 
     array_push($users, $user);
-  }
-
-  // Add groups list
+	}
+
+	// Add groups list
   // ---------------
   $user_ids = array();
   foreach ($users as $i => $user)
   {
-    $user_ids[$i] = $user['id'];
-  }
-
-  return $users;
+  	$user_ids[$i] = $user['id'];
+	}
+
+	return $users;
 }
 
@@ -2534,49 +2561,49 @@
 function expiration($id)
 {
-  global $conf, $page;
+	global $conf, $page;
           
-  // Get ConfirmMail configuration
+	// Get ConfirmMail configuration
   // -----------------------------
   $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
           
-  // Get UAM configuration
+	// Get UAM configuration
   // ---------------------
   $conf_UAM = unserialize($conf['UserAdvManager']);
-  
-  $query = "
+	
+	$query = "
 SELECT registration_date
   FROM ".USER_INFOS_TABLE."
 WHERE user_id = '".$id."'
 ;";
-  list($registration_date) = pwg_db_fetch_row(pwg_query($query));
+	list($registration_date) = pwg_db_fetch_row(pwg_query($query));
 
 //              Time limit process             
 // ********************************************  
-  if (!empty($registration_date))
-  {
-    // Dates formating and compare
+	if (!empty($registration_date))
+  {
+		// Dates formating and compare
     // ---------------------------
-    $today = date("d-m-Y"); // Get today's date
-    list($day, $month, $year) = explode('-', $today); // explode date of today             
-    $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
-      
-    list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
-    list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
-    $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
-      
-    $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps 
-    $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
-
-    // Condition with the value set for time limit
+		$today = date("d-m-Y"); // Get today's date
+		list($day, $month, $year) = explode('-', $today); // explode date of today						 
+ 		$daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
+	  	
+	  list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
+		list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
+		$regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
+			
+		$deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps	
+		$deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
+
+		// Condition with the value set for time limit
     // -------------------------------------------
-    if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
-    {
-      return false;
-    }
-    else
-    {
-      return true;
-    }
-  }
+		if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
+		{
+			return false;
+		}
+		else
+		{
+			return true;
+		}
+	}
 }
 
@@ -2618,9 +2645,9 @@
       // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase
       // ------------------------------------------------------------------------------
-      $points = $points + 1;
-
-      // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase
+		  $points = $points + 1;
+
+		  // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase
       // --------------------------------------------------------------------------
-      $point_lowercase = 1;
+		  $point_lowercase = 1;
     }
     else if ($letters>='A' && $letters <='Z')
@@ -2629,5 +2656,5 @@
       // ------------------------------------------------------------------------------
       $points = $points + 2;
-    
+		
       // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase
       // --------------------------------------------------------------------------
@@ -2639,5 +2666,5 @@
       // -------------------------------------------------------------------------
       $points = $points + 3;
-    
+		
       // On rajoute le bonus pour un chiffre - Adding bonus points for numbers
       // ---------------------------------------------------------------------
@@ -2649,5 +2676,5 @@
       // --------------------------------------------------------------------------------------------
       $points = $points + 5;
-    
+		
       // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters
       // ----------------------------------------------------------------------------------------
@@ -2748,48 +2775,17 @@
   global $conf;
 
-  // Get UAM configuration
-  // ---------------------
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-
-  // Check for user groups
   $query = '
-SELECT group_id
-  FROM '.USER_GROUP_TABLE.'
-WHERE user_id = '.$user_id.'
-  AND group_id = '.$conf_UAM[2].'
+SELECT UAM_validated
+FROM '.USERS_TABLE.'
+WHERE id='.$user_id.'
 ;';
 
-  $count1 = pwg_db_num_rows(pwg_query($query));
-
-  // Check for user status
-  $query = '
-SELECT status
-  FROM '.USER_INFOS_TABLE.'
-WHERE user_id = '.$user_id.'
-  AND status in (\''.$conf_UAM[7].'\')
-;';
-
-  $count2 = pwg_db_num_rows(pwg_query($query));
-
-  // Check for user privacy level
-  $query = '
-SELECT level
-  FROM '.USER_INFOS_TABLE.'
-WHERE user_id = '.$user_id.'
-  AND level = '.$conf_UAM[35].'
-;';
-
-  $count3 = pwg_db_num_rows(pwg_query($query));
-
-  $count = $count1 + $count2 + $count3; // Summary of counts
-
-  if ($count == 0)
-  {
-    return true; // User has validated his registration
-  }
-  else
-  {
-    return false; // User has not validated his registration
-  }
+  $result = pwg_db_fetch_assoc(pwg_query($query));
+
+  if($result['UAM_validated'] == 'true')
+  {
+    return true;
+  }
+  else return false;
 }
 
@@ -2855,5 +2851,5 @@
       else $pwdreset = l10n('UAM_PwdReset_NA');
       
-      $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] = $pwdreset; // Shows users password state in user_list
+		  $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] = $pwdreset; // Shows users password state in user_list
     }
   }
Index: /extensions/UserAdvManager/trunk/include/upgradedb.inc.php
===================================================================
--- /extensions/UserAdvManager/trunk/include/upgradedb.inc.php	(revision 17886)
+++ /extensions/UserAdvManager/trunk/include/upgradedb.inc.php	(revision 17887)
@@ -623,3 +623,70 @@
   conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
 }
+
+
+/* upgrade from 2.40.x to 2.41.0 */
+/* ***************************** */
+function upgrade_2400_2410()
+{
+  global $conf;
+  $conf_UAM = unserialize($conf['UserAdvManager']);
+  
+  // Piwigo's native tables modifications for validation status - Add UAM_validated column
+  // -------------------------------------------------------------------------------------
+  $query = '
+SHOW COLUMNS FROM '.USERS_TABLE.'
+LIKE "UAM_validated"
+;';
+  
+  $result = pwg_query($query);
+
+  if(!pwg_db_fetch_row($result))
+  {
+    $q = '
+ALTER TABLE '.USERS_TABLE.'
+ADD UAM_validated enum("true","false") 
+;';
+    pwg_query($q);
+  }
+
+  // Fill UAM_validated column with correct information for registered and validated  users
+  // --------------------------------------------------------------------------------------
+  $query = '
+SELECT DISTINCT u.id AS id
+FROM '.USERS_TABLE.' AS u
+  INNER JOIN '.USER_INFOS_TABLE.' AS ui
+    ON u.id = ui.user_id
+  LEFT JOIN '.USER_GROUP_TABLE.' AS ug
+    ON u.id = ug.user_id
+WHERE u.id <> 2';
+
+	if ($conf_UAM[3] <> '-1' and $conf_UAM[4] == '-1')
+  {
+    $query.= '
+  AND ug.group_id = \''.$conf_UAM[3]."'";
+  }
+  if ($conf_UAM[3] == '-1' and $conf_UAM[4] <> '-1')
+  {
+    $query.= '
+  AND ui.status = \''.$conf_UAM[4]."'";
+  }
+  if ($conf_UAM[3] <> '-1' and $conf_UAM[4] <> '-1')
+  {
+    $query.= '
+  AND ug.group_id = \''.$conf_UAM[3]."'";
+  }
+  $query.= ';';
+
+	$result = pwg_query($query);
+
+  while($row = mysql_fetch_array($result))
+  {
+    $query = '
+UPDATE '.USERS_TABLE.'
+SET UAM_validated=true
+WHERE id = "'.$row['id'].'"
+;';
+    pwg_query($query);
+  }
+}
 ?>
Index: /extensions/UserAdvManager/trunk/maintain.inc.php
===================================================================
--- /extensions/UserAdvManager/trunk/maintain.inc.php	(revision 17886)
+++ /extensions/UserAdvManager/trunk/maintain.inc.php	(revision 17887)
@@ -214,4 +214,22 @@
   }
 
+  // Piwigo's native tables modifications for validation status
+  // ----------------------------------------------------------
+  $query = '
+SHOW COLUMNS FROM '.USERS_TABLE.'
+LIKE "UAM_validated"
+;';
+  
+  $result = pwg_query($query);
+
+  if(!pwg_db_fetch_row($result))
+  {
+    $q = '
+ALTER TABLE '.USERS_TABLE.'
+ADD UAM_validated enum("true","false") 
+;';
+    pwg_query($q);
+  }
+
 /* *************************************************************************** */
 /* **************** END - Database actions and initialization **************** */
@@ -379,4 +397,11 @@
       upgrade_2300_2400();
     }
+
+    if (version_compare($conf['UserAdvManager_Version'], '2.41.0') < 0)
+    {
+    /* upgrade from version 2.40.x to 2.41.0 */
+    /* ************************************* */
+      upgrade_2400_2410();
+    }
   }
 
@@ -448,4 +473,10 @@
 ;';
   pwg_query($q);
+
+  $q = '
+ALTER TABLE '.USERS_TABLE.'
+DROP UAM_validated 
+;';
+  pwg_query($q);
 }
 ?>
