From cfc01c8f69bbc8bc05c9173b89d1d49ac792380d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sat, 19 Apr 2008 21:52:14 +0000
Subject: [PATCH] Update const in database with version of dolibarr.

---
 htdocs/install/etape5.php | 20 ++++++++++++++++----
 htdocs/install/inc.php    |  4 +++-
 htdocs/master.inc.php     |  4 ++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php
index 1fbb05a75e7..97bbe1c0295 100644
--- a/htdocs/install/etape5.php
+++ b/htdocs/install/etape5.php
@@ -27,6 +27,7 @@
 
 include_once("./inc.php");
 
+
 $setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
 $langs->setDefaultLang($setuplang);
 
@@ -152,9 +153,6 @@ if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
 	    
 	        if ($success)
 	        {
-				dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_ERR);
-	            $db->query("DELETE FROM llx_const WHERE name='MAIN_NOT_INSTALLED'");
-	        
 	            // Si install non Fran�ais, on configure pour fonctionner en mode internationnal
 	            if ($langs->defaultlang != "fr_FR")
 	            {
@@ -165,7 +163,13 @@ if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
 	                $db->query("UPDATE llx_const set value='eldy_frontoffice.php' WHERE name='MAIN_MENUFRONT_BARRELEFT';");
 	            }
 	
-	        }
+				dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const', LOG_ERR);
+	            $db->query("DELETE FROM llx_const WHERE name='MAIN_VERSION_LAST_INSTALL'");
+				$db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_VERSION_LAST_INSTALL','".DOL_VERSION."','chaine',0,'Dolibarr version for last install')");
+
+				dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_ERR);
+	            $db->query("DELETE FROM llx_const WHERE name='MAIN_NOT_INSTALLED'");
+			}
     	}
     	else
     	{
@@ -173,6 +177,14 @@ if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
     	}
     }
 
+	// If upgrade
+    if ($_POST["action"] == "upgrade")
+    {
+		dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const', LOG_ERR);
+	    $db->query("DELETE FROM llx_const WHERE name='MAIN_VERSION_LAST_UPGRADE'");
+		$db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_VERSION_LAST_UPGRADE','".DOL_VERSION."','chaine',0,'Dolibarr version for last upgrade')");
+	}
+	
     // May fail if parameter already defined
     $resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note) values('MAIN_LANG_DEFAULT','".$setuplang."','chaine',0,'Default language')");
 	
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index d491bd2645e..e5bfd231846 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -20,10 +20,12 @@
  */
 
 /**	    \file       htdocs/install/inc.php
-		\brief      Fichier include du programme d'installation
+		\brief      File that define environment for install pages
 		\version    $Id$
 */
 
+define('DOL_VERSION','2.4-dev');	// Also defined in master.inc.php
+
 require_once('../translate.class.php');
 require_once('../lib/functions.lib.php');
 require_once('../lib/admin.lib.php');
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 9a4a16cda15..6d260b9ae32 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -25,11 +25,11 @@
 
 /**
    \file       htdocs/master.inc.php
-   \brief      Prepare Dolibarr environment
+   \brief      File that define environment for install pages
    \version    $Id$
 */
 
-define('DOL_VERSION','2.4-dev');
+define('DOL_VERSION','2.4-dev');	// Also defined in inc.php
 define('EURO',chr(128)); 
 
 // La fonction clearstatcache ne doit pas etre appel�e de mani�re globale car ralenti.
-- 
GitLab