Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

Conflicts:
	airtime_mvc/application/models/DateHelper.php
	airtime_mvc/application/models/Show.php
This commit is contained in:
Martin Konecny 2011-11-15 16:14:00 -05:00
commit e5fc5d623d
13 changed files with 356 additions and 242 deletions

View File

@ -56,7 +56,7 @@ 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');
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -68,7 +68,9 @@ class ScheduleController extends Zend_Controller_Action
public function eventFeedAction() public function eventFeedAction()
{ {
$start = new DateTime($this->_getParam('start', null)); $start = new DateTime($this->_getParam('start', null));
$start->setTimezone(new DateTimeZone("UTC"));
$end = new DateTime($this->_getParam('end', null)); $end = new DateTime($this->_getParam('end', null));
$end->setTimezone(new DateTimeZone("UTC"));
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id); $user = new Application_Model_User($userInfo->id);
@ -113,7 +115,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id); $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{ try{
$show = new Application_Model_ShowInstance($showInstanceId); $show = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){ }catch(Exception $e){
@ -123,8 +125,9 @@ class ScheduleController extends Zend_Controller_Action
$error = $show->resizeShow($deltaDay, $deltaMin); $error = $show->resizeShow($deltaDay, $deltaMin);
} }
if(isset($error)) if (isset($error)) {
$this->view->error = $error; $this->view->error = $error;
}
} }
public function deleteShowAction() public function deleteShowAction()
@ -141,7 +144,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true; $this->view->show_error = true;
return false; return false;
} }
$show->deleteShow(); $show->deleteShow();
} }
} }
@ -177,15 +180,15 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true; $this->view->show_error = true;
return false; return false;
} }
$params = '/format/json/id/#id#'; $params = '/format/json/id/#id#';
$showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceStart()); $showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceStart());
$showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceEnd()); $showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceEnd());
$menu = array(); $menu = array();
if ($epochNow < $showStartDateHelper->getTimestamp()) { if ($epochNow < $showStartDateHelper->getTimestamp()) {
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
@ -239,7 +242,7 @@ class ScheduleController extends Zend_Controller_Action
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
} }
} }
//returns format jjmenu is looking for. //returns format jjmenu is looking for.
die(json_encode($menu)); die(json_encode($menu));
} }
@ -325,12 +328,12 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true; $this->view->show_error = true;
return false; return false;
} }
$playlists = $show->searchPlaylistsForShow($post); $playlists = $show->searchPlaylistsForShow($post);
foreach( $playlists['aaData'] as &$data){ foreach( $playlists['aaData'] as &$data){
// calling two functions to format time to 1 decimal place // calling two functions to format time to 1 decimal place
$sec = Application_Model_Playlist::playlistTimeToSeconds($data[4]); $sec = Application_Model_Playlist::playlistTimeToSeconds($data[4]);
$data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec); $data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec);
} }
//for datatables //for datatables
@ -374,13 +377,13 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_error = true; $this->view->show_error = true;
return false; return false;
} }
$start_timestamp = $show->getShowInstanceStart(); $start_timestamp = $show->getShowInstanceStart();
$end_timestamp = $show->getShowInstanceEnd(); $end_timestamp = $show->getShowInstanceEnd();
//check to make sure show doesn't overlap. //check to make sure show doesn't overlap.
if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")), if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")),
new DateTime($end_timestamp, new DateTimeZone("UTC")), new DateTime($end_timestamp, new DateTimeZone("UTC")),
array($showInstanceId))) { array($showInstanceId))) {
$this->view->error = "cannot schedule an overlapping show."; $this->view->error = "cannot schedule an overlapping show.";
return; return;
@ -388,7 +391,7 @@ class ScheduleController extends Zend_Controller_Action
$dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp))); $dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp)));
$dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp))); $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp)));
$this->view->showContent = $show->getShowContent(); $this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled(); $this->view->timeFilled = $show->getTimeScheduled();
$this->view->showName = $show->getName(); $this->view->showName = $show->getName();
@ -430,7 +433,9 @@ class ScheduleController extends Zend_Controller_Action
$originalShowName = $originalShow->getName(); $originalShowName = $originalShow->getName();
$originalShowStart = $originalShow->getShowInstanceStart(); $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 = $this->view->additionalShowInfo =
"Rebroadcast of show \"$originalShowName\" from " "Rebroadcast of show \"$originalShowName\" from "
.date("l, F jS", $timestamp)." at ".date("G:i", $timestamp); .date("l, F jS", $timestamp)." at ".date("G:i", $timestamp);
@ -447,7 +452,7 @@ class ScheduleController extends Zend_Controller_Action
if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
return; return;
} }
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$showInstanceId = $this->_getParam('id'); $showInstanceId = $this->_getParam('id');
@ -484,10 +489,10 @@ class ScheduleController extends Zend_Controller_Action
'add_show_url' => $show->getUrl(), 'add_show_url' => $show->getUrl(),
'add_show_genre' => $show->getGenre(), 'add_show_genre' => $show->getGenre(),
'add_show_description' => $show->getDescription())); 'add_show_description' => $show->getDescription()));
$startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone(date_default_timezone_get())); $startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone(date_default_timezone_get()));
$endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone(date_default_timezone_get())); $endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone(date_default_timezone_get()));
//$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); //$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
//$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); //$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -525,27 +530,27 @@ class ScheduleController extends Zend_Controller_Action
$formWho->populate(array('add_show_hosts' => $hosts)); $formWho->populate(array('add_show_hosts' => $hosts));
$formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(),
'add_show_color' => $show->getColor())); 'add_show_color' => $show->getColor()));
if(!$isSaas){ if(!$isSaas){
$formRecord = new Application_Form_AddShowRR(); $formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper');
$this->view->rr = $formRecord; $this->view->rr = $formRecord;
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$this->view->rebroadcast = $formRebroadcast; $this->view->rebroadcast = $formRebroadcast;
$formRecord->populate(array('add_show_record' => $show->isRecorded(), $formRecord->populate(array('add_show_record' => $show->isRecorded(),
'add_show_rebroadcast' => $show->isRebroadcast())); 'add_show_rebroadcast' => $show->isRebroadcast()));
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
$rebroadcastsRelative = $show->getRebroadcastsRelative(); $rebroadcastsRelative = $show->getRebroadcastsRelative();
$rebroadcastFormValues = array(); $rebroadcastFormValues = array();
$i = 1; $i = 1;
@ -555,7 +560,7 @@ class ScheduleController extends Zend_Controller_Action
$i++; $i++;
} }
$formRebroadcast->populate($rebroadcastFormValues); $formRebroadcast->populate($rebroadcastFormValues);
$rebroadcastsAbsolute = $show->getRebroadcastsAbsolute(); $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
$rebroadcastAbsoluteFormValues = array(); $rebroadcastAbsoluteFormValues = array();
$i = 1; $i = 1;
@ -571,7 +576,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->entries = 5; $this->view->entries = 5;
} }
public function getFormAction(){ public function getFormAction(){
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
$this->view->form = $this->view->render('schedule/add-show-form.phtml'); $this->view->form = $this->view->render('schedule/add-show-form.phtml');
} }
@ -585,7 +590,7 @@ class ScheduleController extends Zend_Controller_Action
foreach($js as $j){ foreach($js as $j){
$data[$j["name"]] = $j["value"]; $data[$j["name"]] = $j["value"];
} }
$show = new Application_Model_Show($data['add_show_id']); $show = new Application_Model_Show($data['add_show_id']);
$startDateModified = true; $startDateModified = true;
@ -602,10 +607,10 @@ class ScheduleController extends Zend_Controller_Action
if($data['add_show_day_check'] == "") { if($data['add_show_day_check'] == "") {
$data['add_show_day_check'] = null; $data['add_show_day_check'] = null;
} }
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$record = false; $record = false;
$formWhat = new Application_Form_AddShowWhat(); $formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho(); $formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen(); $formWhen = new Application_Form_AddShowWhen();
@ -624,8 +629,8 @@ class ScheduleController extends Zend_Controller_Action
$when = $formWhen->checkReliantFields($data, $startDateModified); $when = $formWhen->checkReliantFields($data, $startDateModified);
} }
//The way the following code works is that is parses the hour and //The way the following code works is that is parses the hour and
//minute from a string with the format "1h 20m" or "2h" or "36m". //minute from a string with the format "1h 20m" or "2h" or "36m".
//So we are detecting whether an hour or minute value exists via strpos //So we are detecting whether an hour or minute value exists via strpos
//and then parse appropriately. A better way to do this in the future is //and then parse appropriately. A better way to do this in the future is
@ -633,10 +638,10 @@ class ScheduleController extends Zend_Controller_Action
//have to do this extra String parsing. //have to do this extra String parsing.
$hPos = strpos($data["add_show_duration"], 'h'); $hPos = strpos($data["add_show_duration"], 'h');
$mPos = strpos($data["add_show_duration"], 'm'); $mPos = strpos($data["add_show_duration"], 'm');
$hValue = 0; $hValue = 0;
$mValue = 0; $mValue = 0;
if($hPos !== false){ if($hPos !== false){
$hValue = trim(substr($data["add_show_duration"], 0, $hPos)); $hValue = trim(substr($data["add_show_duration"], 0, $hPos));
} }
@ -644,18 +649,18 @@ class ScheduleController extends Zend_Controller_Action
$hPos = $hPos === FALSE ? 0 : $hPos+1; $hPos = $hPos === FALSE ? 0 : $hPos+1;
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 )); $mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
} }
$data["add_show_duration"] = $hValue.":".$mValue; $data["add_show_duration"] = $hValue.":".$mValue;
if(!$isSaas){ if(!$isSaas){
$formRecord = new Application_Form_AddShowRR(); $formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper');
//If show is a new show (not updated), then get //If show is a new show (not updated), then get
//isRecorded from POST data. Otherwise get it from //isRecorded from POST data. Otherwise get it from
//the database since the user is not allowed to //the database since the user is not allowed to
@ -668,7 +673,7 @@ class ScheduleController extends Zend_Controller_Action
$record = $formRecord->isValid($data); $record = $formRecord->isValid($data);
} }
} }
if($data["add_show_repeats"]) { if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data); $repeats = $formRepeats->isValid($data);
if($repeats) { if($repeats) {
@ -678,7 +683,7 @@ class ScheduleController extends Zend_Controller_Action
$formAbsoluteRebroadcast->reset(); $formAbsoluteRebroadcast->reset();
//make it valid, results don't matter anyways. //make it valid, results don't matter anyways.
$rebroadAb = 1; $rebroadAb = 1;
if ($data["add_show_rebroadcast"]) { if ($data["add_show_rebroadcast"]) {
$rebroad = $formRebroadcast->isValid($data); $rebroad = $formRebroadcast->isValid($data);
if($rebroad) { if($rebroad) {
@ -696,7 +701,7 @@ class ScheduleController extends Zend_Controller_Action
$formRebroadcast->reset(); $formRebroadcast->reset();
//make it valid, results don't matter anyways. //make it valid, results don't matter anyways.
$rebroad = 1; $rebroad = 1;
if ($data["add_show_rebroadcast"]) { if ($data["add_show_rebroadcast"]) {
$rebroadAb = $formAbsoluteRebroadcast->isValid($data); $rebroadAb = $formAbsoluteRebroadcast->isValid($data);
if($rebroadAb) { if($rebroadAb) {
@ -719,10 +724,10 @@ class ScheduleController extends Zend_Controller_Action
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
Application_Model_Show::create($data); Application_Model_Show::create($data);
} }
//send back a new form for the user. //send back a new form for the user.
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} }
}else{ }else{
@ -731,14 +736,14 @@ class ScheduleController extends Zend_Controller_Action
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
Application_Model_Show::create($data); Application_Model_Show::create($data);
} }
//send back a new form for the user. //send back a new form for the user.
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} }
} }
else { else {
$this->view->what = $formWhat; $this->view->what = $formWhat;
$this->view->when = $formWhen; $this->view->when = $formWhen;
$this->view->repeats = $formRepeats; $this->view->repeats = $formRepeats;
@ -750,7 +755,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->rebroadcast = $formRebroadcast; $this->view->rebroadcast = $formRebroadcast;
} }
$this->view->addNewShow = true; $this->view->addNewShow = true;
//the form still needs to be "update" since //the form still needs to be "update" since
//the validity test failed. //the validity test failed.
if ($data['add_show_id'] != -1){ if ($data['add_show_id'] != -1){
@ -818,7 +823,7 @@ class ScheduleController extends Zend_Controller_Action
$file_id = $this->_getParam('id', null); $file_id = $this->_getParam('id', null);
$file = Application_Model_StoredFile::Recall($file_id); $file = Application_Model_StoredFile::Recall($file_id);
$baseUrl = $this->getRequest()->getBaseUrl(); $baseUrl = $this->getRequest()->getBaseUrl();
$url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $url = $file->getRelativeFileUrl($baseUrl).'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url), $menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
@ -827,7 +832,7 @@ class ScheduleController extends Zend_Controller_Action
//returns format jjmenu is looking for. //returns format jjmenu is looking for.
die(json_encode($menu)); die(json_encode($menu));
} }
/** /**
* Sets the user specific preference for which time scale to use in Calendar. * Sets the user specific preference for which time scale to use in Calendar.
* This is only being used by schedule.js at the moment. * This is only being used by schedule.js at the moment.
@ -835,7 +840,7 @@ class ScheduleController extends Zend_Controller_Action
public function setTimeScaleAction() { public function setTimeScaleAction() {
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale')); Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
} }
/** /**
* Sets the user specific preference for which time interval to use in Calendar. * Sets the user specific preference for which time interval to use in Calendar.
* This is only being used by schedule.js at the moment. * This is only being used by schedule.js at the moment.

View File

@ -17,7 +17,7 @@ class Application_Model_DateHelper
{ {
return date("Y-m-d H:i:s", $this->_dateTime); return date("Y-m-d H:i:s", $this->_dateTime);
} }
/** /**
* Get time of object construction in the format * Get time of object construction in the format
* YYYY-MM-DD HH:mm:ss * YYYY-MM-DD HH:mm:ss
@ -59,10 +59,10 @@ class Application_Model_DateHelper
/** /**
* Calculate and return the timestamp for end of day today * Calculate and return the timestamp for end of day today
* in local time. * in local time.
* *
* For example, if local time is 2PM on 2011-11-01, * For example, if local time is 2PM on 2011-11-01,
* then the function would return 2011-11-02 00:00:00 * then the function would return 2011-11-02 00:00:00
* *
* @return End of day timestamp in local timezone * @return End of day timestamp in local timezone
*/ */
function getDayEndTimestamp() { function getDayEndTimestamp() {
@ -70,7 +70,7 @@ class Application_Model_DateHelper
$dateTime->add(new DateInterval('P1D')); $dateTime->add(new DateInterval('P1D'));
return $dateTime->format('Y-m-d H:i:s'); return $dateTime->format('Y-m-d H:i:s');
} }
/** /**
* Find the epoch timestamp difference from "now" to the beginning of today. * Find the epoch timestamp difference from "now" to the beginning of today.
*/ */
@ -98,7 +98,7 @@ class Application_Model_DateHelper
* Returns the offset in seconds, between local and UTC timezones. * Returns the offset in seconds, between local and UTC timezones.
* E.g., if local timezone is -4, this function * E.g., if local timezone is -4, this function
* returns -14400. * returns -14400.
* *
* @return type offset in int, between local and UTC timezones * @return type offset in int, between local and UTC timezones
*/ */
function getLocalTimeZoneOffset() { function getLocalTimeZoneOffset() {
@ -106,31 +106,31 @@ class Application_Model_DateHelper
$timezone = new DateTimeZone(date_default_timezone_get()); $timezone = new DateTimeZone(date_default_timezone_get());
return $timezone->getOffset($dateTime); return $timezone->getOffset($dateTime);
} }
/** /**
* Returns the offset hour in int, between local and UTC timezones. * Returns the offset hour in int, between local and UTC timezones.
* E.g., if local timezone is -4:30, this function * E.g., if local timezone is -4:30, this function
* returns -4. * returns -4.
* *
* @return type offset hour in int, between local and UTC timezones * @return type offset hour in int, between local and UTC timezones
*/ */
function getLocalOffsetHour() { function getLocalOffsetHour() {
$offset = $this->getLocalTimeZoneOffset(); $offset = $this->getLocalTimeZoneOffset();
return (int)($offset / 3600); return (int)($offset / 3600);
} }
/** /**
* Returns the offset minute in int, between local and UTC timezones. * Returns the offset minute in int, between local and UTC timezones.
* E.g., if local timezone is -4:30, this function * E.g., if local timezone is -4:30, this function
* returns -30. * returns -30.
* *
* @return type offset minute in int, between local and UTC timezones * @return type offset minute in int, between local and UTC timezones
*/ */
function getLocalOffsetMinute() { function getLocalOffsetMinute() {
$offset = $this->getLocalTimeZoneOffset(); $offset = $this->getLocalTimeZoneOffset();
return (int)(($offset % 3600) / 60); return (int)(($offset % 3600) / 60);
} }
public static function TimeDiff($time1, $time2) public static function TimeDiff($time1, $time2)
{ {
return strtotime($time2) - strtotime($time1); return strtotime($time2) - strtotime($time1);
@ -193,11 +193,11 @@ class Application_Model_DateHelper
$explode = explode(" ", $p_dateTime); $explode = explode(" ", $p_dateTime);
return $explode[1]; return $explode[1];
} }
/* Given a track length in the format HH:MM:SS.mm, we want to /* Given a track length in the format HH:MM:SS.mm, we want to
* convert this to seconds. This is useful for Liquidsoap which * convert this to seconds. This is useful for Liquidsoap which
* likes input parameters give in seconds. * likes input parameters give in seconds.
* For example, 00:06:31.444, should be converted to 391.444 seconds * For example, 00:06:31.444, should be converted to 391.444 seconds
* @param int $p_time * @param int $p_time
* The time interval in format HH:MM:SS.mm we wish to * The time interval in format HH:MM:SS.mm we wish to
* convert to seconds. * convert to seconds.
@ -205,39 +205,44 @@ class Application_Model_DateHelper
* The input parameter converted to seconds. * The input parameter converted to seconds.
*/ */
public static function calculateLengthInSeconds($p_time){ public static function calculateLengthInSeconds($p_time){
if (2 !== substr_count($p_time, ":")){ if (2 !== substr_count($p_time, ":")){
return FALSE; return FALSE;
} }
if (1 === substr_count($p_time, ".")){ if (1 === substr_count($p_time, ".")){
list($hhmmss, $ms) = explode(".", $p_time); list($hhmmss, $ms) = explode(".", $p_time);
} else { } else {
$hhmmss = $p_time; $hhmmss = $p_time;
$ms = 0; $ms = 0;
} }
list($hours, $minutes, $seconds) = explode(":", $hhmmss); list($hours, $minutes, $seconds) = explode(":", $hhmmss);
$totalSeconds = $hours*3600 + $minutes*60 + $seconds + $ms/1000; $totalSeconds = $hours*3600 + $minutes*60 + $seconds + $ms/1000;
return $totalSeconds; return $totalSeconds;
} }
public static function ConvertToUtcDateTime($p_dateString, $timezone){ public static function ConvertToUtcDateTime($p_dateString, $timezone=null){
$dateTime = new DateTime($p_dateString, new DateTimeZone($timezone)); 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")); $dateTime->setTimezone(new DateTimeZone("UTC"));
return $dateTime; return $dateTime;
} }
public static function ConvertToSpecificTimezoneDateTime($p_dateString, $timezone){ public static function ConvertToSpecificTimezoneDateTime($p_dateString, $timezone){
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
$dateTime->setTimezone(new DateTimeZone($timezone)); $dateTime->setTimezone(new DateTimeZone($timezone));
return $dateTime; return $dateTime;
} }
public static function ConvertToLocalDateTime($p_dateString){ public static function ConvertToLocalDateTime($p_dateString){
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
$dateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));

View File

@ -119,17 +119,17 @@ class Application_Model_Show {
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}"; WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
$CC_DBC->query($sql); $CC_DBC->query($sql);
// check if we can safely delete the show // check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create() $showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($this->_showId) ->filterByDbShowId($this->_showId)
->findOne(); ->findOne();
if(is_null($showInstancesRow)){ if(is_null($showInstancesRow)){
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}"; $sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
$CC_DBC->query($sql); $CC_DBC->query($sql);
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} }
@ -137,10 +137,10 @@ class Application_Model_Show {
* This function is called when a repeating show is edited and the * This function is called when a repeating show is edited and the
* days that is repeats on have changed. More specifically, a day * days that is repeats on have changed. More specifically, a day
* that the show originally repeated on has been "unchecked". * that the show originally repeated on has been "unchecked".
* *
* Removes Show Instances that occur on days of the week specified * Removes Show Instances that occur on days of the week specified
* by input array. For example, if array contains one value of "0", * by input array. For example, if array contains one value of "0",
* (0 = Sunday, 1=Monday) then all show instances that occur on * (0 = Sunday, 1=Monday) then all show instances that occur on
* Sunday are removed. * Sunday are removed.
* *
* @param array p_uncheckedDays * @param array p_uncheckedDays
@ -385,8 +385,8 @@ class Application_Model_Show {
/** /**
* Deletes all show instances of current show before a * Deletes all show instances of current show before a
* certain date. * certain date.
* *
* This function is used in the case where a repeating show is being * This function is used in the case where a repeating show is being
* edited and the start date of the first show has been changed more * edited and the start date of the first show has been changed more
* into the future. In this case, delete any show instances that * into the future. In this case, delete any show instances that
@ -454,11 +454,11 @@ class Application_Model_Show {
return $startTime; return $startTime;
} }
} }
/** /**
* Get the end date of the current show. * Get the end date of the current show.
* Note that this is not the end date of repeated show * Note that this is not the end date of repeated show
* *
* @return string * @return string
* The end date in the format YYYY-MM-DD * The end date in the format YYYY-MM-DD
*/ */
@ -466,12 +466,12 @@ class Application_Model_Show {
$startDate = $this->getStartDate(); $startDate = $this->getStartDate();
$startTime = $this->getStartTime(); $startTime = $this->getStartTime();
$duration = $this->getDuration(); $duration = $this->getDuration();
$startDateTime = new DateTime($startDate.' '.$startTime); $startDateTime = new DateTime($startDate.' '.$startTime);
$duration = explode(":", $duration); $duration = explode(":", $duration);
$endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); $endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
return $endDate->format('Y-m-d'); return $endDate->format('Y-m-d');
} }
@ -485,12 +485,12 @@ class Application_Model_Show {
$startDate = $this->getStartDate(); $startDate = $this->getStartDate();
$startTime = $this->getStartTime(); $startTime = $this->getStartTime();
$duration = $this->getDuration(); $duration = $this->getDuration();
$startDateTime = new DateTime($startDate.' '.$startTime); $startDateTime = new DateTime($startDate.' '.$startTime);
$duration = explode(":", $duration); $duration = explode(":", $duration);
$endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); $endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
return $endDate->format('H:i:s'); return $endDate->format('H:i:s');
} }
@ -511,7 +511,7 @@ class Application_Model_Show {
* Get the ID's of future instance of the current show. * Get the ID's of future instance of the current show.
* *
* @return array * @return array
* A simple array containing all ID's of show instance * A simple array containing all ID's of show instance
* scheduled in the future. * scheduled in the future.
*/ */
public function getAllFutureInstanceIds(){ public function getAllFutureInstanceIds(){
@ -535,11 +535,11 @@ class Application_Model_Show {
} }
/* Called when a show's duration is changed (edited). /* Called when a show's duration is changed (edited).
* *
* @param array $p_data * @param array $p_data
* array containing the POST data about the show from the * array containing the POST data about the show from the
* browser. * browser.
* *
*/ */
private function updateDurationTime($p_data){ private function updateDurationTime($p_data){
//need to update cc_show_instances, cc_show_days //need to update cc_show_instances, cc_show_days
@ -640,7 +640,7 @@ class Application_Model_Show {
public function getInstanceOnDate($p_dateTime){ public function getInstanceOnDate($p_dateTime){
global $CC_DBC; global $CC_DBC;
$timestamp = $p_dateTime->format("Y-m-d H:i:s"); $timestamp = $p_dateTime->format("Y-m-d H:i:s");
$showId = $this->getId(); $showId = $this->getId();
$sql = "SELECT id FROM cc_show_instances" $sql = "SELECT id FROM cc_show_instances"
." WHERE date(starts) = date(TIMESTAMP '$timestamp') " ." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
@ -836,7 +836,7 @@ class Application_Model_Show {
$daysAdd = 6 - $startDow + 1 + $day; $daysAdd = 6 - $startDow + 1 + $day;
else else
$daysAdd = $day - $startDow; $daysAdd = $day - $startDow;
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D")); $startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
} }
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) { if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
@ -905,12 +905,12 @@ class Application_Model_Show {
$showHost->save(); $showHost->save();
} }
} }
Application_Model_Show::populateShowUntil($showId); Application_Model_Show::populateShowUntil($showId);
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
return $showId; return $showId;
} }
/** /**
* Generate repeating show instances for a single show up to the given date. * Generate repeating show instances for a single show up to the given date.
* If no date is given, use the one in the user's preferences, which is stored * If no date is given, use the one in the user's preferences, which is stored
@ -934,7 +934,7 @@ class Application_Model_Show {
$p_dateTime = $date; $p_dateTime = $date;
} }
} }
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId"; $sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
$res = $CC_DBC->GetAll($sql); $res = $CC_DBC->GetAll($sql);
@ -942,7 +942,7 @@ class Application_Model_Show {
Application_Model_Show::populateShow($showRow, $p_dateTime); Application_Model_Show::populateShow($showRow, $p_dateTime);
} }
} }
/** /**
* We are going to use cc_show_days as a template, to generate Show Instances. This function * We are going to use cc_show_days as a template, to generate Show Instances. This function
* is basically a dispatcher that looks at the show template, and sends it to the correct function * is basically a dispatcher that looks at the show template, and sends it to the correct function
@ -953,8 +953,8 @@ class Application_Model_Show {
* A row from cc_show_days table * A row from cc_show_days table
* @param DateTime $p_dateTime * @param DateTime $p_dateTime
* DateTime object in UTC time. * DateTime object in UTC time.
*/ */
private static function populateShow($p_showRow, $p_dateTime) { private static function populateShow($p_showRow, $p_dateTime) {
if($p_showRow["repeat_type"] == -1) { if($p_showRow["repeat_type"] == -1) {
Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_dateTime); Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_dateTime);
} }
@ -969,7 +969,7 @@ class Application_Model_Show {
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} }
/** /**
* Creates a single show instance. If the show is recorded, it may have multiple * Creates a single show instance. If the show is recorded, it may have multiple
* rebroadcast dates, and so this function will create those as well. * rebroadcast dates, and so this function will create those as well.
@ -978,11 +978,11 @@ class Application_Model_Show {
* A row from cc_show_days table * A row from cc_show_days table
* @param DateTime $p_dateTime * @param DateTime $p_dateTime
* DateTime object in UTC time. * DateTime object in UTC time.
*/ */
private static function populateNonRepeatingShow($p_showRow, $p_dateTime) private static function populateNonRepeatingShow($p_showRow, $p_dateTime)
{ {
global $CC_DBC; global $CC_DBC;
$show_id = $p_showRow["show_id"]; $show_id = $p_showRow["show_id"];
$first_show = $p_showRow["first_show"]; //non-UTC $first_show = $p_showRow["first_show"]; //non-UTC
$start_time = $p_showRow["start_time"]; //non-UTC $start_time = $p_showRow["start_time"]; //non-UTC
@ -990,7 +990,7 @@ class Application_Model_Show {
$day = $p_showRow["day"]; $day = $p_showRow["day"];
$record = $p_showRow["record"]; $record = $p_showRow["record"];
$timezone = $p_showRow["timezone"]; $timezone = $p_showRow["timezone"];
$start = $first_show." ".$start_time; $start = $first_show." ".$start_time;
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
@ -1012,7 +1012,7 @@ class Application_Model_Show {
$newInstance = true; $newInstance = true;
} }
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){
$ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStartDateTime); $ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbEnds($utcEndDateTime);
@ -1029,27 +1029,29 @@ class Application_Model_Show {
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql); $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);
} }
} }
/** /**
* Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show
* is recorded, it may have multiple rebroadcast dates, and so this function will create * is recorded, it may have multiple rebroadcast dates, and so this function will create
* those as well. * those as well.
* *
* @param array $p_showRow * @param array $p_showRow
* A row from cc_show_days table * A row from cc_show_days table
* @param DateTime $p_dateTime * @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 * @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) private static function populateRepeatingShow($p_showRow, $p_dateTime, $p_interval)
{ {
global $CC_DBC; global $CC_DBC;
$show_id = $p_showRow["show_id"]; $show_id = $p_showRow["show_id"];
$next_pop_date = $p_showRow["next_pop_date"]; $next_pop_date = $p_showRow["next_pop_date"];
$first_show = $p_showRow["first_show"]; //non-UTC $first_show = $p_showRow["first_show"]; //non-UTC
@ -1060,26 +1062,27 @@ class Application_Model_Show {
$record = $p_showRow["record"]; $record = $p_showRow["record"];
$timezone = $p_showRow["timezone"]; $timezone = $p_showRow["timezone"];
$date = new Application_Model_DateHelper();
$currentUtcTimestamp = $date->getUtcTimestamp();
if(isset($next_pop_date)) { if(isset($next_pop_date)) {
$start = $next_pop_date." ".$start_time; $start = $next_pop_date." ".$start_time;
} else { } else {
$start = $first_show." ".$start_time; $start = $first_show." ".$start_time;
} }
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); $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}"; $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql); $rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Application_Model_Show($show_id); $show = new Application_Model_Show($show_id);
$date = new Application_Model_DateHelper(); while($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp()
$currentUtcTimestamp = $date->getUtcTimestamp(); && (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){
while($utcStartDateTime->getTimestamp()
<= $p_dateTime->getTimestamp() &&
($utcStartDateTime->getTimestamp() < strtotime($last_show) || is_null($last_show))) {
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s"); $utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
$utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC")); $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC"));
@ -1113,37 +1116,63 @@ class Application_Model_Show {
$showInstance->correctScheduleStartTimes(); $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 = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval)); $dt->add(new DateInterval($p_interval));
$start = $dt->format("Y-m-d H:i:s"); $start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC')); $dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt; $utcStartDateTime = $dt;
} }
Application_Model_Show::setNextPop($start, $show_id, $day); Application_Model_Show::setNextPop($start, $show_id, $day);
} }
private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_utcStartDateTime, $p_duration){
global $CC_DBC;
foreach($p_rebroadcasts as $rebroadcast) {
$timeinfo = $p_utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT timestamp '{$timeinfo}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; /* 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;
Logging::log('Count of rebroadcasts '. count($p_rebroadcasts));
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); $rebroadcast_start_time = $CC_DBC->GetOne($sql);
Logging::log('rebroadcast start '.$rebroadcast_start_time);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'"; $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql); $rebroadcast_end_time = $CC_DBC->GetOne($sql);
Logging::log('rebroadcast end '.$rebroadcast_end_time);
if ($rebroadcast_start_time > $p_currentUtcTimestamp){
//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"));
$newRebroadcastInstance = new CcShowInstances(); $newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($p_showId); $newRebroadcastInstance->setDbShowId($p_showId);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time); $newRebroadcastInstance->setDbStarts($utc_rebroadcast_start_time->format("Y-m-d H:i:s"));
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time); $newRebroadcastInstance->setDbEnds($utc_rebroadcast_end_time->format("Y-m-d H:i:s"));
$newRebroadcastInstance->setDbRecord(0); $newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1); $newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($p_showInstanceId); $newRebroadcastInstance->setDbOriginalShow($p_showInstanceId);
@ -1167,6 +1196,7 @@ class Application_Model_Show {
{ {
global $CC_DBC; global $CC_DBC;
//UTC DateTime object
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
//if application is requesting shows past our previous populated until date, generate shows up until this point. //if application is requesting shows past our previous populated until date, generate shows up until this point.
@ -1233,7 +1263,7 @@ class Application_Model_Show {
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp) public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
{ {
global $CC_DBC; global $CC_DBC;
$endTimeString = $p_endTimestamp->format("Y-m-d H:i:s"); $endTimeString = $p_endTimestamp->format("Y-m-d H:i:s");
if (!is_null($p_startTimestamp)) { if (!is_null($p_startTimestamp)) {
$startTimeString = $p_startTimestamp->format("Y-m-d H:i:s"); $startTimeString = $p_startTimestamp->format("Y-m-d H:i:s");
@ -1272,8 +1302,9 @@ class Application_Model_Show {
$days = $interval->format('%a'); $days = $interval->format('%a');
$shows = Application_Model_Show::getShows($start, $end); $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) { foreach ($shows as $show) {
if ($show["deleted_instance"] != "t"){ if ($show["deleted_instance"] != "t"){
@ -1284,7 +1315,7 @@ class Application_Model_Show {
$show_instance = new Application_Model_ShowInstance($show["instance_id"]); $show_instance = new Application_Model_ShowInstance($show["instance_id"]);
$options["percent"] = $show_instance->getPercentScheduled(); $options["percent"] = $show_instance->getPercentScheduled();
} }
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
$options["editable"] = true; $options["editable"] = true;
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
@ -1304,10 +1335,10 @@ class Application_Model_Show {
if($show["rebroadcast"]) { if($show["rebroadcast"]) {
$event["disableResizing"] = true; $event["disableResizing"] = true;
} }
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC")); $endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC"));
$endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -1321,7 +1352,7 @@ class Application_Model_Show {
$event["record"] = intval($show["record"]); $event["record"] = intval($show["record"]);
$event["deleted_instance"] = $show["deleted_instance"]; $event["deleted_instance"] = $show["deleted_instance"];
$event["rebroadcast"] = intval($show["rebroadcast"]); $event["rebroadcast"] = intval($show["rebroadcast"]);
// get soundcloud_id // get soundcloud_id
if(!is_null($show["file_id"])){ if(!is_null($show["file_id"])){
$file = Application_Model_StoredFile::Recall($show["file_id"]); $file = Application_Model_StoredFile::Recall($show["file_id"]);
@ -1345,35 +1376,35 @@ class Application_Model_Show {
return $event; return $event;
} }
public function setShowFirstShow($s_date){ public function setShowFirstShow($s_date){
$showDay = CcShowDaysQuery::create() $showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId) ->filterByDbShowId($this->_showId)
->findOne(); ->findOne();
$showDay->setDbFirstShow($s_date) $showDay->setDbFirstShow($s_date)
->save(); ->save();
} }
public function setShowLastShow($e_date){ public function setShowLastShow($e_date){
$showDay = CcShowDaysQuery::create() $showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId) ->filterByDbShowId($this->_showId)
->findOne(); ->findOne();
$showDay->setDbLastShow($e_date) $showDay->setDbLastShow($e_date)
->save(); ->save();
} }
/** /**
* Given local current time $timeNow, returns the show being played right now. * Given local current time $timeNow, returns the show being played right now.
* *
* @param type $timeNow local current time * @param type $timeNow local current time
* @return type show being played right now * @return type show being played right now
*/ */
public static function GetCurrentShow($timeNow) public static function GetCurrentShow($timeNow)
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url" $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
@ -1382,15 +1413,15 @@ class Application_Model_Show {
// Convert back to local timezone // Convert back to local timezone
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
return $rows; return $rows;
} }
/** /**
* Given local current time $timeNow, returns the next $limit number of * Given local current time $timeNow, returns the next $limit number of
* shows within 2 days if $timeEnd is not given; Otherwise, returns the * shows within 2 days if $timeEnd is not given; Otherwise, returns the
* next $limit number of shows from $timeNow to $timeEnd, both in local time. * next $limit number of shows from $timeNow to $timeEnd, both in local time.
* *
* @param type $timeNow local current time * @param type $timeNow local current time
* @param type $limit number of shows to return * @param type $limit number of shows to return
* @param type $timeEnd optional: interval end time * @param type $timeEnd optional: interval end time
@ -1399,7 +1430,7 @@ class Application_Model_Show {
public static function GetNextShows($timeNow, $limit, $timeEnd = "") public static function GetNextShows($timeNow, $limit, $timeEnd = "")
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
// defaults to retrieving shows from next 2 days if no end time has // defaults to retrieving shows from next 2 days if no end time has
// been specified // been specified
if($timeEnd == "") { if($timeEnd == "") {
@ -1407,7 +1438,7 @@ class Application_Model_Show {
} else { } else {
$timeEnd = "'$timeEnd'"; $timeEnd = "'$timeEnd'";
} }
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM " $sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
@ -1417,14 +1448,14 @@ class Application_Model_Show {
." LIMIT $limit"; ." LIMIT $limit";
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
return $rows; return $rows;
} }
/** /**
* Given a day of the week variable $day, based in local time, returns the * Given a day of the week variable $day, based in local time, returns the
* shows being played on this day of the week we're in right now. * shows being played on this day of the week we're in right now.
* *
* @param type $day day of the week * @param type $day day of the week
* @return type shows being played on this day * @return type shows being played on this day
*/ */
@ -1434,9 +1465,9 @@ class Application_Model_Show {
//SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40'); //SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
//Result: 5 //Result: 5
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT" $sql = "SELECT"
." si.starts as show_starts," ." si.starts as show_starts,"
." si.ends as show_ends," ." si.ends as show_ends,"
@ -1448,70 +1479,70 @@ class Application_Model_Show {
." WHERE EXTRACT(DOW FROM si.starts) = $day" ." WHERE EXTRACT(DOW FROM si.starts) = $day"
." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)" ." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)"
." ORDER BY si.starts"; ." ORDER BY si.starts";
// Convert result timestamps to local timezone // Convert result timestamps to local timezone
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
return $rows; return $rows;
} }
/** /**
* Convert the columns given in the array $columnsToConvert in the * Convert the columns given in the array $columnsToConvert in the
* database result $rows to local timezone. * database result $rows to local timezone.
* *
* @param type $rows arrays of arrays containing database query result * @param type $rows arrays of arrays containing database query result
* @param type $columnsToConvert array of column names to convert * @param type $columnsToConvert array of column names to convert
*/ */
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) { public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) {
$timezone = date_default_timezone_get(); $timezone = date_default_timezone_get();
foreach($rows as &$row) { foreach($rows as &$row) {
foreach($columnsToConvert as $column) { foreach($columnsToConvert as $column) {
$row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]); $row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]);
} }
} }
} }
/** /**
* Returns the timezone difference as an INTERVAL string that can be used * Returns the timezone difference as an INTERVAL string that can be used
* by SQL queries. * by SQL queries.
* *
* E.g., if local timezone is -4:30, this function returns: * E.g., if local timezone is -4:30, this function returns:
* INTERVAL '-4 hours -30 minutes' * INTERVAL '-4 hours -30 minutes'
* *
* Note that if $fromLocalToUtc is true, then it returns: * Note that if $fromLocalToUtc is true, then it returns:
* INTERVAL '4 hours 30 minutes' * INTERVAL '4 hours 30 minutes'
* *
* @param type $fromLocalToUtc true if we're converting from local to UTC * @param type $fromLocalToUtc true if we're converting from local to UTC
*/ */
/* /*
public static function GetTimeZoneIntervalString($fromLocalToUtc = false) { public static function GetTimeZoneIntervalString($fromLocalToUtc = false) {
$date = new Application_Model_DateHelper; $date = new Application_Model_DateHelper;
$timezoneHour = $date->getLocalOffsetHour(); $timezoneHour = $date->getLocalOffsetHour();
$timezoneMin = $date->getLocalOffsetMinute(); $timezoneMin = $date->getLocalOffsetMinute();
// negate the hour and min if converting from local to UTC // negate the hour and min if converting from local to UTC
if($fromLocalToUtc) { if($fromLocalToUtc) {
$timezoneHour = -$timezoneHour; $timezoneHour = -$timezoneHour;
$timezoneMin = -$timezoneMin; $timezoneMin = -$timezoneMin;
} }
return "INTERVAL '$timezoneHour hours $timezoneMin minutes'"; return "INTERVAL '$timezoneHour hours $timezoneMin minutes'";
} }
* */ * */
public static function GetMaxLengths() { public static function GetMaxLengths() {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns" $sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
." WHERE table_name = 'cc_show' AND character_maximum_length > 0"; ." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
$result = $CC_DBC->GetAll($sql); $result = $CC_DBC->GetAll($sql);
// store result into assoc array // store result into assoc array
$assocArray = array(); $assocArray = array();
foreach($result as $row) { foreach($result as $row) {
$assocArray[$row['column_name']] = $row['character_maximum_length']; $assocArray[$row['column_name']] = $row['character_maximum_length'];
} }
return $assocArray; return $assocArray;
} }
} }

View File

@ -24,7 +24,7 @@ class Application_Model_ShowInstance {
{ {
return $this->_instanceId; return $this->_instanceId;
} }
public function getShow(){ public function getShow(){
return new Application_Model_Show($this->getShowId()); return new Application_Model_Show($this->getShowId());
} }
@ -136,7 +136,7 @@ class Application_Model_ShowInstance {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
$this->_showInstance->updateDbTimeFilled($con); $this->_showInstance->updateDbTimeFilled($con);
} }
public function isDeleted() public function isDeleted()
{ {
$this->_showInstance->getDbDeletedInstance(); $this->_showInstance->getDbDeletedInstance();
@ -174,7 +174,7 @@ class Application_Model_ShowInstance {
public function moveShow($deltaDay, $deltaMin) public function moveShow($deltaDay, $deltaMin)
{ {
global $CC_DBC; global $CC_DBC;
if ($this->getShow()->isRepeating()){ if ($this->getShow()->isRepeating()){
return "Can't drag and drop repeating shows"; return "Can't drag and drop repeating shows";
} }
@ -190,7 +190,7 @@ class Application_Model_ShowInstance {
$today_timestamp = time(); $today_timestamp = time();
$starts = $this->getShowInstanceStart(); $starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd(); $ends = $this->getShowInstanceEnd();
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC")); $startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
if($today_timestamp > $startsDateTime->getTimestamp()) { if($today_timestamp > $startsDateTime->getTimestamp()) {
@ -205,13 +205,13 @@ class Application_Model_ShowInstance {
$new_ends = $CC_DBC->GetOne($sql); $new_ends = $CC_DBC->GetOne($sql);
$newEndsDateTime = new DateTime($new_ends, new DateTimeZone("UTC")); $newEndsDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
if($today_timestamp > $newStartsDateTime->getTimestamp()) { if($today_timestamp > $newStartsDateTime->getTimestamp()) {
return "Can't move show into past"; return "Can't move show into past";
} }
$overlap = Application_Model_Show::getShows($newStartsDateTime, $newEndsDateTime, array($this->_instanceId)); $overlap = Application_Model_Show::getShows($newStartsDateTime, $newEndsDateTime, array($this->_instanceId));
if(count($overlap) > 0) { if(count($overlap) > 0) {
return "Should not overlap shows"; return "Should not overlap shows";
} }
@ -229,13 +229,13 @@ class Application_Model_ShowInstance {
$this->setShowStart($new_starts); $this->setShowStart($new_starts);
$this->setShowEnd($new_ends); $this->setShowEnd($new_ends);
$this->correctScheduleStartTimes(); $this->correctScheduleStartTimes();
$show = new Application_Model_Show($this->getShowId()); $show = new Application_Model_Show($this->getShowId());
if(!$show->isRepeating()){ if(!$show->isRepeating()){
$show->setShowFirstShow($new_starts); $show->setShowFirstShow($new_starts);
$show->setShowLastShow($new_ends); $show->setShowLastShow($new_ends);
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} }
@ -251,7 +251,7 @@ class Application_Model_ShowInstance {
$mins = abs($deltaMin%60); $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(); $starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd(); $ends = $this->getShowInstanceEnd();
@ -264,8 +264,11 @@ class Application_Model_ShowInstance {
//only need to check overlap if show increased in size. //only need to check overlap if show increased in size.
if(strtotime($new_ends) > strtotime($ends)) { 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) { if(count($overlap) > 0) {
return "Should not overlap shows"; return "Should not overlap shows";
@ -385,7 +388,7 @@ class Application_Model_ShowInstance {
public function deleteShow() public function deleteShow()
{ {
global $CC_DBC; global $CC_DBC;
// see if it was recording show // see if it was recording show
$recording = CcShowInstancesQuery::create() $recording = CcShowInstancesQuery::create()
->findPK($this->_instanceId) ->findPK($this->_instanceId)
@ -394,18 +397,18 @@ class Application_Model_ShowInstance {
$showId = CcShowInstancesQuery::create() $showId = CcShowInstancesQuery::create()
->findPK($this->_instanceId) ->findPK($this->_instanceId)
->getDbShowId(); ->getDbShowId();
CcShowInstancesQuery::create() CcShowInstancesQuery::create()
->findPK($this->_instanceId) ->findPK($this->_instanceId)
->setDbDeletedInstance(true) ->setDbDeletedInstance(true)
->save(); ->save();
// check if we can safely delete the show // check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create() $showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId) ->filterByDbShowId($showId)
->filterByDbDeletedInstance(false) ->filterByDbDeletedInstance(false)
->findOne(); ->findOne();
/* If we didn't find any instances of the show that haven't /* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show. * been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should * We can just delete, the show and the foreign key-constraint should
@ -415,7 +418,7 @@ class Application_Model_ShowInstance {
->filterByDbId($showId) ->filterByDbId($showId)
->delete(); ->delete();
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
if($recording){ if($recording){
Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording"); Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording");
@ -671,7 +674,7 @@ class Application_Model_ShowInstance {
return new Application_Model_ShowInstance($id); return new Application_Model_ShowInstance($id);
} }
} }
// returns number of show instances that ends later than $day // returns number of show instances that ends later than $day
public static function GetShowInstanceCount($day){ public static function GetShowInstanceCount($day){
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;

View File

@ -96,24 +96,25 @@ class Application_Model_Systemstatus
} }
public static function GetPlatformInfo(){ public static function GetPlatformInfo(){
$data = array("release"=>"UNKNOWN", $keys = array("release", "machine", "memory", "swap");
"machine"=>"UNKNOWN", foreach($keys as $key) {
"memory"=>"UNKNOWN", $data[$key] = "UNKNOWN";
"swap"=>"UNKNOWN"); }
$docRoot = self::GetMonitStatus("localhost"); $docRoot = self::GetMonitStatus("localhost");
if (!is_null($docRoot)){ if (!is_null($docRoot)){
foreach ($docRoot->getElementsByTagName("platform") AS $item) foreach ($docRoot->getElementsByTagName("platform") AS $item)
{ {
$data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue; foreach($keys as $key) {
$data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue; $keyElement = $item->getElementsByTagName($key);
$data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue; if($keyElement->length > 0) {
$data["swap"] = $item->getElementsByTagName("swap")->item(0)->nodeValue; $data[$key] = $keyElement->item(0)->nodeValue;
}
}
} }
} }
return $data; return $data;
} }
public static function GetPypoStatus(){ public static function GetPypoStatus(){

View File

@ -26,36 +26,31 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
return ""; 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 // Note: algorithm assumes the number after 1st dot never goes above 9
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2])) $diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
- (intval($curMatch[1]) * 10 + intval($curMatch[2])); - (intval($curMatch[1]) * 10 + intval($curMatch[2]));
// Pick icon and tooltip msg // Pick icon
$bg = "/css/images/";
$msg = "";
$link = "<a href='http://apt.sourcefabric.org/misc/'>" . $latest . "</a>";
if(($diff == 0 && $current == $latest) || $diff < 0) { if(($diff == 0 && $current == $latest) || $diff < 0) {
// current version is up to date // current version is up to date
$bg .= "icon_uptodate.png"; $class = "uptodate";
$msg = "You are running the latest version";
} else if($diff <= 2) { } else if($diff <= 2) {
// 2 or less major versions back // 2 or less major versions back
$bg .= "icon_update.png"; $class = "update";
$msg = "New version available: " . $link;
} else if($diff == 3) { } else if($diff == 3) {
// 3 major versions back // 3 major versions back
$bg .= "icon_update2.png"; $class = "update2";
$msg = "This version will soon be obsolete.<br/>Please upgrade to " . $link;
} else { } else {
// more than 3 major versions back // more than 3 major versions back
$bg .= "icon_outdated.png"; $class = "outdated";
$msg = "This version is no longer supported.<br/>Please upgrade to " . $link;
} }
$result = "<div id='version_message' style='display:none'>" . $msg . "</div>" $result = "<div id='version-diff' style='display:none'>" . $diff . "</div>"
. "<div id='version_current' style='display:none'>" . $current . "</div>" . "<div id='version-current' style='display:none'>" . $current . "</div>"
. "<div id='version_icon' style='background-image: url(" . $bg . ");'></div>"; . "<div id='version-latest' style='display:none'>" . $latest . "</div>"
. "<div id='version-icon' class='" . $class . "'></div>";
return $result; return $result;
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -58,18 +58,29 @@ select {
} }
/* Version Notification Starts*/ /* Version Notification Starts*/
#version_icon { #version-icon {
position:absolute; position:absolute;
right:85px; right:96px;
top:104px; top:104px;
height:35px; height:35px;
width:35px; width:35px;
z-index:1000; z-index:1000;
display:block; display:block;
cursor:pointer; cursor:pointer;
background-repeat:no-repeat;
background-repeat:no-repeat; background-position:center;
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 { #ui-tooltip-version a {
@ -2366,6 +2377,9 @@ tfoot tr th {
margin:2px 1px 10px 0px; margin:2px 1px 10px 0px;
width: auto; width: auto;
} }
dd .stream-status {
margin-bottom:1px;
}
.stream-status h3 { .stream-status h3 {
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
@ -2397,4 +2411,18 @@ tfoot tr th {
} }
.status-error h3 { .status-error h3 {
color:#DA0101; 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;
} }

View File

@ -1,24 +1,68 @@
/** /**
* Get the tooltip message to be displayed, * Get the tooltip message to be displayed
* which is stored inside a pair of hidden div tags
*/ */
function getContent() { 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, * Get major version difference b/w current and latest version, in int
* which is stored inside a pair of hidden div tags */
function getVersionDiff() {
return parseInt($("#version-diff").html());
}
/**
* Get the current version
*/ */
function getCurrentVersion() { 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 * Sets up the tooltip for version notification
*/ */
function setupVersionQtip(){ function setupVersionQtip(){
var qtipElem = $('#version_icon'); var qtipElem = $('#version-icon');
if (qtipElem.length > 0){ if (qtipElem.length > 0){
qtipElem.qtip({ qtipElem.qtip({
id: 'version', id: 'version',
@ -26,10 +70,12 @@ function setupVersionQtip(){
text: getContent(), text: getContent(),
title: { title: {
text: getCurrentVersion(), text: getCurrentVersion(),
button: true button: isUpToDate() ? false : true
} }
}, },
hide: false, /* Don't hide on mouseout */ hide: {
event: isUpToDate() ? 'mouseleave' : 'unfocus'
},
position: { position: {
my: "top right", my: "top right",
at: "bottom left" at: "bottom left"
@ -46,7 +92,7 @@ function setupVersionQtip(){
} }
$(document).ready(function() { $(document).ready(function() {
if($('#version_message').length > 0) { if($('#version-icon').length > 0) {
setupVersionQtip(); setupVersionQtip();
} }
}); });