Index: /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php	(revision 7954)
+++ /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php	(revision 7955)
@@ -16,8 +16,13 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 include_once (PHPWG_ROOT_PATH.'/include/constants.php');
-$my_base_url = get_admin_plugin_menu_link(__FILE__);
 
 load_language('plugin.lang', UAM_PATH);
 load_language('help/plugin.lang', UAM_PATH);
+
+
+// +-----------------------------------------------------------------------+
+// |                   Variables initialization                            |
+// +-----------------------------------------------------------------------+
+$my_base_url = get_admin_plugin_menu_link(__FILE__);
 
 $page['global'] = array();
@@ -28,4 +33,5 @@
 $UAM_Password_Test_Score = 0;
 $UAM_Exclusionlist_Error = false;
+
 
 // +-----------------------------------------------------------------------+
@@ -64,6 +70,4 @@
 // |            FCK Editor for email text fields              |
 // +----------------------------------------------------------+
-
-/* Available only for ConfirmMail return page customization */
 $toolbar = 'Basic';
 $width = '750px';
@@ -104,5 +108,5 @@
   {
 
-/* General configuration settings */
+    //General configuration settings
 		$_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text'])));
     
@@ -112,5 +116,5 @@
 
 
-/* Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them */
+    //Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them
     if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List']))
     {
@@ -154,5 +158,5 @@
 		pwg_query($query);
 
-/* Email confirmation settings */
+    //Email confirmation settings
     $_POST['UAM_ConfirmMail_ReMail_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt1'])));
 
@@ -187,5 +191,5 @@
 
 
-/* Testing password enforcement */
+  //Testing password enforcement
   if (isset($_POST['PasswordTest']) and !is_adviser() and isset($_POST['UAM_Password_Test']) and !empty($_POST['UAM_Password_Test']))
   {
@@ -199,10 +203,10 @@
   $conf_UAM = unserialize($conf['UserAdvManager']);
 
-/* Group setting for unvalidated and validated users */
+  //Group setting for unvalidated and validated users
   $groups[-1] = '---------';
   $No_Valid = -1;
   $Valid = -1;
 	
-/* Check groups list in database  */
+  //Check groups list in database 
   $query = '
 SELECT id, name
@@ -216,10 +220,10 @@
   {
     $groups[$row['id']] = $row['name'];
-/* configuration value for unvalidated users */
+    //configuration value for unvalidated users
     if (isset($conf_UAM[2]) and $conf_UAM[2] == $row['id'])
     {
 	  	$No_Valid = $row['id'];
 		}
-/* configuration value for validated users */
+    //configuration value for validated users
     if (isset($conf_UAM[3]) and $conf_UAM[3] == $row['id'])
 		{
@@ -228,5 +232,5 @@
   }
 	
-/* Template initialization for unvalidated users group */
+  //Template initialization for unvalidated users group
   $template->assign(
     'No_Confirm_Group',
@@ -236,5 +240,5 @@
 			)
  		);
-/* Template initialization for validated users group */
+  //Template initialization for validated users group
   $template->assign(
     'Validated_Group',
@@ -245,10 +249,10 @@
   	);
 	
-/* Status setting for unvalidated and validated users */
+  //Status setting for unvalidated and validated users
   $status_options[-1] = '------------';
   $No_Valid_Status = -1;
   $Valid_Status = -1;
 	
-/* Get status values */
+  //Get status values
   foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
   {
@@ -259,5 +263,5 @@
 	  }
 	  
-/* Template initialization for unvalidated users group */
+      //Template initialization for unvalidated users group
       $template->assign(
         'No_Confirm_Status',
@@ -269,5 +273,5 @@
   }
   
-/* Get status values */
+  //Get status values
   foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
   {
@@ -278,5 +282,5 @@
 		}
 		
-/* Template initialization for unvalidated users group */
+      //Template initialization for unvalidated users group
       $template->assign(
 	    'Confirm_Status',
@@ -288,10 +292,11 @@
 	}
 
-/* Save last opened paragraph in configuration tab */
+  //Save last opened paragraph in configuration tab
   $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:"";
   $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:"";
 
   $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
-  
+
+  // Template initialization for forms and data
   $template->assign(
     array(
@@ -352,5 +357,5 @@
 		$msg_error1 = '';
 		
-/* Username without forbidden keys */
+    //Username without forbidden keys
     if ( isset($conf_UAM[6]) and $conf_UAM[6] == 'true' )
 	  {
@@ -371,5 +376,5 @@
 		$msg_error2 = '';
 		
-/* Email without forbidden domain */
+    //Email without forbidden domain
     if ( isset($conf_UAM[11]) and $conf_UAM[11] == 'true' )
 	  {
@@ -464,33 +469,4 @@
 
 // +-----------------------------------------------------------------------+
-// |                           Template Init                               |
-// +-----------------------------------------------------------------------+
-		/*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
-
-    if (isset($_GET['start']) and is_numeric($_GET['start']))
-    {
-      $start = $_GET['start'];
-    }
-    else
-    {
-      $start = 0;
-    }*/
-
-// +-----------------------------------------------------------------------+
-// |                            navigation bar                             |
-// +-----------------------------------------------------------------------+
-
-/*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
-
-$navbar = create_navigation_bar(
-  $url,
-  count($page['filtered_users']),
-  $start,
-  $conf['users_page']
-  );
-
-$template->assign('navbar', $navbar);*/
-
-// +-----------------------------------------------------------------------+
 // |                               user list                               |
 // +-----------------------------------------------------------------------+
@@ -499,14 +475,4 @@
     foreach ($page['filtered_users'] as $num => $local_user)
     {
-// simulate LIMIT $start, $conf['users_page']
-			/*if ($num < $start)
-      {
-        continue;
-      }
-      if ($num >= $start + $conf['users_page'])
-      {
-        break;
-      }*/
-
       $visible_user_list[] = $local_user;
 		}
@@ -557,5 +523,5 @@
 			);
 		}
-    /* Plugin version inserted */
+    //Plugin version inserted
     $template->assign(
       array(
@@ -977,38 +943,9 @@
     }
 
-// +-----------------------------------------------------------------------+
-// |                           Template Init                               |
-// +-----------------------------------------------------------------------+
-		/*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
-
-    if (isset($_GET['start']) and is_numeric($_GET['start']))
-    {
-      $start = $_GET['start'];
-    }
-    else
-    {
-      $start = 0;
-    }*/
-
-/* Hide radio-button if not allow to assign adviser */
+    //Hide radio-button if not allow to assign adviser
 		if ($conf['allow_adviser'])
     	{
       	$template->assign('adviser', true);
     	}
-
-// +-----------------------------------------------------------------------+
-// |                            navigation bar                             |
-// +-----------------------------------------------------------------------+
-
-/*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
-
-$navbar = create_navigation_bar(
-  $url,
-  count($page['filtered_users']),
-  $start,
-  $conf['users_page']
-  );
-
-$template->assign('navbar', $navbar);*/
 
 // +-----------------------------------------------------------------------+
@@ -1022,14 +959,4 @@
     foreach ($page['filtered_users'] as $num => $local_user)
     {
-/* simulate LIMIT $start, $conf['users_page'] */
-			/*if ($num < $start)
-      {
-        continue;
-      }
-      if ($num >= $start + $conf['users_page'])
-      {
-        break;
-      }*/
-
       $visible_user_list[] = $local_user;
 		}
@@ -1124,5 +1051,5 @@
     } 
     
-    /* Plugin version inserted */
+    //Plugin version inserted
     $template->assign(
       array(
@@ -1357,5 +1284,5 @@
     if (isset($_POST['GhostTracker_Init']))
     {
-      /* Reset is only allowed for admins ! */
+      //Reset is only allowed for admins !
       if (is_admin() and !is_adviser())
       {
@@ -1426,19 +1353,5 @@
     }
 
-// +-----------------------------------------------------------------------+
-// |                           Template Init                               |
-// +-----------------------------------------------------------------------+
-		/*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
-
-    if (isset($_GET['start']) and is_numeric($_GET['start']))
-    {
-      $start = $_GET['start'];
-    }
-    else
-    {
-      $start = 0;
-    }*/
-
-/* Hide radio-button if not allow to assign adviser */
+    //Hide radio-button if not allow to assign adviser
 		if ($conf['allow_adviser'])
     {
@@ -1447,19 +1360,4 @@
 
 // +-----------------------------------------------------------------------+
-// |                            navigation bar                             |
-// +-----------------------------------------------------------------------+
-
-/*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
-
-$navbar = create_navigation_bar(
-  $url,
-  count($page['filtered_users']),
-  $start,
-  $conf['users_page']
-  );
-
-$template->assign('navbar', $navbar);*/
-
-// +-----------------------------------------------------------------------+
 // |                               user list                               |
 // +-----------------------------------------------------------------------+
@@ -1468,18 +1366,8 @@
     foreach ($page['filtered_users'] as $num => $local_user)
     {
-/* simulate LIMIT $start, $conf['users_page'] */
-			/*if ($num < $start)
-      {
-        continue;
-      }
-      if ($num >= $start + $conf['users_page'])
-      {
-        break;
-      }*/
-
       $visible_user_list[] = $local_user;
 		}
 
-/* Plugin version inserted */
+      //Plugin version inserted
       $template->assign(
         array(
Index: /extensions/NBC_UserAdvManager/trunk/changelog.txt.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/changelog.txt.php	(revision 7954)
+++ /extensions/NBC_UserAdvManager/trunk/changelog.txt.php	(revision 7955)
@@ -202,4 +202,6 @@
             Bug 1936 fixed - Bad home link in ConfirmMail page when gallery URL is not set
             small CSS improvement (thx to Gotcha)
+
+-- 2.15.9 : Bug 2010 fixed - No confirmation email when information email is not set
 */
 ?>
Index: /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php	(revision 7954)
+++ /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php	(revision 7955)
@@ -208,6 +208,6 @@
 }
 
-/* upgrade from branch 2.15.3 to 2.15.4 */
-/* ************************************ */
+/* upgrade from 2.15.3 to 2.15.4 */
+/* ***************************** */
 function upgrade_2153_2154()
 {
@@ -267,3 +267,47 @@
   pwg_query($query);
 }
+
+/* upgrade from 2.15.9 to 2.16.0 */
+/* ***************************** */
+function upgrade_2159_2160()
+{
+  global $conf;
+
+/* Upgrading options */
+  $query = '
+SELECT value
+  FROM '.CONFIG_TABLE.'
+WHERE param = "UserAdvManager"
+;';
+
+  $result = pwg_query($query);
+  $conf_UAM = pwg_db_fetch_assoc($result);
+    
+  $Newconf_UAM = unserialize($conf_UAM['value']);
+  
+  $Newconf_UAM[22] = 'false';
+  $Newconf_UAM[23] = 'false';
+  $Newconf_UAM[24] = 'false';
+  $Newconf_UAM[25] = 'Sorry, your account has been deleted due to a too long time passed since your last visit.';
+  $Newconf_UAM[26] = 'Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.';
+  
+  $update_conf = serialize($Newconf_UAM);
+    
+  $query = '
+      UPDATE '.CONFIG_TABLE.'
+			SET value="'.addslashes($update_conf).'"
+			WHERE param="UserAdvManager"
+			LIMIT 1
+		;';
+
+	pwg_query($query);
+
+  // Insert a new config entry for futur plugin's version check
+  $query = '
+INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
+VALUES ("UserAdvManager_Version","2.15.8","UAM version check")
+  ;';
+  
+  pwg_query($query);
+}
 ?>
Index: /extensions/NBC_UserAdvManager/trunk/main.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/main.inc.php	(revision 7954)
+++ /extensions/NBC_UserAdvManager/trunk/main.inc.php	(revision 7955)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: UserAdvManager
-Version: 2.15.9
+Version: 2.16.0-alpha
 Description: Renforcer la gestion des utilisateurs - Enforce users management
 Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216
@@ -26,457 +26,31 @@
 
 
-/* Plugin admin */
+// Plugin administration panel
 add_event_handler('get_admin_plugin_menu_links', 'UAM_admin_menu');
-
-function UAM_admin_menu($menu)
-{
-// +-----------------------------------------------------------------------+
-// |                      Getting plugin name                              |
-// +-----------------------------------------------------------------------+
-  $plugin =  PluginInfos(UAM_PATH);
-  $name = $plugin['name'];
-  
-  array_push($menu,
-    array(
-      'NAME' => $name,
-      'URL'  => get_admin_plugin_menu_link(UAM_PATH.'/admin/UAM_admin.php')
-    )
-  );
-
-  return $menu;
-}
 
 /* Lastvisit table feed for Ghost Tracker */
 add_event_handler('loc_begin_index', 'UAM_GhostTracker');
 
-function UAM_GhostTracker()
-{
-  global $conf, $user;
-
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-
-  /* Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker */
-  if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18")
-  {
-    if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true'))
-    {
-
-      $userid = get_userid($user['username']);
-     	  
-      /* Looking for existing entry in last visit table */
-      $query = '
-SELECT *
-  FROM '.USER_LASTVISIT_TABLE.'
-WHERE user_id = '.$userid.'
-;';
-        
-      $count = pwg_db_num_rows(pwg_query($query));
-         
-      if ($count == 0)
-      {
-        /* If not, data are inserted in table */
-        $query = '
-INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder)
-VALUES ('.$userid.', now(), "false")
-;';
-        pwg_query($query);
-      }
-      else if ($count > 0)
-      {
-        /* If yes, data are updated in table */
-        $query = '
-UPDATE '.USER_LASTVISIT_TABLE.'
-SET lastvisit = now(), reminder = "false"
-WHERE user_id = '.$userid.'
-LIMIT 1
-;';
-        pwg_query($query);
-      }
-    }
-  }
-}
-
-
-/* User creation */
+// User creation
 add_event_handler('register_user', 'UAM_Adduser');
 
-function UAM_Adduser($register_user)
-{
-  global $conf;
-
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-
-  // Exclusion of Adult_Content users
-  if ($register_user['username'] != "16" and $register_user['username'] != "18")
-  {
-    if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
-    {
-      /* This is to send an information email and set user to "waiting" group or status until admin validation */
-      $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
-      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
-      setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
-    }
-    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
-    {
-      /* This is to set user to "waiting" group or status until admin validation */
-      setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
-    }
-    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false'))
-    {
-      /* This is to send an information email without validation key */
-      $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
-      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
-    }
-    /* Sending registration confirmation by email */
-    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' or $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true'))
-    {
-      if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true')
-      {
-        $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
-        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 
-      }
-      elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false')
-      {
-        $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
-        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
-      }
-      elseif (!is_admin())
-      {
-        $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
-        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);
-      }
-    }
-  }
-}
-
-
-/* User deletion */
+// User deletion
 add_event_handler('delete_user', 'UAM_Deluser');
-
-function UAM_Deluser($user_id)
-{
-  /* Cleanup for ConfirmMail table */
-  DeleteConfirmMail($user_id);
-  /* Cleanup for LastVisit table */
-  DeleteLastVisit($user_id);
-  /* Cleanup Redirection settings */
-  DeleteRedir($user_id);
-}
-
 
 // Check users registration
 add_event_handler('register_user_check', 'UAM_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
 
-function UAM_RegistrationCheck($err, $user)
-{
-  global $errors, $conf;
-
-  // Exclusion of Adult_Content users
-  if ($user['username'] != "16" and $user['username'] != "18")
-  {
-// ***********************************************************
-// We need to reset the standard Piwigo's register controls   
-// because the call of register_user_check trigger resets them
-// ***********************************************************
-  // **********************************
-  // Standard Piwigo's username control
-  // **********************************
-    if ($_POST['login'] == '')
-    {
-      return l10n('reg_err_login1');
-    }
-    if (preg_match('/^.* $/', $_POST['login']))
-    {
-      return l10n('reg_err_login2');
-    }
-    if (preg_match('/^ .*$/', $_POST['login']))
-    {
-      return l10n('reg_err_login3');
-    }
-    if (get_userid($_POST['login']))
-    {
-      return l10n('reg_err_login5');
-    }
-  
-    if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') // not the same email variable if we are on users registration page or on admin's user registration page
-    {
-    // Email doblons check
-      $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
-      $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
-      $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
-  
-      if (!preg_match($regex, $_POST['email']))
-      {
-        return l10n('reg_err_mail_address');
-      }
-    
-      $query = '
-SELECT count(*)
-FROM '.USERS_TABLE.'
-WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['email'].'\')
-;';
-      list($count) = pwg_db_fetch_row(pwg_query($query));
-      if ($count != 0)
-      {
-        return l10n('reg_err_mail_address_dbl');
-      }
-    }
-
-    if (script_basename() == 'register') // not the same email variable if we are on users registration page or on admin's user registration page
-    {
-  // Email doblons check
-      $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
-      $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
-      $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
-  
-      if (!preg_match($regex, $_POST['mail_address']))
-      {
-        return l10n('reg_err_mail_address');
-      }
-    
-      $query = '
-SELECT count(*)
-FROM '.USERS_TABLE.'
-WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\')
-;';
-      list($count) = pwg_db_fetch_row(pwg_query($query));
-      if ($count != 0)
-      {
-        return l10n('reg_err_mail_address_dbl');
-      }
-    }
-// ******************************************
-// End of Piwigo's standard register controls
-// ******************************************
-
-
-// ******************************************
-// Here begins the advanced register controls
-// ******************************************
-    $PasswordCheck = 0;
-
-    $conf_UAM = unserialize($conf['UserAdvManager']);
-
-    // Password enforcement control
-    if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14]))
-    {
-      if (!empty($user['password']) and !is_admin())
-      {
-        $PasswordCheck = testpassword($user['password']);
-  
-        if ($PasswordCheck < $conf_UAM[14])
-        {
-          $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
-          return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]);
-        }
-      }
-      else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true')
-      {
-        $PasswordCheck = testpassword($user['password']);
-  
-        if ($PasswordCheck < $conf_UAM[14])
-        {
-          $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
-          return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]);
-        }
-      }
-    }
-
-    // Username without forbidden keys
-    if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())
-    {
-      $_POST['login'] = '';
-      return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'");
-    }
-
-    // Email without forbidden domains
-    if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())
-    {
-      $_POST['mail_address'] = '';
-      return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'");
-    }
-  }
-}
-
-
 if (script_basename() == 'profile')
 {
   add_event_handler('loc_begin_profile', 'UAM_Profile_Init');
-
-  function UAM_Profile_Init()
-  {
-    global $conf, $user, $template;
-
-    $conf_UAM = unserialize($conf['UserAdvManager']);
-    
-    if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
-    {
-      $user_idsOK = array();
-      if (!check_consult($user['id'], $user_idsOK))
-      {
-        $user_idsOK[] = $user['id'];
-        
-        $query = "
-          UPDATE ".CONFIG_TABLE."
-          SET value = \"".implode(',', $user_idsOK)."\"
-          WHERE param = 'UserAdvManager_Redir';";
-          
-        pwg_query($query);
-      }
-    }
-
-    if (isset($_POST['validate']) and !is_admin())
-    {
-      /* Email without forbidden domains */
-      if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']))
-      {
-        if (ValidateEmailProvider($_POST['mail_address']))
-        {
-          $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'");
-          unset($_POST['validate']);
-        }
-      }
-
-      $typemail = 3;
-      
-      if (!empty($_POST['use_new_pwd']))
-      {
-        $typemail = 2;
-        
-        /* Password enforcement control */
-        if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14]))
-        {
-          $PasswordCheck = testpassword($_POST['use_new_pwd']);
-         
-          if ($PasswordCheck < $conf_UAM[14])
-          {
-            $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
-            $template->append('errors', l10n_args($message).$conf_UAM[14]);
-            unset($_POST['use_new_pwd']);
-            unset($_POST['validate']);
-          }
-        }
-      }
-      
-      /* Sending registration confirmation by email */
-      if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
-      {
-        $confirm_mail_need = false;
-              
-        if (!empty($_POST['mail_address']))
-        {
-          $query = '
-SELECT '.$conf['user_fields']['email'].' AS email
-FROM '.USERS_TABLE.'
-WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
-;';
-          
-          list($current_email) = pwg_db_fetch_row(pwg_query($query));
-
-          /* This is to send a new validation key */
-          if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true'))
-        
-            $confirm_mail_need = true;
-
-          /* This is to set the user to "waiting" group or status until admin validation */
-          if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
-        
-            setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
-            $confirm_mail_need = false;
-        }
-        
-        if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need))
-        {
-          $query = '
-SELECT '.$conf['user_fields']['username'].'
-FROM '.USERS_TABLE.'
-WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
-;';
-        
-          list($username) = pwg_db_fetch_row(pwg_query($query));
-
-          SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need);
-        }
-      }
-    }
-  }
 }
 
-
-// RedirectToProfile - Thx to LucMorizur
-// redirects a visitor (except for admins, webmasters and generic statuses) to his
-// profile.php page
-//
-// no variable, no return
+// Redirection to profile page
 add_event_handler('login_success', 'RedirectToProfile');
 
-function RedirectToProfile()
-{
-  global $conf, $user;
-  
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-  
-  $query ='
-SELECT user_id, status
-FROM '.USER_INFOS_TABLE.'
-WHERE user_id = '.$user['id'].'
-;';
-  $data = pwg_db_fetch_assoc(pwg_query($query));
-  
-  if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic")
-  {
-    if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
-    {
-      $user_idsOK = array();
-      if (!check_consult($user['id'], $user_idsOK))
-        redirect(PHPWG_ROOT_PATH.'profile.php');
-    }
-  }
-}
+// *** Important ! This is necessary to make email exclusion work in admin's users management panel ***
+add_event_handler('init', 'UAM_InitPage');
 
-
-add_event_handler('init', 'UAM_InitPage');
-/* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */
-function UAM_InitPage()
-{
-  load_language('plugin.lang', UAM_PATH);
-  global $conf, $template, $page, $lang, $errors;
-
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-
-/* Admin user management */
-  if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list')
-  {
-    if (isset($_POST['submit_add']))
-    {
-      /* Email without forbidden domains */
-      if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))
-      {
-        $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'");
-        unset($_POST['submit_add']);
-      }
-    }
-  }
-}
-
-
+// Comment without author
 add_event_handler('user_comment_check', 'UAM_CheckEmptyCommentAuthor', 50, 2);
-
-function UAM_CheckEmptyCommentAuthor($comment_action, $comm)
-{
-  load_language('plugin.lang', UAM_PATH);
-  global $infos, $conf, $template;
-
-  $conf_UAM = unserialize($conf['UserAdvManager']);
-
-/* User creation OR update */
-  if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')
-  {
-    $comment_action = 'reject';
-
-    array_push($infos, l10n('UAM_Empty Author'));
-  }
-
-  return $comment_action;
-}
 ?>
Index: /extensions/NBC_UserAdvManager/trunk/maintain.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/maintain.inc.php	(revision 7954)
+++ /extensions/NBC_UserAdvManager/trunk/maintain.inc.php	(revision 7955)
@@ -180,4 +180,17 @@
   }
 
+
+	$query = '
+SELECT param
+  FROM '.CONFIG_TABLE.'
+WHERE param = "UserAdvManager_Version"
+;';
+  $count = pwg_db_num_rows(pwg_query($query));
+  
+  if ($count == 0)
+  {
+    upgrade_2159_2160();
+  }
+
 load_conf_from_db('param like \'UserAdvManager\\_%\'');
 }
