From f2d9d064e086a5ca2dd4447ca2dcff863db68171 Mon Sep 17 00:00:00 2001
From: Rescue9 <Rescue9@yahoo.com>
Date: Thu, 09 Oct 2014 15:02:45 -0400
Subject: [PATCH] outgoing email copy

---
 install/lib/update.lib.php |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index eba9ac6..d2d11bf 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -160,10 +160,15 @@
 
 		//* get the version of the db schema from the server table
 		$found = true;
+		$dev_patch = false;
 		while($found == true) {
-			$next_db_version = intval($current_db_version + 1);
+			if($dev_patch == true) $next_db_version = 'dev_collection';
+			else $next_db_version = intval($current_db_version + 1);
 			$sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
 			$php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php';
+			
+			// comma separated list of version numbers were a update has to be done silently
+			$silent_update_versions = 'dev_collection,75';
 
 			if(is_file($sql_patch_filename)) {
 
@@ -179,26 +184,34 @@
 				}
 
 				//* Exec onBeforeSQL function
-				if(isset($php_patch) && is_object($php_patch)) {
+				if(isset($php_patch) && is_object($php_patch) && method_exists($php_patch, 'onBeforeSQL')) {
 					$php_patch->onBeforeSQL();
 					swriteln($inst->lng('Executing PHP patch file').': '.$php_patch_filename);
 				}
 
 				//* Load patch file into database
 				if( !empty($conf["mysql"]["admin_password"]) ) {
-					system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
+					$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
 				} else {
-					system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
+					$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
 				}
+				
+				if(in_array($next_db_version,explode(',',$silent_update_versions))) $cmd .= ' > /dev/null 2> /dev/null';
+				system($cmd);
+				
 				swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename);
 
 				//* Exec onAfterSQL function
-				if(isset($php_patch) && is_object($php_patch)) {
+				if(isset($php_patch) && is_object($php_patch) && method_exists($php_patch, 'onAfterSQL')) {
 					$php_patch->onAfterSQL();
 				}
 
-				$current_db_version = $next_db_version;
+				if($dev_patch == false) $current_db_version = $next_db_version;
+				else $found = false;
+				
 				if(isset($php_patch)) unset($php_patch);
+			} elseif($dev_patch == false) {
+				$dev_patch = true;
 			} else {
 				$found = false;
 			}

--
Gitblit v1.9.1