[Vtigercrm-commits] [vtiger-commits] r4328 - in /vtigercrm/branches/4.2_postgresql_integration/install: 1checkSystem.php 2setConfig.php 3confirmConfig.php 4createConfigFile.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Mar 20 05:48:02 EST 2006


Author: allanbush
Date: Mon Mar 20 03:47:59 2006
New Revision: 4328

Log:
Working postgres/mysql database type selection process for installation.

Leaves the database type option out if support for one of the options is missing.  The default port is probably set incorrectly for most postgres installations (usually 5432).

References ticket:17.

Modified:
    vtigercrm/branches/4.2_postgresql_integration/install/1checkSystem.php
    vtigercrm/branches/4.2_postgresql_integration/install/2setConfig.php
    vtigercrm/branches/4.2_postgresql_integration/install/3confirmConfig.php
    vtigercrm/branches/4.2_postgresql_integration/install/4createConfigFile.php

Modified: vtigercrm/branches/4.2_postgresql_integration/install/1checkSystem.php
==============================================================================
--- vtigercrm/branches/4.2_postgresql_integration/install/1checkSystem.php (original)
+++ vtigercrm/branches/4.2_postgresql_integration/install/1checkSystem.php Mon Mar 20 03:47:59 2006
@@ -169,7 +169,7 @@
 		<tr>
 			<td bgcolor="#EEEEEE"><strong>Database</strong></td>
 
-        	<td align="right"><?php echo function_exists('mysql_connect')?"<strong><font color=\"#0066CC\">Available</font></strong>":"<strong><font color=\"#FF0000\">Not Available</font></strong>";?></td>
+        	<td align="right"><?php echo function_exists('mysql_connect') || function_exists('pg_connect')?"<strong><font color=\"#0066CC\">Available</font></strong>":"<strong><font color=\"#FF0000\">Not Available</font></strong>";?></td>
 
 	    </tr>
 		<tr>

Modified: vtigercrm/branches/4.2_postgresql_integration/install/2setConfig.php
==============================================================================
--- vtigercrm/branches/4.2_postgresql_integration/install/2setConfig.php (original)
+++ vtigercrm/branches/4.2_postgresql_integration/install/2setConfig.php Mon Mar 20 03:47:59 2006
@@ -335,14 +335,27 @@
             <tr>
               <td nowrap bgcolor="#F5F5F5"><strong>Database Name</strong> <sup><font color=red>*</font></sup></td>
               <td align="left"><input type="text" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" /></td>
-              <input type="hidden" name="dbtype" value="
-              <?php
-                if(isset($dbconfig['db_type']) && $dbconfig['db_type'] != '')
-                        echo $dbconfig['db_type'];
-                elseif(isset($databasetype) && $databasetype != '')
-                        echo $databasetype;
-              ?>">
-            </tr>
+            </tr>
+		<?php if(function_exists('mysql_connect') && function_exists('pg_connect')) : ?>
+	    <tr>
+	      <td nowrap bgcolor="#F5F5F5"><strong>Database Type</strong> <sup><font color=red>*</font></sup></td>
+	      <td align="left">
+	        <select class="dataInput" name="dbtype">
+		  <option value="mysql" <?php echo $dbconfig['db_type'] == 'mysql' ? 'selected' : '' ?>>MySQL</option>
+		  <option value="pgsql" <?php echo $dbconfig['db_type'] == 'pgsql' ? 'selected' : '' ?>>Postgresql</option>
+	        </select>
+	      </td>
+	    </tr>
+		<?php elseif(function_exists('mysql_connect')) : ?>
+			<input type="hidden" name="dbtype" value="mysql" />
+		<?php elseif(function_exists('pg_connect')) : ?>
+			<input type="hidden" name="dbtype" value="pgsql" />
+		<?php else : ?>
+	   <tr>
+	      <td nowrap bgcolor="#F5F5F5"><strong>Database Type</strong> <sup><font color=red>*</font></sup></td>
+	      <td align="left" class="dataInput">ERROR: none detected</td>
+	   </tr>
+		<?php endif ?>
           </table>
               <!-- tr>
                <td></td><td nowrap><strong>Drop Existing Tables?</strong></td>

Modified: vtigercrm/branches/4.2_postgresql_integration/install/3confirmConfig.php
==============================================================================
--- vtigercrm/branches/4.2_postgresql_integration/install/3confirmConfig.php (original)
+++ vtigercrm/branches/4.2_postgresql_integration/install/3confirmConfig.php Mon Mar 20 03:47:59 2006
@@ -68,14 +68,10 @@
 if (isset($_REQUEST['dbtype']))
 	$dbtype	= $_REQUEST['dbtype'];
 
-//Checking for mysql connection parameters
+//Checking for mysql or pgsql connection parameters
 $mysql_status = '';
 $mysql_db_status = '';
-if($dbtype != 'mysql' || $dbtype =='') {
-	$mysql_status = 'true';
-	$mysql_db_status = 'true';
-}
-else {
+if($dbtype == 'mysql') {
 	$conn = @mysql_pconnect($db_hostname,$db_username,$db_password);
 	if(!$conn)
 		$mysql_status = 'false';
@@ -89,6 +85,19 @@
 			$mysql_db_status = 'false';
 		}
 	}
+} elseif($dbtype == 'pgsql') {
+	$host = explode(':', $db_hostname);
+	$conn = @pg_connect("host=".$host[0]." port=".$host[1]." user=$db_username password=$db_password dbname=$db_name");
+	if(!$conn) {
+		$mysql_status = 'false';
+		$mysql_db_status = 'false';
+	} else {
+		$mysql_status = 'true';
+		$mysql_db_status = 'true';
+	}
+} else {
+	$mysql_status = 'true';
+	$mysql_db_status = 'true';
 }
 ?>
 
@@ -198,6 +207,7 @@
              <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
              <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
              <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+	     <input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
              <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
              <input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
              <input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -231,6 +241,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -255,6 +266,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -363,6 +375,7 @@
 		<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 		<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 		<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+		<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 		<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 		<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 		<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -433,6 +446,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />

Modified: vtigercrm/branches/4.2_postgresql_integration/install/4createConfigFile.php
==============================================================================
--- vtigercrm/branches/4.2_postgresql_integration/install/4createConfigFile.php (original)
+++ vtigercrm/branches/4.2_postgresql_integration/install/4createConfigFile.php Mon Mar 20 03:47:59 2006
@@ -19,7 +19,6 @@
  * Description:  Executes a step in the installation process.
  ********************************************************************************/
 
-require_once('include/utils.php');
 include('vtigerversion.php');
 
 session_start();
@@ -35,6 +34,9 @@
 
 if (isset($_REQUEST['db_name']))
   $db_name = $_REQUEST['db_name'];
+
+if (isset($_REQUEST['db_type']))
+  $db_type = $_REQUEST['db_type'];
 
 if (isset($_REQUEST['db_drop_tables']))
   $db_drop_tables = $_REQUEST['db_drop_tables'];
@@ -144,7 +146,7 @@
       $buffer = str_replace( "_DBC_USER_", $db_username, $buffer);
       $buffer = str_replace( "_DBC_PASS_", $db_password, $buffer);
       $buffer = str_replace( "_DBC_NAME_", $db_name, $buffer);
-      $buffer = str_replace( "_DBC_TYPE_", "mysql", $buffer);
+      $buffer = str_replace( "_DBC_TYPE_", $db_type, $buffer);
       
       $buffer = str_replace( "_SITE_URL_", $site_URL, $buffer);
       
@@ -195,6 +197,7 @@
               <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
               <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
               <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+              <input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($db_type)) echo "$db_type"; ?>" />
               <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
               <input type="hidden" class="dataInput" name="db_create" value="<?php if (isset($db_create)) echo "$db_create"; ?>" />
               <input type="hidden" class="dataInput" name="db_populate" value="<?php if (isset($db_populate)) echo "$db_populate"; ?>" />





More information about the vtigercrm-commits mailing list