Index: /extensions/HistoryIPExcluder/trunk/include/dbupgrade.inc.php
===================================================================
--- /extensions/HistoryIPExcluder/trunk/include/dbupgrade.inc.php	(revision 10045)
+++ /extensions/HistoryIPExcluder/trunk/include/dbupgrade.inc.php	(revision 10045)
@@ -0,0 +1,108 @@
+<?php
+
+/* Database upgrading functions */
+
+// This wil update only current plugin version number in database
+function global_version_update()
+{
+  global $conf;
+  
+  // Get current plugin version
+  $plugin =  HIPE_infos(HIPE_PATH);
+  $version = $plugin['version'];
+
+// Update plugin version
+  $query = '
+SELECT value
+  FROM '.CONFIG_TABLE.'
+WHERE param = "HistoryIPConfig"
+;';
+  $result = pwg_query($query);
+  
+  $conf_HIPE = pwg_db_fetch_assoc($result);
+    
+  $Newconf_HIPE = unserialize($conf_HIPE['value']);
+  
+  $Newconf_HIPE['Version'] = $version;
+  
+  $update_conf = serialize($Newconf_HIPE);
+
+  $query = '
+UPDATE '.CONFIG_TABLE.'
+SET value="'.addslashes($update_conf).'"
+WHERE param="HistoryIPConfig"
+LIMIT 1
+;';
+
+	pwg_query($query);
+}
+
+
+function upgrade_200()
+{
+  global $conf;
+  
+  $q = '
+UPDATE '.CONFIG_TABLE.'
+SET param = "HistoryIPExcluder"
+WHERE param = "nbc_HistoryIPExcluder"
+;';
+  pwg_query($q);
+
+  $q = '
+UPDATE '.CONFIG_TABLE.'
+SET comment = "History IP Excluder parameters"
+WHERE comment = "Parametres nbc History IP Excluder"
+;';
+  pwg_query($q);
+
+  upgrade_210();
+}
+
+function upgrade_210()
+{
+  global $conf;
+  
+  $default = array (
+    'Blacklist' => "0",
+    'Version'=> "2.1.1",
+  );
+
+  $q = '
+INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
+VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
+';
+      
+  pwg_query($q);
+  
+  upgrade_211();
+}
+
+function upgrade_211()
+{
+  global $conf;
+
+  // Create new HIPE entry in plugins table 
+  $query = '
+INSERT INTO '.PLUGINS_TABLE.' (id, state, version)
+VALUES ("HistoryIPExcluder","active","2.2.0")
+;';
+  
+  pwg_query($query);
+
+  // Delete old plugin entry in plugins table 
+  $query = '
+DELETE FROM '.PLUGINS_TABLE.'
+WHERE id="nbc_HistoryIPExcluder"
+LIMIT 1
+;';
+  
+  pwg_query($query);
+
+  // rename directory
+  if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder'))
+  {
+    die('Fatal error on plugin upgrade process : Unable to rename directory ! Please, rename manualy the plugin directory name from ../plugins/nbc_HistoryIPExcluder to ../plugins/HistoryIPExcluder.');
+  }
+}
+?>
Index: /extensions/HistoryIPExcluder/trunk/main.inc.php
===================================================================
--- /extensions/HistoryIPExcluder/trunk/main.inc.php	(revision 10044)
+++ /extensions/HistoryIPExcluder/trunk/main.inc.php	(revision 10045)
@@ -2,6 +2,6 @@
 /*
 Plugin Name: History IP Excluder
-Version: 2.2.2
-Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l'historique et de les blacklister à l'inscription - Base MySql seulement! / Excludes one IP or a range of IP from the history and to blacklist them on registration - MySql database only!
+Version: 2.2.3
+Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l'historique et de les blacklister à l'inscription / Excludes one IP or a range of IP from the history and to blacklist them on registration
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=147
 Author: Nicco, Eric
@@ -30,4 +30,6 @@
 
 2.2.2             - Another bug fixed on plugin upgrade from 2.2.x version
+
+2.2.3             - Improved update mechanism. When no structural update of database is necessary, it sets the correct version number in plugin's configuration
 
 --------------------------------------------------------------------------------
Index: /extensions/HistoryIPExcluder/trunk/maintain.inc.php
===================================================================
--- /extensions/HistoryIPExcluder/trunk/maintain.inc.php	(revision 10044)
+++ /extensions/HistoryIPExcluder/trunk/maintain.inc.php	(revision 10045)
@@ -60,4 +60,6 @@
   global $conf;
   
+  include_once (HIPE_PATH.'include/dbupgrade.inc.php');
+  
 /* Check for upgrade from 2.0.0 to 2.0.1 */
 /* *************************************** */
@@ -98,11 +100,7 @@
   }
 
-  /* upgrade from version 2.2.0 to 2.2.1 */
-  /* *********************************** */
-  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
-  if ($HIPE_Config['Version'] == '2.2.0')
-  {
-    upgrade_220();
-  }
+  /* Global version number upgrade */
+  /* ***************************** */
+  global_version_update();
 }
 
@@ -131,126 +129,3 @@
   }  
 }
-
-
-function upgrade_200()
-{
-  global $conf;
-  
-  $q = '
-UPDATE '.CONFIG_TABLE.'
-SET param = "HistoryIPExcluder"
-WHERE param = "nbc_HistoryIPExcluder"
-;';
-  pwg_query($q);
-
-  $q = '
-UPDATE '.CONFIG_TABLE.'
-SET comment = "History IP Excluder parameters"
-WHERE comment = "Parametres nbc History IP Excluder"
-;';
-  pwg_query($q);
-
-  upgrade_210();
-}
-
-function upgrade_210()
-{
-  global $conf;
-  
-  $default = array (
-    'Blacklist' => "0",
-    'Version'=> "2.1.1",
-  );
-
-  $q = '
-INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
-VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
-';
-      
-  pwg_query($q);
-}
-
-function upgrade_211()
-{
-  global $conf;
-
-// Update plugin version
-  $query = '
-SELECT value
-  FROM '.CONFIG_TABLE.'
-WHERE param = "HistoryIPConfig"
-;';
-  $result = pwg_query($query);
-  
-  $conf_HIPE = pwg_db_fetch_assoc($result);
-    
-  $Newconf_HIPE = unserialize($conf_HIPE['value']);
-  
-  $Newconf_HIPE['Version'] = '2.2.0';
-  
-  $update_conf = serialize($Newconf_HIPE);
-
-  $query = '
-UPDATE '.CONFIG_TABLE.'
-SET value="'.addslashes($update_conf).'"
-WHERE param="HistoryIPConfig"
-LIMIT 1
-;';
-
-	pwg_query($query);
-
-  // Create new HIPE entry in plugins table 
-  $query = '
-INSERT INTO '.PLUGINS_TABLE.' (id, state, version)
-VALUES ("HistoryIPExcluder","active","2.2.0")
-;';
-  
-  pwg_query($query);
-
-  // Delete old plugin entry in plugins table 
-  $query = '
-DELETE FROM '.PLUGINS_TABLE.'
-WHERE id="nbc_HistoryIPExcluder"
-LIMIT 1
-;';
-  
-  pwg_query($query);
-
-  // rename directory
-  if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder'))
-  {
-    die('Fatal error on plugin upgrade process : Unable to rename directory ! Please, rename manualy the plugin directory name from ../plugins/nbc_HistoryIPExcluder to ../plugins/HistoryIPExcluder.');
-  }
-}
-
-
-function upgrade_220()
-{
-  global $conf;
-
-// Update plugin version
-  $query = '
-SELECT value
-  FROM '.CONFIG_TABLE.'
-WHERE param = "HistoryIPConfig"
-;';
-  $result = pwg_query($query);
-  
-  $conf_HIPE = pwg_db_fetch_assoc($result);
-    
-  $Newconf_HIPE = unserialize($conf_HIPE['value']);
-  
-  $Newconf_HIPE['Version'] = '2.2.1';
-  
-  $update_conf = serialize($Newconf_HIPE);
-
-  $query = '
-UPDATE '.CONFIG_TABLE.'
-SET value="'.addslashes($update_conf).'"
-WHERE param="HistoryIPConfig"
-LIMIT 1
-;';
-
-	pwg_query($query);
-}
 ?>
