From cd95170b06cac446575c8d293ab79c5518e5bb14 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 23 Sep 2011 16:26:19 -0400 Subject: [PATCH] CC-2807: Remove AIRTIME_VERSION from constants.php and use the value in the database instead -done --- airtime_mvc/application/configs/constants.php | 1 - .../application/controllers/ApiController.php | 6 +- .../controllers/LoginController.php | 2 +- airtime_mvc/application/models/Preference.php | 160 +++++++++--------- .../application/models/Systemstatus.php | 59 ------- install_minimal/include/airtime-constants.php | 3 + .../include/airtime-db-install.php | 4 +- install_minimal/include/airtime-install.php | 2 +- install_minimal/include/airtime-uninstall.php | 2 +- install_minimal/include/airtime-upgrade.php | 2 +- 10 files changed, 94 insertions(+), 147 deletions(-) create mode 100644 install_minimal/include/airtime-constants.php diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index 43c15e9d3..00055588a 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -1,6 +1,5 @@ AIRTIME_VERSION)); + $jsonStr = json_encode(array("version"=>Application_Model_Preference::GetAirtimeVersion())); echo $jsonStr; } @@ -662,7 +662,7 @@ class ApiController extends Zend_Controller_Action $status = array( "platform"=>Application_Model_Systemstatus::GetPlatformInfo(), - "airtime_version"=>Application_Model_Systemstatus::GetAirtimeVersion(), + "airtime_version"=>Application_Model_Preference::GetAirtimeVersion(), "services"=>array( "icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(), "rabbitmq"=>Application_Model_Systemstatus::GetRabbitMqStatus(), diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index d05eec225..87ddc30a2 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -83,7 +83,7 @@ class LoginController extends Zend_Controller_Action $this->view->message = $message; $this->view->error = $error; $this->view->form = $form; - $this->view->airtimeVersion = AIRTIME_VERSION; + $this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion(); $this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE; } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 0466332dc..340762a6f 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -68,7 +68,7 @@ class Application_Model_Preference if (isset($defaultNamespace->title)) { $title = $defaultNamespace->title; } else { - $title = Application_Model_Preference::GetValue("station_name"); + $title = self::GetValue("station_name"); $defaultNamespace->title = $title; } if (strlen($title) > 0) @@ -78,7 +78,7 @@ class Application_Model_Preference } public static function SetHeadTitle($title, $view){ - Application_Model_Preference::SetValue("station_name", $title); + self::SetValue("station_name", $title); $defaultNamespace = new Zend_Session_Namespace('title_name'); $defaultNamespace->title = $title; RabbitMq::PushSchedule(); @@ -86,101 +86,101 @@ class Application_Model_Preference //set session variable to new station name so that html title is updated. //should probably do this in a view helper to keep this controller as minimal as possible. $view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject - $view->headTitle(Application_Model_Preference::GetHeadTitle()); + $view->headTitle(self::GetHeadTitle()); } public static function SetShowsPopulatedUntil($timestamp) { - Application_Model_Preference::SetValue("shows_populated_until", $timestamp); + self::SetValue("shows_populated_until", $timestamp); } public static function GetShowsPopulatedUntil() { - return Application_Model_Preference::GetValue("shows_populated_until"); + return self::GetValue("shows_populated_until"); } public static function SetDefaultFade($fade) { - Application_Model_Preference::SetValue("default_fade", $fade); + self::SetValue("default_fade", $fade); } public static function GetDefaultFade() { - return Application_Model_Preference::GetValue("default_fade"); + return self::GetValue("default_fade"); } public static function SetStreamLabelFormat($type){ - Application_Model_Preference::SetValue("stream_label_format", $type); + self::SetValue("stream_label_format", $type); RabbitMq::PushSchedule(); } public static function GetStreamLabelFormat(){ - return Application_Model_Preference::getValue("stream_label_format"); + return self::getValue("stream_label_format"); } public static function GetStationName(){ - return Application_Model_Preference::getValue("station_name"); + return self::getValue("station_name"); } public static function SetDoSoundCloudUpload($upload) { - Application_Model_Preference::SetValue("soundcloud_upload", $upload); + self::SetValue("soundcloud_upload", $upload); } public static function GetDoSoundCloudUpload() { - return Application_Model_Preference::GetValue("soundcloud_upload"); + return self::GetValue("soundcloud_upload"); } public static function SetSoundCloudUser($user) { - Application_Model_Preference::SetValue("soundcloud_user", $user); + self::SetValue("soundcloud_user", $user); } public static function GetSoundCloudUser() { - return Application_Model_Preference::GetValue("soundcloud_user"); + return self::GetValue("soundcloud_user"); } public static function SetSoundCloudPassword($password) { if (strlen($password) > 0) - Application_Model_Preference::SetValue("soundcloud_password", $password); + self::SetValue("soundcloud_password", $password); } public static function GetSoundCloudPassword() { - return Application_Model_Preference::GetValue("soundcloud_password"); + return self::GetValue("soundcloud_password"); } public static function SetSoundCloudTags($tags) { - Application_Model_Preference::SetValue("soundcloud_tags", $tags); + self::SetValue("soundcloud_tags", $tags); } public static function GetSoundCloudTags() { - return Application_Model_Preference::GetValue("soundcloud_tags"); + return self::GetValue("soundcloud_tags"); } public static function SetSoundCloudGenre($genre) { - Application_Model_Preference::SetValue("soundcloud_genre", $genre); + self::SetValue("soundcloud_genre", $genre); } public static function GetSoundCloudGenre() { - return Application_Model_Preference::GetValue("soundcloud_genre"); + return self::GetValue("soundcloud_genre"); } public static function SetSoundCloudTrackType($track_type) { - Application_Model_Preference::SetValue("soundcloud_tracktype", $track_type); + self::SetValue("soundcloud_tracktype", $track_type); } public static function GetSoundCloudTrackType() { - return Application_Model_Preference::GetValue("soundcloud_tracktype"); + return self::GetValue("soundcloud_tracktype"); } public static function SetSoundCloudLicense($license) { - Application_Model_Preference::SetValue("soundcloud_license", $license); + self::SetValue("soundcloud_license", $license); } public static function GetSoundCloudLicense() { - return Application_Model_Preference::GetValue("soundcloud_license"); + return self::GetValue("soundcloud_license"); } public static function SetAllow3rdPartyApi($bool) { - Application_Model_Preference::SetValue("third_party_api", $bool); + self::SetValue("third_party_api", $bool); } public static function GetAllow3rdPartyApi() { - $val = Application_Model_Preference::GetValue("third_party_api"); + $val = self::GetValue("third_party_api"); if (strlen($val) == 0){ return "0"; } else { @@ -189,101 +189,101 @@ class Application_Model_Preference } public static function SetPhone($phone){ - Application_Model_Preference::SetValue("phone", $phone); + self::SetValue("phone", $phone); } public static function GetPhone(){ - return Application_Model_Preference::GetValue("phone"); + return self::GetValue("phone"); } public static function SetEmail($email){ - Application_Model_Preference::SetValue("email", $email); + self::SetValue("email", $email); } public static function GetEmail(){ - return Application_Model_Preference::GetValue("email"); + return self::GetValue("email"); } public static function SetStationWebSite($site){ - Application_Model_Preference::SetValue("station_website", $site); + self::SetValue("station_website", $site); } public static function GetStationWebSite(){ - return Application_Model_Preference::GetValue("station_website"); + return self::GetValue("station_website"); } public static function SetSupportFeedback($feedback){ - Application_Model_Preference::SetValue("support_feedback", $feedback); + self::SetValue("support_feedback", $feedback); } public static function GetSupportFeedback(){ - return Application_Model_Preference::GetValue("support_feedback"); + return self::GetValue("support_feedback"); } public static function SetPublicise($publicise){ - Application_Model_Preference::SetValue("publicise", $publicise); + self::SetValue("publicise", $publicise); } public static function GetPublicise(){ - return Application_Model_Preference::GetValue("publicise"); + return self::GetValue("publicise"); } public static function SetRegistered($registered){ - Application_Model_Preference::SetValue("registered", $registered); + self::SetValue("registered", $registered); } public static function GetRegistered(){ - return Application_Model_Preference::GetValue("registered"); + return self::GetValue("registered"); } public static function SetStationCountry($country){ - Application_Model_Preference::SetValue("country", $country); + self::SetValue("country", $country); } public static function GetStationCountry(){ - return Application_Model_Preference::GetValue("country"); + return self::GetValue("country"); } public static function SetStationCity($city){ - Application_Model_Preference::SetValue("city", $city); + self::SetValue("city", $city); } public static function GetStationCity(){ - return Application_Model_Preference::GetValue("city"); + return self::GetValue("city"); } public static function SetStationDescription($description){ - Application_Model_Preference::SetValue("description", $description); + self::SetValue("description", $description); } public static function GetStationDescription(){ - return Application_Model_Preference::GetValue("description"); + return self::GetValue("description"); } public static function SetTimezone($timezone){ - Application_Model_Preference::SetValue("timezone", $timezone); + self::SetValue("timezone", $timezone); date_default_timezone_set($timezone); $md = array("timezone" => $timezone); } public static function GetTimezone(){ - return Application_Model_Preference::GetValue("timezone"); + return self::GetValue("timezone"); } public static function SetStationLogo($imagePath){ if(!empty($imagePath)){ $image = @file_get_contents($imagePath); $image = base64_encode($image); - Application_Model_Preference::SetValue("logoImage", $image); + self::SetValue("logoImage", $image); } } public static function GetStationLogo(){ - return Application_Model_Preference::GetValue("logoImage"); + return self::GetValue("logoImage"); } public static function GetUniqueId(){ - return Application_Model_Preference::GetValue("uniqueId"); + return self::GetValue("uniqueId"); } public static function GetCountryList(){ @@ -315,13 +315,13 @@ class Application_Model_Preference $outputArray = array(); - $outputArray['STATION_NAME'] = Application_Model_Preference::GetStationName(); - $outputArray['PHONE'] = Application_Model_Preference::GetPhone(); - $outputArray['EMAIL'] = Application_Model_Preference::GetEmail(); - $outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite(); - $outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry(); - $outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity(); - $outputArray['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription(); + $outputArray['STATION_NAME'] = self::GetStationName(); + $outputArray['PHONE'] = self::GetPhone(); + $outputArray['EMAIL'] = self::GetEmail(); + $outputArray['STATION_WEB_SITE'] = self::GetStationWebSite(); + $outputArray['STATION_COUNTRY'] = self::GetStationCountry(); + $outputArray['STATION_CITY'] = self::GetStationCity(); + $outputArray['STATION_DESCRIPTION'] = self::GetStationDescription(); // get web server info if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){ @@ -338,7 +338,7 @@ class Application_Model_Preference $outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount(); $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount(); $outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); - $outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId(); + $outputArray['UNIQUE_ID'] = self::GetUniqueId(); $outputArray = array_merge($systemInfoArray, $outputArray); @@ -349,8 +349,8 @@ class Application_Model_Preference } } if($returnArray){ - $outputArray['PROMOTE'] = Application_Model_Preference::GetPublicise(); - $outputArray['LOGOIMG'] = Application_Model_Preference::GetStationLogo(); + $outputArray['PROMOTE'] = self::GetPublicise(); + $outputArray['LOGOIMG'] = self::GetStationLogo(); return $outputArray; }else{ return $outputString; @@ -359,80 +359,84 @@ class Application_Model_Preference public static function SetRemindMeDate($now){ $weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y")); - Application_Model_Preference::SetValue("remindme", $weekAfter); + self::SetValue("remindme", $weekAfter); } public static function GetRemindMeDate(){ - return Application_Model_Preference::GetValue("remindme"); + return self::GetValue("remindme"); } public static function SetImportTimestamp(){ $now = time(); - if(Application_Model_Preference::GetImportTimestamp()+5 < $now){ - Application_Model_Preference::SetValue("import_timestamp", $now); + if(self::GetImportTimestamp()+5 < $now){ + self::SetValue("import_timestamp", $now); } } public static function GetImportTimestamp(){ - return Application_Model_Preference::GetValue("import_timestamp"); + return self::GetValue("import_timestamp"); } public static function GetStreamType(){ - $st = Application_Model_Preference::GetValue("stream_type"); + $st = self::GetValue("stream_type"); return explode(',', $st); } public static function GetStreamBitrate(){ - $sb = Application_Model_Preference::GetValue("stream_bitrate"); + $sb = self::GetValue("stream_bitrate"); return explode(',', $sb); } public static function SetPrivacyPolicyCheck($flag){ - Application_Model_Preference::SetValue("privacy_policy", $flag); + self::SetValue("privacy_policy", $flag); } public static function GetPrivacyPolicyCheck(){ - return Application_Model_Preference::GetValue("privacy_policy"); + return self::GetValue("privacy_policy"); } public static function SetNumOfStreams($num){ - Application_Model_Preference::SetValue("num_of_streams", intval($num)); + self::SetValue("num_of_streams", intval($num)); } public static function GetNumOfStreams(){ - return Application_Model_Preference::GetValue("num_of_streams"); + return self::GetValue("num_of_streams"); } public static function SetMaxBitrate($bitrate){ - Application_Model_Preference::SetValue("max_bitrate", intval($bitrate)); + self::SetValue("max_bitrate", intval($bitrate)); } public static function GetMaxBitrate(){ - return Application_Model_Preference::GetValue("max_bitrate"); + return self::GetValue("max_bitrate"); } public static function SetPlanLevel($plan){ - Application_Model_Preference::SetValue("plan_level", $plan); + self::SetValue("plan_level", $plan); } public static function GetPlanLevel(){ - return Application_Model_Preference::GetValue("plan_level"); + return self::GetValue("plan_level"); } public static function SetTrialEndingDate($date){ - Application_Model_Preference::SetValue("trial_end_date", $date); + self::SetValue("trial_end_date", $date); } public static function GetTrialEndingDate(){ - return Application_Model_Preference::GetValue("trial_end_date"); + return self::GetValue("trial_end_date"); } public static function SetDisableStreamConf($bool){ - Application_Model_Preference::SetValue("disable_stream_conf", $bool); + self::SetValue("disable_stream_conf", $bool); } public static function GetDisableStreamConf(){ - return Application_Model_Preference::GetValue("disable_stream_conf"); + return self::GetValue("disable_stream_conf"); + } + + public static function GetAirtimeVersion(){ + return self::GetValue("system_version"); } } diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php index d9ef41ce7..be115c56e 100644 --- a/airtime_mvc/application/models/Systemstatus.php +++ b/airtime_mvc/application/models/Systemstatus.php @@ -174,11 +174,6 @@ class Application_Model_Systemstatus return $data; } - - public static function GetAirtimeVersion(){ - return AIRTIME_VERSION; - } - public static function GetDiskInfo(){ /* First lets get all the watched directories. Then we can group them * into the same paritions by comparing the partition sizes. */ @@ -202,58 +197,4 @@ class Application_Model_Systemstatus return array_values($partitions); } - - -/* - - - private function getCheckSystemResults(){ - //exec("airtime-check-system", $output); - - require_once "/usr/lib/airtime/utils/airtime-check-system.php"; - $arrs = AirtimeCheck::CheckAirtimeDaemons(); - - $status = array("AIRTIME_VERSION" => AIRTIME_VERSION); - foreach($arrs as $arr){ - $status[$arr[0]] = $arr[1]; - } - - $storDir = Application_Model_MusicDir::getStorDir()->getDirectory(); - - $freeSpace = disk_free_space($storDir); - $totalSpace = disk_total_space($storDir); - - $status["DISK_SPACE"] = sprintf("%01.3f%%", $freeSpace/$totalSpace*100); - - return $status; - } - - public function getResults(){ - $keyValues = $this->getCheckSystemResults(); - - $results = array(); - $key = "AIRTIME_VERSION"; - $results[$key] = array("Airtime Version", $keyValues[$key], false); - - $triplets = array(array("PLAYOUT_ENGINE_RUNNING_SECONDS", "Playout Engine Status", true), - array("LIQUIDSOAP_RUNNING_SECONDS", "Liquidsoap Status", true), - array("MEDIA_MONITOR_RUNNING_SECONDS", "Media-Monitor Status", true), - array("SHOW_RECORDER_RUNNING_SECONDS", "Show-Recorder Status", true)); - - foreach($triplets as $triple){ - list($key, $desc, $downloadLog) = $triple; - $results[$key] = array($desc, $this->convertRunTimeToPassFail($keyValues[$key]), $downloadLog); - } - - $key = "DISK_SPACE"; - $results[$key] = array("Disk Space Free: ", $keyValues[$key], false); - - return $results; - } - - private function convertRunTimeToPassFail($runTime){ - return $runTime > 3 ? "Pass" : "Fail"; - } - - */ } diff --git a/install_minimal/include/airtime-constants.php b/install_minimal/include/airtime-constants.php new file mode 100644 index 000000000..bc6f9ccbf --- /dev/null +++ b/install_minimal/include/airtime-constants.php @@ -0,0 +1,3 @@ +getMessage()}".PHP_EOL; exit(1); } -} \ No newline at end of file +} diff --git a/install_minimal/include/airtime-install.php b/install_minimal/include/airtime-install.php index 7966994e8..19c2997d1 100644 --- a/install_minimal/include/airtime-install.php +++ b/install_minimal/include/airtime-install.php @@ -13,7 +13,7 @@ set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_inc require_once(dirname(__FILE__).'/AirtimeIni.php'); require_once(dirname(__FILE__).'/AirtimeInstall.php'); -require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php'); +require_once(__DIR__.'/airtime-constants.php'); AirtimeInstall::ExitIfNotRoot(); diff --git a/install_minimal/include/airtime-uninstall.php b/install_minimal/include/airtime-uninstall.php index 39fc0af41..3445b230c 100644 --- a/install_minimal/include/airtime-uninstall.php +++ b/install_minimal/include/airtime-uninstall.php @@ -15,7 +15,7 @@ if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) { echo "Most likely this means that Airtime is not installed, so there is nothing to do.".PHP_EOL.PHP_EOL; exit(); } -require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php'); +require_once(__DIR__.'/airtime-constants.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); echo PHP_EOL; diff --git a/install_minimal/include/airtime-upgrade.php b/install_minimal/include/airtime-upgrade.php index 10ba94931..f439b2eff 100644 --- a/install_minimal/include/airtime-upgrade.php +++ b/install_minimal/include/airtime-upgrade.php @@ -10,7 +10,7 @@ set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path()); require_once('DB.php'); -require_once(__DIR__.'/../../airtime_mvc/application/configs/constants.php'); +require_once(__DIR__.'/airtime-constants.php'); require_once(dirname(__FILE__).'/AirtimeIni.php'); require_once(dirname(__FILE__).'/AirtimeInstall.php');