CC-2950: Tell users if they are running an out-of-date version or not
Get rid of hardcoded url for downloading the latest version, and use the url stored in the stat server instead
This commit is contained in:
parent
d836425931
commit
eae90862b1
4 changed files with 25 additions and 8 deletions
|
@ -526,6 +526,19 @@ class Application_Model_Preference
|
|||
self::SetValue("latest_version", $version);
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetLatestLink(){
|
||||
$link = self::GetValue("latest_link");
|
||||
if($link == null || strlen($link) == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
public static function SetLatestLink($link){
|
||||
self::SetValue("latest_link", $link);
|
||||
}
|
||||
|
||||
public static function SetUploadToSoundcloudOption($upload) {
|
||||
self::SetValue("soundcloud_upload_option", $upload);
|
||||
|
|
|
@ -19,6 +19,7 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
|
|||
// retrieve and validate current and latest versions,
|
||||
$current = Application_Model_Preference::GetAirtimeVersion();
|
||||
$latest = Application_Model_Preference::GetLatestVersion();
|
||||
$link = Application_Model_Preference::GetLatestLink();
|
||||
$pattern = "/^([0-9]+)\.([0-9]+)\.[0-9]+/";
|
||||
preg_match($pattern, $current, $curMatch);
|
||||
preg_match($pattern, $latest, $latestMatch);
|
||||
|
@ -50,6 +51,7 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
|
|||
$result = "<div id='version-diff' style='display:none'>" . $diff . "</div>"
|
||||
. "<div id='version-current' style='display:none'>" . $current . "</div>"
|
||||
. "<div id='version-latest' style='display:none'>" . $latest . "</div>"
|
||||
. "<div id='version-link' style='display:none'>" . $link . "</div>"
|
||||
. "<div id='version-icon' class='" . $class . "'></div>";
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,13 @@ function getLatestVersion() {
|
|||
return $("#version-latest").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download link to latest release in HTML
|
||||
*/
|
||||
function getLatestLink() {
|
||||
return "<a href='" + $("#version-link").html() + "'>" + getLatestVersion() + "</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current version is up to date
|
||||
*/
|
||||
|
@ -51,13 +58,6 @@ function isUpToDate() {
|
|||
return (diff == 0 && current == latest) || diff < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download link to latest release in HTML
|
||||
*/
|
||||
function getLatestLink() {
|
||||
return "<a href='http://apt.sourcefabric.org/misc/'>" + getLatestVersion() + "</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the tooltip for version notification
|
||||
*/
|
||||
|
|
|
@ -82,8 +82,10 @@ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
|
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
$result = curl_exec($ch);
|
||||
$resultArray = explode("\n", $result);
|
||||
|
||||
Application_Model_Preference::SetLatestVersion($result);
|
||||
Application_Model_Preference::SetLatestVersion($resultArray[0]);
|
||||
Application_Model_Preference::SetLatestLink($resultArray[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue