[Vtigercrm-commits] [vtiger-commits] r6510 - in /vtigercrm/trunk/modules/Migration: Migration.php MigrationCheck.php MigrationStep1.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri May 26 20:26:50 EDT 2006


Author: saraj
Date: Fri May 26 18:26:46 2006
New Revision: 6510

Log:
* Modified to handle the migration in a single screen and the functionality has been changed

Modified:
    vtigercrm/trunk/modules/Migration/Migration.php
    vtigercrm/trunk/modules/Migration/MigrationCheck.php
    vtigercrm/trunk/modules/Migration/MigrationStep1.php

Modified: vtigercrm/trunk/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/Migration.php (original)
+++ vtigercrm/trunk/modules/Migration/Migration.php Fri May 26 18:26:46 2006
@@ -63,7 +63,7 @@
 
 	function takeDatabaseDump($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname)
 	{
-		$this->conn->println("Inside the function taleDatabaseDump. Going to take the old database dump...");
+		$this->conn->println("Inside the function takeDatabaseDump. Going to take the old database dump...");
 		$dump_filename = 'dump_'.$dbname.'.txt';
 
 		if($mysql_password != '')
@@ -99,7 +99,7 @@
 			exec("echo 'set FOREIGN_KEY_CHECKS = 1;' >> ".$dump_filename);
 		}
 
-		echo '<br> <b>'.$dbname.'</b> Database Dump has been taken and the file is ==> '.$dump_filename;
+		$_SESSION['migration_log'] .= '<br> <b>'.$dbname.'</b> Database Dump has been taken and the file is ==> '.$dump_filename;
 
 		return $dump_filename;
 	}
@@ -110,7 +110,7 @@
 		$sql = "drop database ".$dbname;
 		$conn->query($sql);
 
-		echo '<br> <b>'.$dbname.'</b> Database has been dropped.';
+		$_SESSION['migration_log'] .= '<br> <b>'.$dbname.'</b> Database has been dropped.';
 	}
 	function createDatabase($conn,$dbname)
 	{
@@ -118,7 +118,7 @@
 		$sql = "create database ".$dbname;
 		$conn->query($sql);
 
-		echo '<br> <b>'.$dbname.'</b> Database has been created.';
+		$_SESSION['migration_log'] .= '<br> <b>'.$dbname.'</b> Database has been created.';
 
 		//Added to avoid the No Database Selected error when execute the queries
 		$conn->connect();
@@ -126,7 +126,8 @@
 
 	function applyDumpData($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname,$dumpfile)
 	{
-		$this->conn->println("Inside the function appluDumpData.");
+		$this->conn->println("Inside the function applyDumpData.");
+		$this->conn->println("hostname=$host_name&port=$mysql_port&username=$mysql_username&password=$mysql_password& dump file = $dumpfile");
 		if($mysql_password != '')
 		{
 			$password_str = " --password=".$mysql_password;
@@ -155,7 +156,7 @@
 			exec("mysql --user=".$mysql_username." -h ".$host_name." --force --port=".$mysql_port.$password_str." ".$dbname." < ".$dumpfile);
 		}
 
-		echo '<br> Database Dump has been applied to the <b>'.$dbname.'</b> Database from <b>'.$dumpfile.'</b>';
+		$_SESSION['migration_log'] .= '<br> Database Dump has been applied to the <b>'.$dbname.'</b> Database from <b>'.$dumpfile.'</b>';
 	}
 
 
@@ -193,9 +194,10 @@
 	function modifyDatabase($conn)
 	{
 		$this->conn->println("Inside the function modifyDatabase");
-		echo '<br><br>Note : Please note that for each query the "Object" string will be displayed at the starting of the line if the query executed successfully. If the query fails then "Object" will not be displayed. we can find out the failed queries based on these Object display.';
 		$conn->println("\n\n\nMickie ---- Starts");
 
+		$_SESSION['migration_log'] .= "<br>The current database is going to be modified by executing the following queries...<br>";
+		
 		//Added variables to get the queries list and count
 		$query_count = 1;
 		$success_query_count = 1;
@@ -206,22 +208,30 @@
 		//To handle the file includes for each and every version
 		//Here we have to decide which files should be included, where the files will be added newly for every public release
 		//Handle Here -- Mickie
-		include("ModifyDatabase/42P2_to_50Alpha.php");
+		include("modules/Migration/ModifyDatabase/MigrationInfo.php");
 
 		$conn->println("Mickie ---- Ends\n\n\n");
 	}
 
-	function migrate($same_databases)
-	{
-		//Migration Procedure
+	function migrate($same_databases, $option, $old_dump_file_name='')
+	{
+		//1. Migration Procedure -- when we give the Source Database values
 		//Step : 1 => Take a dump of old database
 		//Step : 2 => Drop the New Database
 		//Step : 3 => Create the New Database
 		//Step : 4 => Put the old dump into the New Database
 		//Step : 5 => Modify the new database with the new changes
 
+		//2. Migration Procedure -- when we give the Database dump file
+		//Step : 1 => Drop the New Database
+		//Step : 2 => Create the New Database
+		//Step : 3 => Put the dump into the New Database
+		//Step : 4 => Modify the new database with the new changes
+
+
 		global $conn;
 		$this->conn->println("Database Migration from Old Database to the Current Database Starts.");
+		$this->conn->println("Migration Option = $option");
 
 		//Set the old database parameters
 		$old_host_name = $this->old_hostname;
@@ -237,11 +247,17 @@
 		$new_mysql_password = $this->new_mysql_password;
 		$new_dbname = $this->new_dbname;
 
-
-
-		//Take the dump of the old Database
-		$this->conn->println("Going to take the old Database Dump.");
-		$dump_file = $this->takeDatabaseDump($old_host_name,$old_mysql_port,$old_mysql_username,$old_mysql_password,$old_dbname);
+		//This will be done when we give the Source Database details
+		if($option == 'dbsource')
+		{
+			//Take the dump of the old Database
+			$this->conn->println("Going to take the old Database Dump.");
+			$dump_file = $this->takeDatabaseDump($old_host_name,$old_mysql_port,$old_mysql_username,$old_mysql_password,$old_dbname);
+		}
+		elseif($option == 'dumpsource')
+		{
+			$dump_file = $old_dump_file_name;
+		}
 
 		//if old db and new db are different then take new db dump
 		if($old_dbname != $new_dbname)
@@ -255,11 +271,11 @@
 		$continue_process = 1;
 		if($same_databases == 1)
 		{
-			echo '<br> Same databases are used. so skip the process of drop and crate the current database.';
-		}
-		else
-		{
-			echo '<br> Databases are different. So drop the Current Database and create. Also apply the dump of Old Database';
+			$_SESSION['migration_log'] .= '<br> Same databases are used. so skip the process of drop and create the current database.';
+		}
+		else
+		{
+			$_SESSION['migration_log'] .= '<br> Databases are different. So drop the Current Database and create. Also apply the dump of Old Database';
 			//Drop the current(latest) Database
 			$this->conn->println("Going to Drop the current Database");
 			$this->dropDatabase($conn,$new_dbname);
@@ -279,17 +295,17 @@
 			$old_tables_count = $this->getTablesCountInOldDatabase();
 
 			//if tables are missing after apply the dump, then alert the user and quit
-			if($new_tables_count != $old_tables_count)
+			if(($new_tables_count != $old_tables_count && $option == 'dbsource') || ($new_tables_count < 180 && $option == 'dumpsource'))
 			{
 				$this->conn->println("New Database tables not equal to Old Database tables count. Reload the current database again and quit.");
 				
 				$continue_process = 0;
 				$msg = "The dump may not be applied correctly. Tables exist in 4.2.3 database : $old_tables_count. Tables exist in current database after apply the dump : $new_tables_count";
-			?>
+			   ?>
 				<script language="javascript">
 					alert("<?php echo $msg; ?>");
 				</script>
-			<?php
+			   <?php
 			}
 		}
 
@@ -305,6 +321,7 @@
 		else
 		{
 			//Drop the current(latest) Database
+			$this->conn->println("Going to Restore the current Database");
 			$this->conn->println("Going to Drop the current Database");
 			$this->dropDatabase($conn,$new_dbname);
 
@@ -315,6 +332,10 @@
 			//Reload the new db dump and quit
 			$this->conn->println("Going to apply the new backup db dump");
 			$this->applyDumpData($new_host_name,$new_mysql_port,$new_mysql_username,$new_mysql_password,$new_dbname,$new_dump_file);
+
+			//Return to Step1
+			echo '<br><font color="red"><b>Dump could not be applied correctly. so your previous database restored.</b></font>';
+			include("modules/Migration/MigrationStep1.php");
 		}
 	}
 

Modified: vtigercrm/trunk/modules/Migration/MigrationCheck.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/MigrationCheck.php (original)
+++ vtigercrm/trunk/modules/Migration/MigrationCheck.php Fri May 26 18:26:46 2006
@@ -9,17 +9,9 @@
  *
  ********************************************************************************/
 
+
 include("config.inc.php");
-
-$old_version = $_REQUEST['old_version'];
-$latest_version = $_REQUEST['latest_version'];
-
-//old database values
-$old_host_name = $_REQUEST['old_host_name'];
-$old_mysql_port = $_REQUEST['old_port_no'];
-$old_mysql_username = $_REQUEST['old_mysql_username'];
-$old_mysql_password = $_REQUEST['old_mysql_password'];
-$old_dbname = $_REQUEST['old_dbname'];
+$migration_log = '';
 
 //new database values get from the current vtigerCRM's config.php
 global $dbconfig;
@@ -29,142 +21,208 @@
 $new_dbname = $dbconfig['db_name'];
 
 
-//make a connection with the old database
-$oldconn = @mysql_connect($old_host_name.":".$old_mysql_port,$old_mysql_username,$old_mysql_password);
-
-//make a connection with the new database
-$newconn = @mysql_connect($new_host_name,$new_mysql_username,$new_mysql_password);
-
-if(!$oldconn)
+include("modules/Migration/Migration.php");
+if($_REQUEST['migration_option'] == 'db_details')
 {
-	echo '<br><br><br>  Source Database Server cannot be connected';
-	$continue1 = 0;
+	//Source MySQL database details have been given. 
+	//old database values
+	$old_host_name = $_REQUEST['old_host_name'];
+	$old_mysql_port = $_REQUEST['old_port_no'];
+	$old_mysql_username = $_REQUEST['old_mysql_username'];
+	$old_mysql_password = $_REQUEST['old_mysql_password'];
+	$old_dbname = $_REQUEST['old_dbname'];
+
+	//make a connection with the old database
+	$oldconn = @mysql_connect($old_host_name.":".$old_mysql_port,$old_mysql_username,$old_mysql_password);
+
+	//make a connection with the new database
+	$newconn = @mysql_connect($new_host_name,$new_mysql_username,$new_mysql_password);
+
+	if(!$oldconn)
+	{
+		echo '<br>  Source Database Server cannot be connected';
+		$continue1 = 0;
+	}
+	elseif(!$newconn)
+	{
+		echo '<br>  Current working Database Server cannot be connected';
+		$continue1 = 0;
+	}
+	else
+	{
+		$migration_log .= ' Database Servers can be connected. Can proceed with migration';
+		$continue1 = 1;
+	}
+
+	if($continue1 == 1)
+	{
+		//check whether the specified databases are exist or not
+		$olddb_exist = @mysql_select_db($old_dbname,$oldconn);
+		//$newdb_exist = @mysql_select_db($new_dbname,$oldconn);
+		if(!$olddb_exist)
+		{
+			echo '<br> Source Database does not exist';
+			$continue2 = 0;
+		}
+		//elseif(!$newdb_exist)
+		//{
+			//	echo '<br> New Database is not exist';
+			//	$continue2 = 0;
+		//}
+		else
+		{
+			$migration_log .= '<br> Required databases exist';
+			$continue2 = 1;
+		}
+	}
+
+	if($continue2 == 1)
+	{
+		//Check whether the table are exist in the databases or not
+		$old_tables = @mysql_num_rows(mysql_list_tables($old_dbname,$oldconn));
+		//$new_tables = @mysql_num_rows(mysql_list_tables($new_dbname));
+
+		if(!$old_tables)
+		{
+			echo '<br> Tables do not exist in the Source Database';
+			$continue3 = 0;
+		}
+		/*	if(!$new_tables)
+		{
+			echo '<br> Tables are not exist in New Database';
+			$continue3 = 0;
+		}
+		*/
+		else
+		{
+			$migration_log .= '<br> Tables exist in both the Databases';
+			$continue3 = 1;
+		}
+	}
+
+	//To check whether the two databases are same
+	if($continue3 == 1)
+	{
+		$new_host = explode(":",$new_host_name);
+
+		if($old_host_name == $new_host[0] && $old_mysql_port == $new_host[1] && $old_mysql_username == $new_mysql_username && $old_mysql_password == $new_mysql_password && $old_dbname == $new_dbname)
+		{
+			echo '<br> Both the databases are the same.';
+			$continue4 = 1;//change the value to 0 if you don't want to proceed with the same database
+			$same_databases = 1;
+		}
+		else
+		{
+			$continue4 = 1;
+			$same_databases = 0;
+		}
+	}
+
+	//$continue1 -- Database servers can be connected
+	//$continue2 -- Database exists in the servers
+	//$continue3 -- Tables are exist in the databases
+	//$continue4 -- Two databases are not same
+
+	if($continue1 == 1 && $continue2 == 1 && $continue3 == 1 && $continue4 == 1)
+	{
+		$new_host = explode(":",$new_host_name);
+
+		$conn = new PearDatabase("mysql",$new_host_name,$new_dbname,$new_mysql_username,$new_mysql_password);
+		$conn->connect();
+
+		$conn->println("MICKIE ==> Option = DB details. From the given DB details we will migrate.");
+		
+		@session_unregister('migration_log');
+		$_SESSION['migration_log'] = $migration_log;
+		if($conn)
+		{
+			$obj = new Migration('',$conn);
+			$obj->setOldDatabaseParams($old_host_name,$old_mysql_port,$old_mysql_username,$old_mysql_password,$old_dbname);
+			$obj->setNewDatabaseParams($new_host[0],$new_host[1],$new_mysql_username,$new_mysql_password,$new_dbname);
+			$obj->migrate($same_databases,'dbsource');
+		}
+		else
+		{
+			echo '<br> Cannot make a connection with the current database setup';
+			include("modules/Migration/MigrationStep1.php");
+		}
+	}
+	else
+	{
+		echo '<br>ERROR!!!!!!Please check the input values, unable to proceed.';
+		include("modules/Migration/MigrationStep1.php");
+	}
+
+
 }
-elseif(!$newconn)
+elseif($_REQUEST['migration_option'] == 'dump_details')
 {
-	echo '<br><br><br>  Current working Database Server cannot be connected';
-	$continue1 = 0;
+	$old_dump_details = $_FILES['old_dump_filename'];
+	$old_dump_filename = $old_dump_details['name'];
+	
+	//MySQL Dump file details has given
+	if($old_dump_details['size'] != 0 && is_file($old_dump_details['tmp_name']))
+	{
+		$gotostep1 = 0;
+		//apply this dump file to the new database
+		$checkDumpFileAndApply = 1;
+	}
+	else
+	{
+		$gotostep1 = 1;
+		if($old_dump_details['size'] == 0 || !is_file($old_dump_details['tmp_name']))
+		{
+			$invalid_dump = 1;
+		}
+	}
+
+	if($gotostep1 == 1)
+	{
+		if($invalid_dump == 1)
+		{
+			echo '<br> Please Enter a valid Dump file.';
+		}
+		include("modules/Migration/MigrationStep1.php");
+	}
+	if($checkDumpFileAndApply == 1)
+	{
+		//TODO - Check whether the given file is Dump file and then apply to the new database
+		$migration_log .= '<br> Going to apply the Dump file to the new database.';
+
+		include("config.inc.php");
+		global $dbconfig;
+
+		$new_host_name = $dbconfig['db_hostname'];
+		$new_dbname = $dbconfig['db_name'];
+		$new_mysql_username = $dbconfig['db_username'];
+		$new_mysql_password = $dbconfig['db_password'];
+
+		$conn = new PearDatabase("mysql",$new_host_name,$new_dbname,$new_mysql_username,$new_mysql_password);
+		$conn->connect();
+
+		$conn->println("MICKIE ==> Option = Dump File. Selected Dump File will be applied to the new database");
+		
+		@session_unregister('migration_log');
+		$_SESSION['migration_log'] = $migration_log;
+		if($conn)
+		{
+			$obj = new Migration('',$conn);
+
+			$new_host = explode(":",$new_host_name);
+			$temp_new_host_name = $new_host[0];
+			$new_mysql_port = $new_host[1];
+
+			$obj->setNewDatabaseParams($new_host[0],$new_host[1],$new_mysql_username,$new_mysql_password,$new_dbname);
+			$obj->migrate(0,'dumpsource',$old_dump_filename);
+		}
+	}
+
 }
 else
 {
-	echo '<br><br><br> Database Servers can be connected. Can proceed with migration';
-	$continue1 = 1;
-}
-
-if($continue1 == 1)
-{
-	//check whether the specified databases are exist or not
-	$olddb_exist = @mysql_select_db($old_dbname,$oldconn);
-	//$newdb_exist = @mysql_select_db($new_dbname,$oldconn);
-	if(!$olddb_exist)
-	{
-		echo '<br> Source Database does not exist';
-		$continue2 = 0;
-	}
-	//elseif(!$newdb_exist)
-	//{
-	//	echo '<br> New Database is not exist';
-	//	$continue2 = 0;
-	//}
-	else
-	{
-		echo '<br> Required databases exist';
-		$continue2 = 1;
-	}
-}
-
-if($continue2 == 1)
-{
-	//Check whether the table are exist in the databases or not
-	$old_tables = @mysql_num_rows(mysql_list_tables($old_dbname,$oldconn));
-	//$new_tables = @mysql_num_rows(mysql_list_tables($new_dbname));
-
-	if(!$old_tables)
-	{
-		echo '<br> Tables do not exist in the Source Database';
-		$continue3 = 0;
-	}
-/*	if(!$new_tables)
-        {
-                echo '<br> Tables are not exist in New Database';
-                $continue3 = 0;
-        }
-*/
-	else
-	{
-		echo '<br> Tables exist in both the Databases';
-		$continue3 = 1;
-	}
-}
-
-//To check whether the two databases are same
-if($continue3 == 1)
-{
-	$new_host = explode(":",$new_host_name);
-
-	if($old_host_name == $new_host[0] && $old_mysql_port == $new_host[1] && $old_mysql_username == $new_mysql_username && $old_mysql_password == $new_mysql_password && $old_dbname == $new_dbname)
-	{
-		echo '<br> Both the databases are the same.';
-		$continue4 = 1;//change the value to 0 if you don't want to proceed with the same database
-		$same_databases = 1;
-	}
-	else
-	{
-		$continue4 = 1;
-		$same_databases = 0;
-	}
-}
-
-//$continue1 -- Database servers can be connected
-//$continue2 -- Database exists in the servers
-//$continue3 -- Tables are exist in the databases
-//$continue4 -- Two databases are not same
-
-if($continue1 == 1 && $continue2 == 1 && $continue3 == 1 && $continue4 == 1)
-{
-	$new_host = explode(":",$new_host_name);
-
-	echo '<br>';
-	echo '<br>*************************************************************';
-	echo '<br><b>Source Database Parameters : </b>
-		<br> Host Name : '.$old_host_name.'
-		<br> MySql Port : '.$old_mysql_port.'
-		<br> MySql User Name : '.$old_mysql_username.'
-		<br> MySql Password : '.$old_mysql_password.'
-		<br> DB Name : '.$old_dbname;
-	echo '<br>*************************************************************';
-	echo '';
-	echo '';
-	echo '<br>*************************************************************';
-	echo '<br><b>Current Database Parameters : </b>
-		<br> Host Name : '.$new_host[0].'
-		<br> MySql Port : '.$new_host[1].'
-		<br> MySql User Name : '.$new_mysql_username.'
-		<br> MySql Password : '.$new_mysql_password.'
-		<br> DB Name : '.$new_dbname;
-	echo '<br>*************************************************************';
-
-
-	$conn = new PearDatabase("mysql",$new_host_name,$new_dbname,$new_mysql_username,$new_mysql_password);
-	$conn->connect();
-	if($conn)
-	{
-		include("modules/Migration/Migration.php");
-		$obj = new Migration('',$conn);
-		$obj->setOldDatabaseParams($old_host_name,$old_mysql_port,$old_mysql_username,$old_mysql_password,$old_dbname);
-		$obj->setNewDatabaseParams($new_host[0],$new_host[1],$new_mysql_username,$new_mysql_password,$new_dbname);
-		$obj->migrate($same_databases);
-	}
-	else
-	{
-		echo '<br> Cannot make a connection with the current database setup';
-		include("modules/Migration/MigrationStep1.php");
-	}
-}
-else
-{
-	echo '<br>ERROR!!!!!!Please check the input values, unable to proceed.';
+	//Return to the MigrationStep1
 	include("modules/Migration/MigrationStep1.php");
 }
 
+
 ?>

Modified: vtigercrm/trunk/modules/Migration/MigrationStep1.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/MigrationStep1.php (original)
+++ vtigercrm/trunk/modules/Migration/MigrationStep1.php Fri May 26 18:26:46 2006
@@ -1,301 +1,63 @@
 <?php
 /*********************************************************************************
- * The contents of this file are subject to the vtiger CRM Public License Version 1.0
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
  * ("License"); You may not use this file except in compliance with the License
  * The Original Code is:  vtiger CRM Open Source
  * The Initial Developer of the Original Code is vtiger.
  * Portions created by vtiger are Copyright (C) vtiger.
  * All Rights Reserved.
- *
+*
  ********************************************************************************/
 
-require_once("modules/Migration/language/en_us.lang.php");
-global $mod_strings;
 
-//To get the Current installed MySQL path
-include("connection.php");
-$vtiger_home = $_ENV["VTIGER_HOME"];
-$mysqldir = $mysql_dir;
+require_once('Smarty_setup.php');
 
-if(is_file($mysqldir."/bin/mysqldump"))
+global $app_strings,$app_list_strings,$mod_strings,$theme,$currentModule;
+
+$smarty = new vtigerCRM_Smarty();
+
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("MODULE","Migration");
+
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+
+$smarty->assign("DB_DETAILS_CHECKED", 'checked');
+$smarty->assign("SHOW_DB_DETAILS", 'block');
+//this is to set the entered values when we could not proceed the migration and return to step1
+if($_REQUEST['migration_option'] != '')
 {
-	$installed_mysql_path = $mysqldir."/bin/mysqldump";
-	$getmysqlpath = false;
-}
-elseif(is_file($vtiger_home."/mysql/bin/mysqldump"))
-{
-	$installed_mysql_path = $vtiger_home."/mysql/bin/mysqldump";
-	$getmysqlpath = false;
-}
-elseif(substr($_ENV["OS"],0,3) == "Win")
-{
-	if(is_file($vtiger_home.'\mysql\bin\mysql.exe'))
+	if($_REQUEST['migration_option'] == 'db_details')
 	{
-		$installed_mysql_path = $vtiger_home.'\mysql\bin\mysqldump.exe';
-		@session_unregister('windows_mysql_path');
-		$_SESSION['windows_mysql_path'] = $vtiger_home.'\mysql\bin';
-		$getmysqlpath = false;
+		if($_REQUEST['old_host_name'] != '')
+			$smarty->assign("OLD_HOST_NAME", $_REQUEST['old_host_name']);
+		if($_REQUEST['old_port_no'] != '')
+			$smarty->assign("OLD_PORT_NO", $_REQUEST['old_port_no']);
+		if($_REQUEST['old_mysql_username'] != '')
+			$smarty->assign("OLD_MYSQL_USERNAME", $_REQUEST['old_mysql_username']);
+		if($_REQUEST['old_mysql_password'] != '')
+			$smarty->assign("OLD_MYSQL_PASSWORD", $_REQUEST['old_mysql_password']);
+		if($_REQUEST['old_dbname'] != '')
+			$smarty->assign("OLD_DBNAME", $_REQUEST['old_dbname']);
 	}
 	else
 	{
-		$getmysqlpath = true;
+		$smarty->assign("DUMP_DETAILS_CHECKED", 'checked');
+		$smarty->assign("DB_DETAILS_CHECKED", '');
+
+		$smarty->assign("SHOW_DUMP_DETAILS", 'block');
+		$smarty->assign("SHOW_DB_DETAILS", 'none');
 	}
 }
-else
-{
-	$getmysqlpath = true;
-}
 
-//The control will come here if getparams will be set from Step2
-if($getOldParams == 1)
-{
-	$installed_mysql_path = trim($current_mysqlpath."/")."/bin/mysqldump";
-	$getmysqlpath = false;
-}
-
-
-//Get the MySQL path value if it couldnot retrieved by ENV variable or mysql_dir from connection.php
-if($getmysqlpath == true) 
-{
-
-?>
-
-   <br><br>
-   <form name="current_migration" method="POST" action="index.php">
-   <input type="hidden" name="module" value="Migration">
-   <input type="hidden" name="action" value="MigrationStep2">
-   <input type="hidden" name="pre_action" value="MigrationStep1">
-   <table border=10 width="80%" cellpadding="5" cellspacing="5" bgcolor="#D1DFEF">
-	<th colspan=3>
-         <font color="#3535A2"><?php echo $mod_strings['LBL_MIGRATE_INFO']; ?></font>
-	</th>
-	<tr>
-		<!-- td nowrap>
-		    vtiger 4.5 Type 
-			<select name="4.5type_install">
-			        <OPTION name="Install" value="install"> Install </OPTION>
-			        <OPTION name="Source" value="source"> Source </OPTION>
-			</select>
-		</td -->
-		<td width="40%">
-		   <?php echo $mod_strings['LBL_CURRENT_VT_MYSQL_EXIST']; ?> 
-		   <?php if($_REQUEST['current_mysql_install'] == 'different') $different = 'selected'; else $same = 'selected';?>
-		   <select name="current_mysql_install">
-               	      <OPTION name="This machine" value="same" <?php echo $same;?> ><?php echo $mod_strings['LBL_THIS_MACHINE'];?></OPTION>
-                      <OPTION name="Different machine" value="different" <?php echo $different; ?> ><?php echo $mod_strings['LBL_DIFFERENT_MACHINE'];?></OPTION>
-                   </select>
-		</td>
-		<!-- This text will be displayed if current_mysql_install is same. else get the mysql dump file -->
-		<td width="60%">
-			<?php 
-				if($_REQUEST['old_dump_filename'] != '')
-				{
-					$dumpstyle = "display:block";	$dumpcheck = 'checked';
-					$pathstyle = "display:none";	$pathcheck = '';
-				}
-				else//if($_REQUEST['current_mysqlpath'] != '') 
-				{
-					$pathstyle = "display:block";	$pathcheck = 'checked';
-					$dumpstyle = "display:none";	$dumpcheck = '';
-				}
-			?>
-			<!-- table to display the radio buttons and the related text fields starts here -->
-			<table border=0 cellspacing=0 cellpadding=0>
-			   <tr>
-			      <td width="40%">
-				Current MySQL Path <input type="radio" name="mysql" value="path" <?php echo $pathcheck; ?> onclick="toggleAssignType(this.value)">
-				<br>
-				Source  MySQL Dump <input type="radio" name="mysql" value="dump" <?php echo $dumpcheck; ?> onclick="toggleAssignType(this.value)">
-			      </td>
-			      <td width="60%">
-			   	<div name="pathdisplay" id="path" style="<?php echo $pathstyle?>">
-				   <?php echo $mod_strings['LBL_CURRENT_VT_MYSQL_PATH']; ?>
-				   <input type="text" name="current_mysqlpath" value="<?php echo $_REQUEST['current_mysqlpath']; ?>">
-			   	</div>
-			   	<div name="dumpdisplay" id="dump" style="<?php echo $dumpstyle?>">
-				   <?php echo $mod_strings['LBL_SOURCE_VT_MYSQL_DUMPFILE']; ?>
-				   <input type="text" name="old_dump_filename" value="<?php echo $_REQUEST['old_dump_filename'];?>">
-			   	</div>
-			      </td>
-		        </tr>
-			</table>
-			<!-- table to display the radio buttons and the related text fields ends here -->
-		</td>
-	</tr>
-	<tr>
-		<td align="center" colspan=3>
-			<input type="submit" name="submit" value="Continue" onclick="return form_validate_new(current_migration)">
-		</td>
-	</tr>
-   <table>
-	<br> <?php echo $mod_strings['LBL_NOTE_TITLE']; ?>
-	   <ol>
-		<li><?php echo $mod_strings['LBL_NOTES_LIST1']; ?></li>
-		<li><?php echo $mod_strings['LBL_NOTES_LIST2']; ?></li>
-		<li><?php echo $mod_strings['LBL_NOTES_DUMP_PROCESS']; ?></li>
-		<li><?php echo $mod_strings['LBL_NOTES_LIST3']; ?></b></li>
-		<li><?php echo $mod_strings['LBL_NOTES_LIST4']; ?></b></li>
-	   </ol>
-   </form>
-   <!-- Extra table tag is closed as to move the footer at the end of the page -->
-   </table>
-   <script type='text/javascript' language='JavaScript'>
-   function toggleAssignType(val)
-   {
-        if (val=="path")
-        {
-                getObj("path").style.display="block";
-                getObj("dump").style.display="none";
-        }
-        else
-        {
-                getObj("path").style.display="none";
-                getObj("dump").style.display="block";
-        }
-   }
-   function form_validate_new(form)
-   {
-	if(form.current_mysql_install.value == 'same')
-	{
-		if(form.current_mysqlpath.value == '' && form.old_dump_filename.value == '')
-		{
-			alert("Please enter the Current MySQL Path or Enter the Source Dump file name.");
-			return false;
-		}
-	}
-	else if(form.current_mysql_install.value == 'different')
-	{
-		if(form.old_dump_filename.value == '')
-		{
-			alert('Please enter the Source Dump file name.')
-			return false;
-		}
-	}
-	return true;
-   }
-   </script>
-
-<?php
-}
-else
-{
-	//include("modules/Migration/MigrationStep2.php");
-	if($_REQUEST['old_host_name'] == '')
-	{
-		echo '<br>'.$mod_strings['LBL_CURRENT_MYSQL_PATH_FOUND'];
-	}
-	?>
-   <br><br>
-   <form name="old_migration" method="POST" action="index.php">
-   <input type="hidden" name="module" value="Migration">
-   <input type="hidden" name="action" value="MigrationCheck">
-   <table border=10 width="80%" cellpadding="5" cellspacing="5" bgcolor="#D1DFEF">
-      <th colspan=2>
-         <font color="#3535A2"><?php echo $mod_strings['LBL_MIGRATE_INFO'];?></font>
-      </th>
-	<!-- tr>
-		<td align="right">vtiger 4.2 Exist in </td>
-		<td>
-			<?php //if($_REQUEST['machine_4_2'] == 'different') $different = 'selected'; else $same = 'selected';?>
-			<select name="machine_4_2">
-                                <OPTION name="This machine" value="same" <?php echo $same; ?> > This Machine </OPTION>
-                                <OPTION name="Different machine" value="different" <?php echo $different; ?> > Different Machine </OPTION>
-                        </select>
-		</td>
-		<td>vtiger 4.2 MySQL Exist in 
-			<select name="mysqlinstall">
-                                <OPTION name="This machine" value="same"> This Machine </OPTION>
-                                <OPTION name="Different machine" value="different"> Different Machine </OPTION>
-                        </select>
-		</td>
-	</tr -->
-	<tr>
-		<td align="right"><?php echo $mod_strings['LBL_SOURCE_HOST_NAME'];?></td>
-		<td><input type="text" name="old_host_name" value="<?php echo $_REQUEST['old_host_name']?>"></td>
-	</tr>
-	<tr>
-		<td align="right"><?php echo $mod_strings['LBL_SOURCE_MYSQL_PORT_NO'];?></td>
-		<td><input type="text" name="old_port_no" value="<?php echo $_REQUEST['old_port_no']?>"></td>
-	</tr>
-	<tr>
-		<td align="right"><?php echo $mod_strings['LBL_SOURCE_MYSQL_USER_NAME'];?></td>
-		<td><input type="text" name="old_mysql_username" value="<?php echo $_REQUEST['old_mysql_username']?>"></td>
-	</tr>
-	<tr>
-		<td align="right"><?php echo $mod_strings['LBL_SOURCE_MYSQL_PASSWORD'];?></td>
-		<td><input type="password" name="old_mysql_password" value="<?php echo $_REQUEST['old_mysql_password']?>"></td>
-	</tr>
-	<tr>
-		<td align="right"><?php echo $mod_strings['LBL_SOURCE_DB_NAME'];?></td>
-		<td><input type="text" name="old_dbname" value="<?php echo $_REQUEST['old_dbname']?>"></td>
-	</tr>
-	<tr>
-		<td align="center" colspan=2>
-			<input type="submit" name="submit" value="<?php echo $mod_strings['LBL_MIGRATE'];?>" onclick="return form_validate_old(old_migration)">
-		</td>
-	</tr>
-   <table>
-   </form>
-   <!-- Extra table tag is closed as to move the footer at the end of the page -->
-   </table>
-   <script type='text/javascript' language='JavaScript'>
-   function form_validate_old(formname)
-   {
-	if(formname.old_host_name.value == '')
-	{
-		error_msg = "Please enter the Source Host Name";
-		error = true;
-	}
-	else if(formname.old_port_no.value == '')
-	{
-		error_msg = "Please enter the Source MySql Port Number";
-		error = true;
-	}
-	else if(formname.old_mysql_username.value == '')
-	{
-		error_msg = "Please enter the Source MySql User Name";
-		error = true;
-	}
-	/*
-	else if(formname.old_mysql_password.value == '')
-	{
-		error_msg = "Please enter the Source MySql Password";
-		error = true;
-	}
-	*/
-	else if(formname.old_dbname.value == '')
-        {
-                error_msg = "Please enter the Source Database Name";
-                error = true;
-        }
-	else
-	{
-		error = false;
-	}
-
-
-	if(error == true)
-	{
-		alert(error_msg);
-		return false;
-	}
-	else
-	{
-		return true;
-	}
-   }
-   </script>
-
-<?php
-
-
-}
-
-
-
-
-
-
+$smarty->display("MigrationStep1.tpl");
 
 
 ?>





More information about the vtigercrm-commits mailing list