Browse Source

[svn r12641] fix lot of bugs in upgrade (mainly due to the fact that it is the first upgrade from dokeos 1.8)

Eric Marguin 17 năm trước cách đây
mục cha
commit
35224ff15e

+ 10 - 3
main/install/index.php

@@ -126,7 +126,9 @@ if($_POST['step2_install'] || $_POST['step2_update'])
 			{
 				$_POST['updatePath'].='/';
 			}
-
+			$_POST['step2']=1;
+			$badUpdatePath=false;
+			/* don't verify it to upgrade from 1.8.0 to 1.8.2
 			if(file_exists($_POST['updatePath']))
 			{
 				if(in_array(get_config_param('dokeos_version'),$update_from_version))
@@ -141,7 +143,7 @@ if($_POST['step2_install'] || $_POST['step2_update'])
 			else
 			{
 				$badUpdatePath=true;
-			}
+			}*/
 		}
 	}
 }
@@ -158,6 +160,11 @@ else
 	$updateFromConfigFile=$_GET['updateFromConfigFile'];
 }
 
+if($installType=='update')
+{
+	include_once('../inc/conf/configuration.php');
+}
+
 if(!isset($_GET['running']))
 {
 	$dbHostForm='localhost';
@@ -387,7 +394,7 @@ elseif($_POST['step4'])
 		if(!empty($tmp)) $institutionForm = $tmp;
 		$tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'InstitutionUrl');
 		if(!empty($tmp)) $institutionUrlForm = $tmp;
-		$urlForm = get_config_param('rootWeb');
+		$urlForm = $_configuration['root_web'];
 		$encryptPassForm = get_config_param('userPasswordCrypted');
 		$allowSelfReg = get_config_param('allowSelfReg');
 		$allowSelfRegProf = get_config_param('allowSelfRegProf');

+ 29 - 22
main/install/install_functions.inc.php

@@ -152,10 +152,6 @@ function get_config_param($param)
 		if(file_exists($updatePath.'main/inc/conf/configuration.php'))
 		{
 			$updateFromConfigFile='main/inc/conf/configuration.php';
-			if(file_exists($updatePath.'main/inc/installedVersion.inc.php'))
-			{
-				$updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
-			}
 		}
 		//give up recovering
 		else
@@ -163,6 +159,10 @@ function get_config_param($param)
 			error_log('Could not find config file in '.$updatePath.' in get_config_param()',0);
 			return null;
 		}
+	}	
+	if(file_exists($updatePath.'main/inc/installedVersion.inc.php'))
+	{
+		$updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
 	}
 	//look if we already have the queried param
 	if(is_array($configFile) && isset($configFile[$param]))
@@ -194,7 +194,7 @@ function get_config_param($param)
 
 					$enreg[0]=trim(str_replace('$','',$enreg[0]));
 					$enreg[1]=str_replace('\"','"',ereg_replace('(^"|"$)','',substr(trim($enreg[1]),0,-1)));
-
+					$enreg[1]=str_replace('\'','"',ereg_replace('(^\'|\'$)','',$enreg[1]));
 					if(strtolower($enreg[1]) == 'true')
 					{
 						$enreg[1]=1;
@@ -707,15 +707,17 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
 {
 	if($installType == 'update')
 	{
-		$dbHostForm=get_config_param('dbHost');
-		$dbUsernameForm=get_config_param('dbLogin');
-		$dbPassForm=get_config_param('dbPass');
-		$dbPrefixForm=get_config_param('dbNamePrefix');
-		$enableTrackingForm=get_config_param('is_trackingEnabled');
-		$singleDbForm=get_config_param('singleDbEnabled');
-		$dbNameForm=get_config_param('mainDbName');
-		$dbStatsForm=get_config_param('statsDbName');
-		$dbScormForm=get_config_param('scormDbName');
+		global $_configuration;
+		$dbHostForm=$_configuration['db_host'];
+		$dbUsernameForm=$_configuration['db_user'];
+		$dbPassForm=$_configuration['db_password'];
+		$dbPrefixForm=$_configuration['db_prefix'];
+		$enableTrackingForm=$_configuration['tracking_enabled'];
+		$singleDbForm=$_configuration['single_database'];
+		$dbNameForm=$_configuration['main_database'];
+		$dbStatsForm=$_configuration['statistics_database'];
+		$dbScormForm=$_configuration['scorm_database'];
+		$dbUserForm=$_configuration['user_personal_database'];
 
 		$dbScormExists=true;
 
@@ -732,14 +734,16 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
 				$dbScormExists=false;
 			}
 		}
-
-		if($singleDbForm)
-		{
-			$dbUserForm=$dbNameForm;
-		}
-		else
+		if(empty($dbUserForm))
 		{
-			$dbUserForm=$dbPrefixForm.'dokeos_user';
+			if($singleDbForm)
+			{
+				$dbUserForm=$dbNameForm;
+			}
+			else
+			{
+				$dbUserForm=$dbPrefixForm.'dokeos_user';
+			}
 		}
 		echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
 		echo get_lang("DBSettingUpgradeIntro");
@@ -924,7 +928,10 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	//Second parameter: Dokeos URL
 	echo "<tr>\n";
 	echo '<td>'.get_lang('DokeosURL').' (<font color="#cc0033">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
-	echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.htmlentities($urlForm).'" />'."</td>\n";
+	
+	if($installType == 'update') echo '<td>'.htmlentities($urlForm)."</td>\n";
+	else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.htmlentities($urlForm).'" />'."</td>\n";
+	
 	echo "</tr>\n";
 
 	//Parameter 3: administrator's email

+ 2 - 1
main/install/update-db-1.8.0-1.8.2.inc.php

@@ -58,7 +58,7 @@ if(function_exists('ini_set'))
 if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 {
 	//check if the current Dokeos install is elligible for update
-	if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile) || !in_array(get_config_param('clarolineVersion'), $update_from_version))
+	if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile))
 	{
 		echo '<b>'.get_lang('Error').' !</b> Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.<br><br>
 								'.get_lang('PleasGoBackToStep1').'.
@@ -177,6 +177,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql','stats');
+	
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list