From c4e264b9369b99512ac83e400acd65cac5693dcf Mon Sep 17 00:00:00 2001 From: Naomi Date: Tue, 12 Apr 2011 13:42:28 -0400 Subject: [PATCH] CC-2172 : Create Upgrade structure so that a user can upgrade from any version of Airtime properly --- install/airtime-upgrade.php | 13 ++++++++----- install/include/AirtimeInstall.php | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/install/airtime-upgrade.php b/install/airtime-upgrade.php index 23250b033..37590b0c0 100644 --- a/install/airtime-upgrade.php +++ b/install/airtime-upgrade.php @@ -7,14 +7,15 @@ */ require_once(dirname(__FILE__).'/include/AirtimeIni.php'); +require_once(dirname(__FILE__).'/include/AirtimeInstall.php'); AirtimeIni::ExitIfNotRoot(); -if(file_exists(dirname(__FILE__).'/../VERSION')) { - $version = file_get_contents(dirname(__FILE__).'/../VERSION'); - echo "Airtime Version: ".$version." ".PHP_EOL; -} -else if(AirtimeInstall::DbTableExists('cc_show_rebroadcast') === true) { +//if(file_exists(dirname(__FILE__).'/../VERSION')) { +// $version = file_get_contents(dirname(__FILE__).'/../VERSION'); +// echo "Airtime Version: ".$version." ".PHP_EOL; +//} +if(AirtimeInstall::DbTableExists('cc_show_rebroadcast') === true) { $version = "1.7.0"; echo "Airtime Version: ".$version." ".PHP_EOL; } @@ -32,6 +33,8 @@ if(strcmp($version, "1.8.0") < 0) { system("php ".__DIR__."/upgrades/airtime-1.8/airtime-upgrade.php"); } +AirtimeInstall::SetAirtimeVersion("1.8.0"); + echo "******************************* Update Complete *******************************".PHP_EOL; diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index ddac4bd06..8bacffe85 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -165,6 +165,32 @@ class AirtimeInstall { system($command); } + public static function SetAirtimeVersion($p_version) + { + global $CC_DBC; + $sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'"; + $CC_DBC->query($sql); + + $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', $p_version)"; + $result = $CC_DBC->query($sql); + if (PEAR::isError($result)) { + return false; + } + return true; + } + + public static function GetAirtimeVersion() + { + global $CC_DBC; + $sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'"; + $version = $CC_DBC->GetOne($sql); + + if (PEAR::isError($version)) { + return false; + } + return $version; + } + public static function DeleteFilesRecursive($p_path) { $command = "rm -rf $p_path";