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/redmond/jquery-ui-1.8.8.custom.css');
|
||||||
$view->headLink()->appendStylesheet($baseUrl.'/css/pro_dropdown_3.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');
|
$view->headLink()->appendStylesheet($baseUrl.'/css/styles.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
//scripts for now playing bar
|
//scripts for now playing bar
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
|
$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/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');
|
$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/media_library.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.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');
|
$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/colorpicker/css/colorpicker.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.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);
|
Application_Model_Schedule::createNewFormSections($this->view);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<div id="Panel">
|
<div id="Panel">
|
||||||
<div class="logo"></div>
|
<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 echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
|
||||||
|
|
||||||
<?php $partial = array('menu.phtml', 'default');
|
<?php $partial = array('menu.phtml', 'default');
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<div id="Panel">
|
<div id="Panel">
|
||||||
<div class="logo"></div>
|
<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 echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
|
||||||
|
|
||||||
<?php $partial = array('menu.phtml', 'default');
|
<?php $partial = array('menu.phtml', 'default');
|
||||||
|
|
|
@ -517,6 +517,23 @@ class Application_Model_Preference
|
||||||
return self::GetValue("system_version");
|
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) {
|
public static function SetUploadToSoundcloudOption($upload) {
|
||||||
self::SetValue("soundcloud_upload_option", $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;
|
||||||
|
}
|
||||||
|
}
|
BIN
airtime_mvc/public/css/images/icon_outdated.png
Normal file
BIN
airtime_mvc/public/css/images/icon_outdated.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
airtime_mvc/public/css/images/icon_update.png
Normal file
BIN
airtime_mvc/public/css/images/icon_update.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
airtime_mvc/public/css/images/icon_update2.png
Normal file
BIN
airtime_mvc/public/css/images/icon_update2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
airtime_mvc/public/css/images/icon_uptodate.png
Normal file
BIN
airtime_mvc/public/css/images/icon_uptodate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -57,6 +57,31 @@ select {
|
||||||
display:block;
|
display:block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Version Notification Starts*/
|
||||||
|
#version_icon {
|
||||||
|
position:absolute;
|
||||||
|
right:85px;
|
||||||
|
top:104px;
|
||||||
|
height:35px;
|
||||||
|
width:35px;
|
||||||
|
z-index:1000;
|
||||||
|
display:block;
|
||||||
|
cursor:pointer;
|
||||||
|
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
background-position:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ui-tooltip-version a {
|
||||||
|
color:#ff5d1a;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ui-tooltip-version {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
/* Version Notification Ends*/
|
||||||
|
|
||||||
/* Clearfix */
|
/* Clearfix */
|
||||||
.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;}
|
.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;}
|
||||||
.clearfix, li { display: inline-block; }
|
.clearfix, li { display: inline-block; }
|
||||||
|
|
53
airtime_mvc/public/js/airtime/dashboard/versiontooltip.js
Normal file
53
airtime_mvc/public/js/airtime/dashboard/versiontooltip.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
* Get the tooltip message to be displayed,
|
||||||
|
* which is stored inside a pair of hidden div tags
|
||||||
|
*/
|
||||||
|
function getContent() {
|
||||||
|
return $("#version_message").html();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current version,
|
||||||
|
* which is stored inside a pair of hidden div tags
|
||||||
|
*/
|
||||||
|
function getCurrentVersion() {
|
||||||
|
return $("#version_current").html();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the tooltip for version notification
|
||||||
|
*/
|
||||||
|
function setupVersionQtip(){
|
||||||
|
var qtipElem = $('#version_icon');
|
||||||
|
if (qtipElem.length > 0){
|
||||||
|
qtipElem.qtip({
|
||||||
|
id: 'version',
|
||||||
|
content: {
|
||||||
|
text: getContent(),
|
||||||
|
title: {
|
||||||
|
text: getCurrentVersion(),
|
||||||
|
button: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
show: 'click', /* Show on click */
|
||||||
|
hide: false, /* Don't hide on mouseout */
|
||||||
|
position: {
|
||||||
|
my: "top right",
|
||||||
|
at: "bottom left"
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
border: {
|
||||||
|
width: 0,
|
||||||
|
radius: 4
|
||||||
|
},
|
||||||
|
classes: "ui-tooltip-dark ui-tooltip-rounded"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
if($('#version_message').length > 0) {
|
||||||
|
setupVersionQtip();
|
||||||
|
}
|
||||||
|
});
|
|
@ -74,6 +74,18 @@ if(Application_Model_Preference::GetSupportFeedback() == '1'){
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get latest version from stat server and store to db
|
||||||
|
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
|
||||||
|
$url = 'http://stat-dev.sourcefabric.org/airtime_latest_version';
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
|
||||||
|
Application_Model_Preference::SetLatestVersion($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the user is running this PHP script with root
|
* Ensures that the user is running this PHP script with root
|
||||||
* permissions. If not running with root permissions, causes the
|
* permissions. If not running with root permissions, causes the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue