Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
Conflicts: airtime_mvc/application/models/DateHelper.php airtime_mvc/application/models/Show.php
|
@ -68,7 +68,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
public function eventFeedAction()
|
||||
{
|
||||
$start = new DateTime($this->_getParam('start', null));
|
||||
$start->setTimezone(new DateTimeZone("UTC"));
|
||||
$end = new DateTime($this->_getParam('end', null));
|
||||
$end->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
@ -113,7 +115,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
||||
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
try{
|
||||
$show = new Application_Model_ShowInstance($showInstanceId);
|
||||
}catch(Exception $e){
|
||||
|
@ -123,9 +125,10 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$error = $show->resizeShow($deltaDay, $deltaMin);
|
||||
}
|
||||
|
||||
if(isset($error))
|
||||
if (isset($error)) {
|
||||
$this->view->error = $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteShowAction()
|
||||
{
|
||||
|
@ -430,7 +433,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$originalShowName = $originalShow->getName();
|
||||
$originalShowStart = $originalShow->getShowInstanceStart();
|
||||
|
||||
$timestamp = strtotime($originalShowStart);
|
||||
//convert from UTC to user's timezone for display.
|
||||
$originalDateTime = new DateTime($originalShowStart, new DateTimeZone("UTC"));
|
||||
$timestamp = strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s")));
|
||||
$this->view->additionalShowInfo =
|
||||
"Rebroadcast of show \"$originalShowName\" from "
|
||||
.date("l, F jS", $timestamp)." at ".date("G:i", $timestamp);
|
||||
|
|
|
@ -224,8 +224,13 @@ class Application_Model_DateHelper
|
|||
return $totalSeconds;
|
||||
}
|
||||
|
||||
public static function ConvertToUtcDateTime($p_dateString, $timezone){
|
||||
public static function ConvertToUtcDateTime($p_dateString, $timezone=null){
|
||||
if (isset($timezone)) {
|
||||
$dateTime = new DateTime($p_dateString, new DateTimeZone($timezone));
|
||||
}
|
||||
else {
|
||||
$dateTime = new DateTime($p_dateString, new DateTimeZone(date_default_timezone_get()));
|
||||
}
|
||||
$dateTime->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
return $dateTime;
|
||||
|
|
|
@ -1030,7 +1030,9 @@ class Application_Model_Show {
|
|||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration);
|
||||
Logging::log('$start time of non repeating record '.$start);
|
||||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1042,9 +1044,9 @@ class Application_Model_Show {
|
|||
* @param array $p_showRow
|
||||
* A row from cc_show_days table
|
||||
* @param DateTime $p_dateTime
|
||||
* DateTime object in UTC time.
|
||||
* DateTime object in UTC time. "shows_populated_until" date YY-mm-dd in cc_pref
|
||||
* @param string $p_interval
|
||||
* Period of time between repeating shows
|
||||
* Period of time between repeating shows (in php DateInterval notation 'P7D')
|
||||
*/
|
||||
private static function populateRepeatingShow($p_showRow, $p_dateTime, $p_interval)
|
||||
{
|
||||
|
@ -1060,6 +1062,8 @@ class Application_Model_Show {
|
|||
$record = $p_showRow["record"];
|
||||
$timezone = $p_showRow["timezone"];
|
||||
|
||||
$date = new Application_Model_DateHelper();
|
||||
$currentUtcTimestamp = $date->getUtcTimestamp();
|
||||
|
||||
if(isset($next_pop_date)) {
|
||||
$start = $next_pop_date." ".$start_time;
|
||||
|
@ -1068,17 +1072,16 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
|
||||
//convert $last_show into a UTC DateTime object, or null if there is no last show.
|
||||
$utcLastShowDateTime = $last_show ? Application_Model_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
||||
$show = new Application_Model_Show($show_id);
|
||||
|
||||
$date = new Application_Model_DateHelper();
|
||||
$currentUtcTimestamp = $date->getUtcTimestamp();
|
||||
|
||||
while($utcStartDateTime->getTimestamp()
|
||||
<= $p_dateTime->getTimestamp() &&
|
||||
($utcStartDateTime->getTimestamp() < strtotime($last_show) || is_null($last_show))) {
|
||||
while($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp()
|
||||
&& (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){
|
||||
|
||||
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
|
||||
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
|
||||
|
@ -1113,7 +1116,7 @@ class Application_Model_Show {
|
|||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration);
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
|
||||
$dt = new DateTime($start, new DateTimeZone($timezone));
|
||||
$dt->add(new DateInterval($p_interval));
|
||||
|
@ -1127,23 +1130,49 @@ class Application_Model_Show {
|
|||
Application_Model_Show::setNextPop($start, $show_id, $day);
|
||||
}
|
||||
|
||||
private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_utcStartDateTime, $p_duration){
|
||||
/* Create rebroadcast instances for a created show marked for recording
|
||||
*
|
||||
* @param $p_rebroadcasts rows gotten from the db table cc_show_rebroadcasts, tells airtime when to schedule the rebroadcasts.
|
||||
* @param $p_currentUtcTimestamp a timestring in format "Y-m-d H:i:s", current UTC time.
|
||||
* @param $p_showId int of the show it belongs to (from cc_show)
|
||||
* @param $p_showInstanceId the instance id of the created recorded show instance
|
||||
* (from cc_show_instances), used to associate rebroadcasts to this show.
|
||||
* @param $p_startTime a timestring in format "Y-m-d H:i:s" in the timezone, not UTC of the rebroadcasts' parent recorded show.
|
||||
* @param $p_duration duration of the show in format 1:0
|
||||
* @param $p_timezone string of user's timezone "Europe/Prague"
|
||||
*
|
||||
*/
|
||||
private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_startTime, $p_duration, $p_timezone=null){
|
||||
global $CC_DBC;
|
||||
|
||||
foreach($p_rebroadcasts as $rebroadcast) {
|
||||
$timeinfo = $p_utcStartDateTime->format("Y-m-d H:i:s");
|
||||
Logging::log('Count of rebroadcasts '. count($p_rebroadcasts));
|
||||
|
||||
$sql = "SELECT timestamp '{$timeinfo}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||
foreach($p_rebroadcasts as $rebroadcast) {
|
||||
|
||||
//use only the date part of the show start time stamp for the offsets to work properly.
|
||||
$sql = "SELECT date '{$p_startTime}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
||||
Logging::log('rebroadcast start '.$rebroadcast_start_time);
|
||||
|
||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'";
|
||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||
Logging::log('rebroadcast end '.$rebroadcast_end_time);
|
||||
|
||||
//convert to UTC, after we have used the defined offsets to calculate rebroadcasts.
|
||||
$utc_rebroadcast_start_time = Application_Model_DateHelper::ConvertToUtcDateTime($rebroadcast_start_time, $p_timezone);
|
||||
$utc_rebroadcast_end_time = Application_Model_DateHelper::ConvertToUtcDateTime($rebroadcast_end_time, $p_timezone);
|
||||
|
||||
Logging::log('UTC rebroadcast start '.$utc_rebroadcast_start_time->format("Y-m-d H:i:s"));
|
||||
Logging::log('UTC rebroadcast end '.$utc_rebroadcast_end_time->format("Y-m-d H:i:s"));
|
||||
Logging::log('Current UTC timestamp '.$p_currentUtcTimestamp);
|
||||
|
||||
if ($utc_rebroadcast_start_time->format("Y-m-d H:i:s") > $p_currentUtcTimestamp){
|
||||
Logging::log('Creating rebroadcast show starting at UTC '.$utc_rebroadcast_start_time->format("Y-m-d H:i:s"));
|
||||
|
||||
if ($rebroadcast_start_time > $p_currentUtcTimestamp){
|
||||
$newRebroadcastInstance = new CcShowInstances();
|
||||
$newRebroadcastInstance->setDbShowId($p_showId);
|
||||
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
||||
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
|
||||
$newRebroadcastInstance->setDbStarts($utc_rebroadcast_start_time->format("Y-m-d H:i:s"));
|
||||
$newRebroadcastInstance->setDbEnds($utc_rebroadcast_end_time->format("Y-m-d H:i:s"));
|
||||
$newRebroadcastInstance->setDbRecord(0);
|
||||
$newRebroadcastInstance->setDbRebroadcast(1);
|
||||
$newRebroadcastInstance->setDbOriginalShow($p_showInstanceId);
|
||||
|
@ -1167,6 +1196,7 @@ class Application_Model_Show {
|
|||
{
|
||||
global $CC_DBC;
|
||||
|
||||
//UTC DateTime object
|
||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
//if application is requesting shows past our previous populated until date, generate shows up until this point.
|
||||
|
@ -1273,7 +1303,8 @@ class Application_Model_Show {
|
|||
|
||||
$shows = Application_Model_Show::getShows($start, $end);
|
||||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$today_timestamp = Application_Model_DateHelper::ConvertToUtcDateTime(date("Y-m-d H:i:s"))->format("Y-m-d H:i:s");
|
||||
|
||||
foreach ($shows as $show) {
|
||||
|
||||
if ($show["deleted_instance"] != "t"){
|
||||
|
|
|
@ -251,7 +251,7 @@ class Application_Model_ShowInstance {
|
|||
|
||||
$mins = abs($deltaMin%60);
|
||||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$today_timestamp = Application_Model_DateHelper::ConvertToUtcDateTime(date("Y-m-d H:i:s"))->format("Y-m-d H:i:s");
|
||||
$starts = $this->getShowInstanceStart();
|
||||
$ends = $this->getShowInstanceEnd();
|
||||
|
||||
|
@ -264,8 +264,11 @@ class Application_Model_ShowInstance {
|
|||
|
||||
//only need to check overlap if show increased in size.
|
||||
if(strtotime($new_ends) > strtotime($ends)) {
|
||||
//TODO --martin
|
||||
$overlap = Application_Model_Show::getShows($ends, $new_ends);
|
||||
|
||||
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
|
||||
$utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
|
||||
|
||||
$overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime);
|
||||
|
||||
if(count($overlap) > 0) {
|
||||
return "Should not overlap shows";
|
||||
|
|
|
@ -96,24 +96,25 @@ class Application_Model_Systemstatus
|
|||
}
|
||||
|
||||
public static function GetPlatformInfo(){
|
||||
$data = array("release"=>"UNKNOWN",
|
||||
"machine"=>"UNKNOWN",
|
||||
"memory"=>"UNKNOWN",
|
||||
"swap"=>"UNKNOWN");
|
||||
$keys = array("release", "machine", "memory", "swap");
|
||||
foreach($keys as $key) {
|
||||
$data[$key] = "UNKNOWN";
|
||||
}
|
||||
|
||||
$docRoot = self::GetMonitStatus("localhost");
|
||||
if (!is_null($docRoot)){
|
||||
foreach ($docRoot->getElementsByTagName("platform") AS $item)
|
||||
{
|
||||
$data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue;
|
||||
$data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue;
|
||||
$data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue;
|
||||
$data["swap"] = $item->getElementsByTagName("swap")->item(0)->nodeValue;
|
||||
foreach($keys as $key) {
|
||||
$keyElement = $item->getElementsByTagName($key);
|
||||
if($keyElement->length > 0) {
|
||||
$data[$key] = $keyElement->item(0)->nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
public static function GetPypoStatus(){
|
||||
|
|
|
@ -26,36 +26,31 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
|
|||
return "";
|
||||
}
|
||||
|
||||
// Calculate version diff
|
||||
// Calculate major version diff;
|
||||
// Example: if current = 1.9.5 and latest = 3.0.0, major diff = 11
|
||||
// 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>";
|
||||
// Pick icon
|
||||
if(($diff == 0 && $current == $latest) || $diff < 0) {
|
||||
// current version is up to date
|
||||
$bg .= "icon_uptodate.png";
|
||||
$msg = "You are running the latest version";
|
||||
$class = "uptodate";
|
||||
} else if($diff <= 2) {
|
||||
// 2 or less major versions back
|
||||
$bg .= "icon_update.png";
|
||||
$msg = "New version available: " . $link;
|
||||
$class = "update";
|
||||
} else if($diff == 3) {
|
||||
// 3 major versions back
|
||||
$bg .= "icon_update2.png";
|
||||
$msg = "This version will soon be obsolete.<br/>Please upgrade to " . $link;
|
||||
$class = "update2";
|
||||
} else {
|
||||
// more than 3 major versions back
|
||||
$bg .= "icon_outdated.png";
|
||||
$msg = "This version is no longer supported.<br/>Please upgrade to " . $link;
|
||||
$class = "outdated";
|
||||
}
|
||||
|
||||
$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>";
|
||||
$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-icon' class='" . $class . "'></div>";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 5.0 KiB |
|
@ -58,19 +58,30 @@ select {
|
|||
}
|
||||
|
||||
/* Version Notification Starts*/
|
||||
#version_icon {
|
||||
#version-icon {
|
||||
position:absolute;
|
||||
right:85px;
|
||||
right:96px;
|
||||
top:104px;
|
||||
height:35px;
|
||||
width:35px;
|
||||
z-index:1000;
|
||||
display:block;
|
||||
cursor:pointer;
|
||||
|
||||
background-repeat:no-repeat;
|
||||
background-position:center;
|
||||
}
|
||||
#version-icon.outdated {
|
||||
background-image:url(/css/images/icon_outdated.png);
|
||||
}
|
||||
#version-icon.update2 {
|
||||
background-image:url(/css/images/icon_update2.png);
|
||||
}
|
||||
#version-icon.update {
|
||||
background-image:url(/css/images/icon_update.png);
|
||||
}
|
||||
#version-icon.uptodate {
|
||||
background-image:url(/css/images/icon_uptodate.png);
|
||||
}
|
||||
|
||||
#ui-tooltip-version a {
|
||||
color:#ff5d1a;
|
||||
|
@ -2366,6 +2377,9 @@ tfoot tr th {
|
|||
margin:2px 1px 10px 0px;
|
||||
width: auto;
|
||||
}
|
||||
dd .stream-status {
|
||||
margin-bottom:1px;
|
||||
}
|
||||
.stream-status h3 {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
|
@ -2398,3 +2412,17 @@ tfoot tr th {
|
|||
.status-error h3 {
|
||||
color:#DA0101;
|
||||
}
|
||||
.status-info {
|
||||
background:#fff7e0 url(images/stream_status.png) no-repeat 5px -278px;
|
||||
border-color:#f68826;
|
||||
}
|
||||
.status-info h3 {
|
||||
color:#f1830c;
|
||||
}
|
||||
.status-disabled {
|
||||
background:#c8ccc8 url(images/stream_status.png) no-repeat 5px -429px;
|
||||
border-color:#7f827f;
|
||||
}
|
||||
.status-disabled h3 {
|
||||
color:#646664;
|
||||
}
|
|
@ -1,24 +1,68 @@
|
|||
/**
|
||||
* Get the tooltip message to be displayed,
|
||||
* which is stored inside a pair of hidden div tags
|
||||
* Get the tooltip message to be displayed
|
||||
*/
|
||||
function getContent() {
|
||||
return $("#version_message").html();
|
||||
var diff = getVersionDiff();
|
||||
var link = getLatestLink();
|
||||
|
||||
var msg = "";
|
||||
if(isUpToDate()) {
|
||||
msg = "You are running the latest version";
|
||||
} else if(diff <= 2) {
|
||||
msg = "New version available: " + link;
|
||||
} else if(diff == 3) {
|
||||
msg = "This version will soon be obsolete.<br/>Please upgrade to " + link;
|
||||
} else {
|
||||
msg = "This version is no longer supported.<br/>Please upgrade to " + link;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version,
|
||||
* which is stored inside a pair of hidden div tags
|
||||
* Get major version difference b/w current and latest version, in int
|
||||
*/
|
||||
function getVersionDiff() {
|
||||
return parseInt($("#version-diff").html());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version
|
||||
*/
|
||||
function getCurrentVersion() {
|
||||
return $("#version_current").html();
|
||||
return $("#version-current").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version
|
||||
*/
|
||||
function getLatestVersion() {
|
||||
return $("#version-latest").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current version is up to date
|
||||
*/
|
||||
function isUpToDate() {
|
||||
var diff = getVersionDiff();
|
||||
var current = getCurrentVersion();
|
||||
var latest = getLatestVersion();
|
||||
var temp = (diff == 0 && current == latest) || diff < 0;
|
||||
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
|
||||
*/
|
||||
function setupVersionQtip(){
|
||||
var qtipElem = $('#version_icon');
|
||||
var qtipElem = $('#version-icon');
|
||||
if (qtipElem.length > 0){
|
||||
qtipElem.qtip({
|
||||
id: 'version',
|
||||
|
@ -26,10 +70,12 @@ function setupVersionQtip(){
|
|||
text: getContent(),
|
||||
title: {
|
||||
text: getCurrentVersion(),
|
||||
button: true
|
||||
button: isUpToDate() ? false : true
|
||||
}
|
||||
},
|
||||
hide: false, /* Don't hide on mouseout */
|
||||
hide: {
|
||||
event: isUpToDate() ? 'mouseleave' : 'unfocus'
|
||||
},
|
||||
position: {
|
||||
my: "top right",
|
||||
at: "bottom left"
|
||||
|
@ -46,7 +92,7 @@ function setupVersionQtip(){
|
|||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if($('#version_message').length > 0) {
|
||||
if($('#version-icon').length > 0) {
|
||||
setupVersionQtip();
|
||||
}
|
||||
});
|