diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index eead7b5bd61..3c57d170030 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -50,9 +50,11 @@ print ''.$langs->trans("Version").''.$langs $var=!$var; print "".$langs->trans("VersionLastInstall")."".$conf->global->MAIN_VERSION_LAST_INSTALL."\n"; $var=!$var; -print "".$langs->trans("VersionProgram")."".DOL_VERSION."\n"; -$var=!$var; print "".$langs->trans("VersionLastUpgrade")."".$conf->global->MAIN_VERSION_LAST_UPGRADE; +print "\n"; +$var=!$var; +print "".$langs->trans("VersionProgram")."".DOL_VERSION; +// If current version differs from last upgrade if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print "\n"; print ''; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index a78251aff32..f8c4cae085a 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -246,40 +246,12 @@ else $allowinstall=1; } print "
\n"; - print "
\n"; // Si prerequis ok, on affiche le bouton pour passer à l'étape suivante if ($checksok) { $ok=0; - print $langs->trans("ChooseYourSetupMode"); - - print ''; - - print ''; - print ''; - print ''."\n"; - - $migrationscript=array(array('from'=>'2.0.0', 'to'=>'2.1.0'), - array('from'=>'2.1.0', 'to'=>'2.2.0'), - array('from'=>'2.2.0', 'to'=>'2.4.0'), - array('from'=>'2.4.0', 'to'=>'2.5.0'), - array('from'=>'2.5.0', 'to'=>'2.6.0'), - array('from'=>'2.6.0', 'to'=>'2.7.0') - ); - - // Try to create db connexion if (file_exists($conffile)) { @@ -303,7 +275,6 @@ else } } - # If a database access is available, we set more variable if ($ok) { @@ -315,11 +286,53 @@ else $conf->setValues($db); // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrcurrentversionarray=split('[\.-]',$conf->global->MAIN_VERSION_LAST_UPGRADE); + $dolibarrlastupgradeversionarray=split('[\.-]',$conf->global->MAIN_VERSION_LAST_UPGRADE); $dolibarrversiontoinstallarray=versiondolibarrarray(); } + # Show title + if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) + { + print $langs->trans("VersionLastUpgrade").": ".$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'; + print $langs->trans("VersionProgram").": ".DOL_VERSION; + //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); + print '
'; + print '
'; + } + else print "
\n"; + + print $langs->trans("ChooseYourSetupMode"); + + print '
'.$langs->trans("FreshInstall").''; - print $langs->trans("FreshInstallDesc").''; - if ($allowinstall) - { - print ''.$langs->trans("Start").''; - } - else - { - print $langs->trans("InstallNotAllowed"); - } - print '
'; + + + # Sho first install line + print ''; + print ''; + print ''; + print ''."\n"; + + # Show upgrade lines + $allowupgrade=true; + $migrationscript=array( //array('from'=>'2.0.0', 'to'=>'2.1.0'), + //array('from'=>'2.1.0', 'to'=>'2.2.0'), + array('from'=>'2.2.0', 'to'=>'2.4.0'), + array('from'=>'2.4.0', 'to'=>'2.5.0'), + array('from'=>'2.5.0', 'to'=>'2.6.0'), + array('from'=>'2.6.0', 'to'=>'2.7.0') + ); + $foundrecommandedchoice=0; foreach ($migrationscript as $migarray) { @@ -327,19 +340,29 @@ else $versionto=$migarray['to']; $newversionfrom=eregi_replace('\.[0-9]+$','.*',$versionfrom); $newversionto=eregi_replace('\.[0-9]+$','.*',$versionto); - print ''; + print ''; print ''; diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 5556974def7..f0ed7c87c74 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -129,6 +129,7 @@ FieldRenamed=Field renamed IfLoginDoesNotExistsCheckCreateUser=If login does not exists yet, you must check option "Create user" ErrorConnection=Server "%s", database name "%s", login "%s", or database password may be wrong or PHP client version may be too old compared to database version. InstallChoiceRecommanded=Recommanded choice to install version %s from your current version %s +InstallChoiceSuggested=Install choice suggested by installer. ######### # upgrade diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang index c1af88470fb..4038d539701 100644 --- a/htdocs/langs/fr_FR/install.lang +++ b/htdocs/langs/fr_FR/install.lang @@ -129,6 +129,7 @@ FieldRenamed=Champ renommĂ© IfLoginDoesNotExistsCheckCreateUser=Si le login n'existe pas encore, vous devez cocher l'option "CrĂ©er l'utilisateur" ErrorConnection=Le serveur "%s", nom de base "%s", login "%s", ou mot de passe de la base de donnĂ©e est peut-ĂȘtre incorrect ou la version du client PHP trop ancienne par rapport Ă  la version de la base de donnĂ©e. InstallChoiceRecommanded=Choix recommandĂ© pour installer la version %s depuis votre version actuelle %s +InstallChoiceSuggested=Choix suggĂ©rĂ© par l'installeur. ######### # upgrade diff --git a/htdocs/lib/admin.lib.php b/htdocs/lib/admin.lib.php index 555b8e95c60..d4e43a6ab3d 100644 --- a/htdocs/lib/admin.lib.php +++ b/htdocs/lib/admin.lib.php @@ -40,22 +40,24 @@ function versiontostring($versionarray) } /** - \brief Compare 2 versions - \param versionarray1 Tableau de version (vermajeur,vermineur,autre) - \param versionarray2 Tableau de version (vermajeur,vermineur,autre) - \return int <0 si versionarray10 si versionarray1>versionarray2 + * \brief Compare 2 versions + * \param versionarray1 Array of version (vermajor,verminor,patch) + * \param versionarray2 Array of version (vermajor,verminor,patch) + * \return int -3,-2,-1 if versionarray1versionarray2 (value depends on level of difference) */ function versioncompare($versionarray1,$versionarray2) { $ret=0; - $i=0; - while ($i < max(sizeof($versionarray1),sizeof($versionarray1))) + $level=0; + while ($level < max(sizeof($versionarray1),sizeof($versionarray1))) { - $operande1=isset($versionarray1[$i])?$versionarray1[$i]:0; - $operande2=isset($versionarray2[$i])?$versionarray2[$i]:0; - if ($operande1 < $operande2) { $ret = -1; break; } - if ($operande1 > $operande2) { $ret = 1; break; } - $i++; + $operande1=isset($versionarray1[$level])?$versionarray1[$level]:0; + $operande2=isset($versionarray2[$level])?$versionarray2[$level]:0; + $level++; + if ($operande1 < $operande2) { $ret = -$level; break; } + if ($operande1 > $operande2) { $ret = $level; break; } } return $ret; } @@ -217,7 +219,7 @@ function run_sql($sqlfile,$silent=1) $newsql=str_replace($from,$to,$newsql); dol_syslog('Admin.lib::run_sql New Request '.($i+1).' sql='.$newsql, LOG_DEBUG); } - + // Replace __ENTITY__ with current entity id while (eregi('(__ENTITY__)',$newsql,$reg)) {
'.$langs->trans("FreshInstall").''; + print $langs->trans("FreshInstallDesc").''; + if ($allowinstall) + { + print ''.$langs->trans("Start").''; + } + else + { + print $langs->trans("InstallNotAllowed"); + } + print '
'.$langs->trans("Upgrade").' '.$newversionfrom.' -> '.$newversionto.'
'.$langs->trans("Upgrade").'
'.$newversionfrom.' -> '.$newversionto.'
'; print $langs->trans("UpgradeDesc"); - if ($ok && sizeof($dolibarrcurrentversionarray) > 0) // If a database access is available and a version already available + if ($ok) { - $dolibarrversionfromarray=split('[\.-]',$versionfrom); - $dolibarrversiontoarray=split('[\.-]',$versionto); - if (empty($foundrecommandedchoice) && versioncompare($dolibarrversiontoarray,$dolibarrcurrentversionarray) >= 0) + if (sizeof($dolibarrlastupgradeversionarray) >= 2) // If a database access is available and a version x.y already available { - print '
'; - print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); - // Ok '; - $foundrecommandedchoice=1; // To show only once + $dolibarrversionfromarray=split('[\.-]',$versionfrom); + $dolibarrversiontoarray=split('[\.-]',$versionto); + // If last upgrade was an alpha or beta, we increase target version to 1 to select this one. + if (isset($conf->global->MAIN_VERSION_LAST_UPGRADE) && eregi('beta|alpha',$conf->global->MAIN_VERSION_LAST_UPGRADE)) $dolibarrversiontoarray[2]=(isset($dolibarrversiontoarray[2]) ? ($dolibarrversiontoarray[2]+1) : 1); + // Now we check if this is the first qualified choice + if (empty($foundrecommandedchoice) && versioncompare($dolibarrversiontoarray,$dolibarrlastupgradeversionarray) > 0) + { + print '
'; + //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); + print '
'.$langs->trans("InstallChoiceSuggested").'
'; + // Ok '; + $foundrecommandedchoice=1; // To show only once + } + } + else { + // We can not recommand a choice. } } print '