diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 602c0c618..e6f0853c8 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -96,7 +96,6 @@ class Config { $CC_CONFIG['facebook-app-api-key'] = $globalAirtimeConfigValues['facebook']['facebook_app_api_key']; } - if(isset($values['demo']['demo'])){ $CC_CONFIG['demo'] = $values['demo']['demo']; } @@ -104,10 +103,12 @@ class Config { } public static function setAirtimeVersion() { - $airtime_version = Application_Model_Preference::GetAirtimeVersion(); - $uniqueid = Application_Model_Preference::GetUniqueId(); - $buildVersion = @file_get_contents(self::$rootDir."/../VERSION"); - self::$CC_CONFIG['airtime_version'] = md5($airtime_version.$buildVersion); + $version = @file_get_contents(self::$rootDir."/../VERSION"); + if (!$version) { + // fallback to constant from constants.php if no other info is available + $version = LIBRETIME_MAJOR_VERSION; + } + self::$CC_CONFIG['airtime_version'] = trim($version); } public static function getConfig() { diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index edfe88db9..bc30f3b49 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -32,8 +32,8 @@ define('LICENSE_URL' , 'http://www.gnu.org/licenses/agpl-3.0-standalone.h define('AIRTIME_COPYRIGHT_DATE' , '2010-2015'); define('AIRTIME_REST_VERSION' , '1.1'); define('AIRTIME_API_VERSION' , '1.1'); -// XXX: it's important that we upgrade this every time we add an upgrade! -define('AIRTIME_CODE_VERSION' , '2.5.16'); +// XXX: it's important that we upgrade this on major version bumps, usually users get more exact info from VERSION in airtime root dir +define('LIBRETIME_MAJOR_VERSION', '3'); // grab values from env (i'll do this everywhere with a small function if we like it) define('LIBRETIME_CONF_DIR', getenv('LIBRETIME_CONF_DIR') ? getenv('LIBRETIME_CONF_DIR') : '/etc/airtime'); diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index d7803fed3..e4c5fe5da 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -105,8 +105,9 @@ class ApiController extends Zend_Controller_Action public function versionAction() { + $config = Config::getConfig(); $this->_helper->json->sendJson( array( - "airtime_version" => Application_Model_Preference::GetAirtimeVersion(), + "airtime_version" => $config['airtime_version'], "api_version" => AIRTIME_API_VERSION)); } @@ -656,7 +657,8 @@ class ApiController extends Zend_Controller_Action $this->_helper->json->sendJson( array("jsonrpc" => "2.0", "error" => array("code" => $result['code'], "message" => $result['message'])) ); - }*/ + } + **/ } public function uploadRecordedAction() @@ -915,10 +917,11 @@ class ApiController extends Zend_Controller_Action { $request = $this->getRequest(); $getDiskInfo = $request->getParam('diskinfo') == "true"; + $config = Config::getConfig(); $status = array( "platform"=>Application_Model_Systemstatus::GetPlatformInfo(), - "airtime_version"=>Application_Model_Preference::GetAirtimeVersion(), + "airtime_version"=>$config['airtime_version'], "services"=>array( "pypo"=>Application_Model_Systemstatus::GetPypoStatus(), "liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(), diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 510e94b91..5b265fb19 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -109,8 +109,9 @@ class DashboardController extends Zend_Controller_Action public function aboutAction() { + $config = Config::getConfig(); Zend_Layout::getMvcInstance()->assign('parent_page', 'Help'); - $this->view->airtime_version = Application_Model_Preference::GetAirtimeVersion(); + $this->view->airtime_version = $config['airtime_version']; } public function tableTestAction() diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index 861cc6d35..2fbbfa724 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -114,7 +114,7 @@ class LoginController extends Zend_Controller_Action } $this->view->form = $form; - $this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion(); + $this->view->airtimeVersion = $CC_CONFIG['airtime_version']; $this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE; if (isset($CC_CONFIG['demo'])) { $this->view->demo = $CC_CONFIG['demo']; diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 5a0742c7b..7041d7df8 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -865,23 +865,12 @@ class Application_Model_Preference self::setValue("schema_version", $version); } - public static function GetAirtimeVersion() - { - if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')) { - $version = exec("git rev-parse --short HEAD 2>/dev/null", $out, $return_code); - if ($return_code == 0) { - return self::getValue("system_version")."+".$version.":".time(); - } - } - - return self::getValue("system_version"); - } - public static function GetLatestVersion() { + $config = Config::getConfig(); $latest = self::getValue("latest_version"); if ($latest == null || strlen($latest) == 0) { - return self::GetAirtimeVersion(); + return $config['airtime_version']; } else { return $latest; } diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index 88673e9cd..262aabfd1 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -29,8 +29,9 @@ class UpgradeManager */ public static function getSupportedSchemaVersions() { + $config = Config::getConfig(); //What versions of the schema does the code support today: - return array(AIRTIME_CODE_VERSION); + return array($config['airtime_version']); } public static function checkIfUpgradeIsNeeded() @@ -269,7 +270,6 @@ class AirtimeUpgrader253 extends AirtimeUpgrader Application_Model_Preference::setDiskUsage($diskUsage); - //update system_version in cc_pref and change some columns in cc_files parent::_runUpgrade(); } } diff --git a/airtime_mvc/tests/application/helpers/AirtimeInstall.php b/airtime_mvc/tests/application/helpers/AirtimeInstall.php index 01c1b43b7..f9c059171 100644 --- a/airtime_mvc/tests/application/helpers/AirtimeInstall.php +++ b/airtime_mvc/tests/application/helpers/AirtimeInstall.php @@ -252,10 +252,8 @@ class AirtimeInstall } public static function GetAirtimeVersion() { - $con = Propel::getConnection(); - $sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1"; - $version = $con->query($sql)->fetchColumn(0); - return $version; + $config = Config::getConfig(); + return $config['airtime_version']; } public static function DeleteFilesRecursive($p_path) {