CC-2950: Tell users if they are running an out-of-date version or not
Initial implementation. - added some code in phone_home_stat to retrieve latest version from stat server and store result in db - created new view helper VersionNotify.php, which queries and calculates version difference, then returns the necessary information in html to the view files - created new javascript file versiontooltip.js, which sets up the qtip stuff so that when the version notification icon is clicked, a tooltip is displayed
This commit is contained in:
parent
1c5b2dc813
commit
1a1db1892f
14 changed files with 172 additions and 2 deletions
|
@ -53,6 +53,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/redmond/jquery-ui-1.8.8.custom.css');
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/pro_dropdown_3.css');
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/styles.css');
|
||||
}
|
||||
|
||||
|
@ -71,6 +72,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
//scripts for now playing bar
|
||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
|
||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
|
||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript');
|
||||
|
||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
|
||||
|
||||
|
||||
$this->_helper->layout->setLayout('library');
|
||||
|
|
|
@ -56,7 +56,6 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
|
||||
|
||||
Application_Model_Schedule::createNewFormSections($this->view);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
<div id="Panel">
|
||||
<div class="logo"></div>
|
||||
<?php echo $this->versionNotify() ?>
|
||||
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
|
||||
|
||||
<?php $partial = array('menu.phtml', 'default');
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
<div id="Panel">
|
||||
<div class="logo"></div>
|
||||
<?php echo $this->versionNotify() ?>
|
||||
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
|
||||
|
||||
<?php $partial = array('menu.phtml', 'default');
|
||||
|
|
|
@ -516,6 +516,23 @@ class Application_Model_Preference
|
|||
public static function GetAirtimeVersion(){
|
||||
return self::GetValue("system_version");
|
||||
}
|
||||
|
||||
public static function GetLatestVersion(){
|
||||
$latest = self::GetValue("latest_version");
|
||||
if($latest == null || strlen($latest) == 0) {
|
||||
return self::GetAirtimeVersion();
|
||||
} else {
|
||||
return $latest;
|
||||
}
|
||||
}
|
||||
|
||||
public static function SetLatestVersion($version){
|
||||
$pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/";
|
||||
if(!preg_match($pattern, $version)) {
|
||||
$version = self::GetAirtimeVersion();
|
||||
}
|
||||
self::SetValue("latest_version", $version);
|
||||
}
|
||||
|
||||
public static function SetUploadToSoundcloudOption($upload) {
|
||||
self::SetValue("soundcloud_upload_option", $upload);
|
||||
|
|
61
airtime_mvc/application/views/helpers/VersionNotify.php
Normal file
61
airtime_mvc/application/views/helpers/VersionNotify.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file does the following things:
|
||||
* 1. Calculate how many major versions back the current installation
|
||||
* is from the latest release
|
||||
* 2. Returns the matching icon based on result of 1, as HTML
|
||||
* 3. Returns the matching tooltip message based on result of 1, as HTML
|
||||
* (stored in pair of invisible div tags)
|
||||
* 4. Returns the current version, as HTML (stored in pair of invisible div tags)
|
||||
*/
|
||||
class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
|
||||
|
||||
public function versionNotify(){
|
||||
if(Application_Model_Preference::GetPlanLevel() != 'disabled'){
|
||||
return "";
|
||||
}
|
||||
|
||||
// retrieve and validate current and latest versions,
|
||||
$current = Application_Model_Preference::GetAirtimeVersion();
|
||||
$latest = Application_Model_Preference::GetLatestVersion();
|
||||
$pattern = "/^([0-9]+)\.([0-9]+)\.[0-9]+/";
|
||||
preg_match($pattern, $current, $curMatch);
|
||||
preg_match($pattern, $latest, $latestMatch);
|
||||
if(count($curMatch) == 0 || count($latestMatch) == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Calculate version diff
|
||||
// Note: algorithm assumes the number after 1st dot never goes above 9
|
||||
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
|
||||
- (intval($curMatch[1]) * 10 + intval($curMatch[2]));
|
||||
|
||||
// Pick icon and tooltip msg
|
||||
$bg = "/css/images/";
|
||||
$msg = "";
|
||||
$link = "<a href='http://apt.sourcefabric.org/misc/'>" . $latest . "</a>";
|
||||
if(($diff == 0 && $current == $latest) || $diff < 0) {
|
||||
// current version is up to date
|
||||
$bg .= "icon_uptodate.png";
|
||||
$msg = "You are running the latest version";
|
||||
} else if($diff <= 2) {
|
||||
// 2 or less major versions back
|
||||
$bg .= "icon_update.png";
|
||||
$msg = "New version available: " . $link;
|
||||
} else if($diff == 3) {
|
||||
// 3 major versions back
|
||||
$bg .= "icon_update2.png";
|
||||
$msg = "This version will soon be obsolete.<br/>Please upgrade to " . $link;
|
||||
} else {
|
||||
// more than 3 major versions back
|
||||
$bg .= "icon_outdated.png";
|
||||
$msg = "This version is no longer supported.<br/>Please upgrade to " . $link;
|
||||
}
|
||||
|
||||
$result = "<div id='version_message' style='display:none'>" . $msg . "</div>"
|
||||
. "<div id='version_current' style='display:none'>" . $current . "</div>"
|
||||
. "<div id='version_icon' style='background-image: url(" . $bg . ");'></div>";
|
||||
return $result;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue