Merge branch '1.8.2' of dev.sourcefabric.org:airtime into 1.8.2
This commit is contained in:
commit
cfb3b9a248
|
@ -446,10 +446,14 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
'add_show_description' => $show->getDescription()));
|
'add_show_description' => $show->getDescription()));
|
||||||
|
|
||||||
$formWhen->populate(array('add_show_start_date' => $show->getStartDate(),
|
$formWhen->populate(array('add_show_start_date' => $show->getStartDate(),
|
||||||
'add_show_start_time' => Show::removeSecondsFromTime($show->getStartTime()),
|
'add_show_start_time' => DateHelper::removeSecondsFromTime($show->getStartTime()),
|
||||||
'add_show_duration' => $show->getDuration(),
|
'add_show_duration' => $show->getDuration(),
|
||||||
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
|
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
|
||||||
|
|
||||||
|
if ($show->isStartDateTimeInPast()){
|
||||||
|
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||||
|
}
|
||||||
|
|
||||||
$days = array();
|
$days = array();
|
||||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||||
foreach($showDays as $showDay){
|
foreach($showDays as $showDay){
|
||||||
|
@ -476,7 +480,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($rebroadcastsRelative as $rebroadcast){
|
foreach ($rebroadcastsRelative as $rebroadcast){
|
||||||
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
|
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
|
||||||
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']);
|
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$formRebroadcast->populate($rebroadcastFormValues);
|
$formRebroadcast->populate($rebroadcastFormValues);
|
||||||
|
@ -486,7 +490,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($rebroadcastsAbsolute as $rebroadcast){
|
foreach ($rebroadcastsAbsolute as $rebroadcast){
|
||||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
||||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']);
|
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
||||||
|
@ -548,6 +552,16 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$data[$j["name"]] = $j["value"];
|
$data[$j["name"]] = $j["value"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$show = new Show($data['add_show_id']);
|
||||||
|
|
||||||
|
$startDateModified = true;
|
||||||
|
if ($data['add_show_id'] != -1 && !array_key_exists('add_show_start_date', $data)){
|
||||||
|
//show is being updated and changing the start date was disabled, since the
|
||||||
|
//array key does not exist. We need to repopulate this entry from the db.
|
||||||
|
$data['add_show_start_date'] = $show->getStartDate();
|
||||||
|
$startDateModified = false;
|
||||||
|
}
|
||||||
|
|
||||||
$data['add_show_hosts'] = $this->_getParam('hosts');
|
$data['add_show_hosts'] = $this->_getParam('hosts');
|
||||||
$data['add_show_day_check'] = $this->_getParam('days');
|
$data['add_show_day_check'] = $this->_getParam('days');
|
||||||
|
|
||||||
|
@ -586,11 +600,10 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$what = $formWhat->isValid($data);
|
$what = $formWhat->isValid($data);
|
||||||
$when = $formWhen->isValid($data);
|
$when = $formWhen->isValid($data);
|
||||||
if($when) {
|
if($when) {
|
||||||
$when = $formWhen->checkReliantFields($data);
|
$when = $formWhen->checkReliantFields($data, $startDateModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data["add_show_repeats"]) {
|
if($data["add_show_repeats"]) {
|
||||||
|
|
||||||
$repeats = $formRepeats->isValid($data);
|
$repeats = $formRepeats->isValid($data);
|
||||||
if($repeats) {
|
if($repeats) {
|
||||||
$repeats = $formRepeats->checkReliantFields($data);
|
$repeats = $formRepeats->checkReliantFields($data);
|
||||||
|
@ -636,7 +649,6 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
//update this option.
|
//update this option.
|
||||||
$record = false;
|
$record = false;
|
||||||
if ($data['add_show_id'] != -1){
|
if ($data['add_show_id'] != -1){
|
||||||
$show = new Show($data['add_show_id']);
|
|
||||||
$data['add_show_record'] = $show->isRecorded();
|
$data['add_show_record'] = $show->isRecorded();
|
||||||
$record = $formRecord->isValid($data);
|
$record = $formRecord->isValid($data);
|
||||||
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
|
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||||
|
@ -676,6 +688,9 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
if ($data['add_show_id'] != -1){
|
if ($data['add_show_id'] != -1){
|
||||||
$this->view->addNewShow = false;
|
$this->view->addNewShow = false;
|
||||||
}
|
}
|
||||||
|
if (!$startDateModified){
|
||||||
|
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkReliantFields($formData) {
|
public function checkReliantFields($formData, $startDateModified) {
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
|
@ -69,10 +69,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
$now_epoch = strtotime($now_timestamp);
|
$now_epoch = strtotime($now_timestamp);
|
||||||
$start_epoch = strtotime($start_timestamp);
|
$start_epoch = strtotime($start_timestamp);
|
||||||
|
|
||||||
|
if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
|
||||||
if($start_epoch < $now_epoch) {
|
if($start_epoch < $now_epoch) {
|
||||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
|
if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
|
||||||
|
|
|
@ -18,6 +18,15 @@ class DateHelper
|
||||||
return date("Y-m-d H:i:s", $this->_timestamp);
|
return date("Y-m-d H:i:s", $this->_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get date of object construction in the format
|
||||||
|
* YY:mm:dd
|
||||||
|
*/
|
||||||
|
function getDate()
|
||||||
|
{
|
||||||
|
return date("Y-m-d", $this->_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get time of object construction in the format
|
* Get time of object construction in the format
|
||||||
* HH:mm:ss
|
* HH:mm:ss
|
||||||
|
@ -83,5 +92,40 @@ class DateHelper
|
||||||
|
|
||||||
return $hours.":".$minutes.":".$seconds.".".$ms;
|
return $hours.":".$minutes.":".$seconds.".".$ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function formats a time by removing seconds
|
||||||
|
*
|
||||||
|
* When we receive a time from the database we get the
|
||||||
|
* format "hh:mm:ss". But when dealing with show times, we
|
||||||
|
* do not care about the seconds.
|
||||||
|
*
|
||||||
|
* @param int $p_timestamp
|
||||||
|
* The value which to format.
|
||||||
|
* @return int
|
||||||
|
* The timestamp with the new format "hh:mm", or
|
||||||
|
* the original input parameter, if it does not have
|
||||||
|
* the correct format.
|
||||||
|
*/
|
||||||
|
public static function removeSecondsFromTime($p_timestamp)
|
||||||
|
{
|
||||||
|
//Format is in hh:mm:ss. We want hh:mm
|
||||||
|
$timeExplode = explode(":", $p_timestamp);
|
||||||
|
|
||||||
|
if (count($timeExplode) == 3)
|
||||||
|
return $timeExplode[0].":".$timeExplode[1];
|
||||||
|
else
|
||||||
|
return $p_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDateFromTimestamp($p_timestamp){
|
||||||
|
$explode = explode(" ", $p_timestamp);
|
||||||
|
return $explode[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTimeFromTimestamp($p_timestamp){
|
||||||
|
$explode = explode(" ", $p_timestamp);
|
||||||
|
return $explode[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -318,14 +318,19 @@ class Show {
|
||||||
* certain date.
|
* certain date.
|
||||||
*
|
*
|
||||||
* @param string $p_date
|
* @param string $p_date
|
||||||
* The date which to delete after
|
* The date which to delete after, if null deletes from the current timestamp.
|
||||||
*/
|
*/
|
||||||
public function removeAllInstancesFromDate($p_date){
|
public function removeAllInstancesFromDate($p_date=null){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$date = new DateHelper;
|
$date = new DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
|
||||||
|
if(is_null($p_date)) {
|
||||||
|
$date = new DateHelper;
|
||||||
|
$p_date = $date->getDate();
|
||||||
|
}
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "DELETE FROM cc_show_instances "
|
$sql = "DELETE FROM cc_show_instances "
|
||||||
." WHERE date(starts) >= DATE '$p_date'"
|
." WHERE date(starts) >= DATE '$p_date'"
|
||||||
|
@ -333,6 +338,13 @@ class Show {
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
||||||
|
/*
|
||||||
|
CcShowInstancesQuery::create()
|
||||||
|
->filterByDbShowId($showId)
|
||||||
|
->filterByDbStartTime($p_date, Criteria::GREATER_EQUAL)
|
||||||
|
->delete();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,6 +414,19 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate whether the starting point of the show is in the
|
||||||
|
* past.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* true if the StartDate is in the past, false otherwise
|
||||||
|
*/
|
||||||
|
public function isStartDateTimeInPast(){
|
||||||
|
$date = new DateHelper;
|
||||||
|
$current_timestamp = $date->getTimestamp();
|
||||||
|
return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID's of future instance of the current show.
|
* Get the ID's of future instance of the current show.
|
||||||
*
|
*
|
||||||
|
@ -533,11 +558,13 @@ class Show {
|
||||||
|
|
||||||
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType)
|
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType)
|
||||||
{
|
{
|
||||||
if ($p_data['add_show_repeats'] != $p_show->isRepeating()
|
if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || ($isRecorded && !$p_data['add_show_repeats'])){
|
||||||
|| $isRecorded){
|
//repeat option was toggled.
|
||||||
//repeat option was toggled or show is recorded.
|
|
||||||
$p_show->deleteAllInstances();
|
$p_show->deleteAllInstances();
|
||||||
}
|
}
|
||||||
|
if($isRecorded && $p_data['add_show_repeats']) {
|
||||||
|
$p_show->removeAllInstancesFromDate();
|
||||||
|
}
|
||||||
|
|
||||||
if ($p_data['add_show_duration'] != $p_show->getDuration()){
|
if ($p_data['add_show_duration'] != $p_show->getDuration()){
|
||||||
//duration has changed
|
//duration has changed
|
||||||
|
@ -561,7 +588,8 @@ class Show {
|
||||||
if ($repeatType != $p_show->getRepeatType()){
|
if ($repeatType != $p_show->getRepeatType()){
|
||||||
//repeat type changed.
|
//repeat type changed.
|
||||||
$p_show->deleteAllInstances();
|
$p_show->deleteAllInstances();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
//repeat type is the same, check if the days of the week are the same
|
//repeat type is the same, check if the days of the week are the same
|
||||||
$repeatingDaysChanged = false;
|
$repeatingDaysChanged = false;
|
||||||
$showDaysArray = $p_show->getShowDays();
|
$showDaysArray = $p_show->getShowDays();
|
||||||
|
@ -571,7 +599,8 @@ class Show {
|
||||||
if (count($intersect) != count($p_data['add_show_day_check'])){
|
if (count($intersect) != count($p_data['add_show_day_check'])){
|
||||||
$repeatingDaysChanged = true;
|
$repeatingDaysChanged = true;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$repeatingDaysChanged = true;
|
$repeatingDaysChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +618,8 @@ class Show {
|
||||||
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
|
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
|
||||||
//show "Never Ends" option was toggled.
|
//show "Never Ends" option was toggled.
|
||||||
if ($p_data['add_show_no_end']){
|
if ($p_data['add_show_no_end']){
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$p_show->removeAllInstancesFromDate($p_endDate);
|
$p_show->removeAllInstancesFromDate($p_endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,7 +638,7 @@ class Show {
|
||||||
/**
|
/**
|
||||||
* Create a show.
|
* Create a show.
|
||||||
*
|
*
|
||||||
* Note: end dates are inclusive.
|
* Note: end dates are non inclusive.
|
||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -685,7 +715,8 @@ class Show {
|
||||||
$showDay->setDbShowId($showId);
|
$showDay->setDbShowId($showId);
|
||||||
$showDay->setDbRecord($isRecorded);
|
$showDay->setDbRecord($isRecorded);
|
||||||
$showDay->save();
|
$showDay->save();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
foreach ($data['add_show_day_check'] as $day) {
|
foreach ($data['add_show_day_check'] as $day) {
|
||||||
if ($startDow !== $day){
|
if ($startDow !== $day){
|
||||||
|
|
||||||
|
@ -717,16 +748,20 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date = new DateHelper();
|
||||||
|
$currentTimestamp = $date->getTimestamp();
|
||||||
|
|
||||||
//check if we are adding or updating a show, and if updating
|
//check if we are adding or updating a show, and if updating
|
||||||
//erase all the show's show_rebroadcast information first.
|
//erase all the show's future show_rebroadcast information first.
|
||||||
if ($data['add_show_id'] != -1){
|
if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){
|
||||||
CcShowRebroadcastQuery::create()->filterByDbShowId($data['add_show_id'])->delete();
|
CcShowRebroadcastQuery::create()
|
||||||
|
->filterByDbShowId($data['add_show_id'])
|
||||||
|
//->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL)
|
||||||
|
->delete();
|
||||||
}
|
}
|
||||||
//adding rows to cc_show_rebroadcast
|
//adding rows to cc_show_rebroadcast
|
||||||
if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType != -1) {
|
if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) {
|
||||||
|
|
||||||
for ($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
if ($data['add_show_rebroadcast_date_'.$i]) {
|
if ($data['add_show_rebroadcast_date_'.$i]) {
|
||||||
$showRebroad = new CcShowRebroadcast();
|
$showRebroad = new CcShowRebroadcast();
|
||||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
||||||
|
@ -735,10 +770,9 @@ class Show {
|
||||||
$showRebroad->save();
|
$showRebroad->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType == -1){
|
}
|
||||||
|
else if ($isRecorded && $data['add_show_rebroadcast'] && ($repeatType == -1)){
|
||||||
for ($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
if ($data['add_show_rebroadcast_date_absolute_'.$i]) {
|
if ($data['add_show_rebroadcast_date_absolute_'.$i]) {
|
||||||
$sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
$sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
|
@ -845,13 +879,11 @@ class Show {
|
||||||
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp)
|
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$next_date = $first_show." ".$start_time;
|
$next_date = $first_show." ".$start_time;
|
||||||
|
|
||||||
if (strtotime($next_date) < strtotime($end_timestamp)) {
|
if (strtotime($next_date) < strtotime($end_timestamp)) {
|
||||||
|
|
||||||
$start = $next_date;
|
$start = $next_date;
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -859,16 +891,19 @@ class Show {
|
||||||
if ($show->hasInstance()){
|
if ($show->hasInstance()){
|
||||||
$ccShowInstance = $show->getInstance();
|
$ccShowInstance = $show->getInstance();
|
||||||
$newInstance = false;
|
$newInstance = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$ccShowInstance = new CcShowInstances();
|
$ccShowInstance = new CcShowInstances();
|
||||||
$newInstance = true;
|
$newInstance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($start > $currentTimestamp){
|
||||||
$ccShowInstance->setDbShowId($show_id);
|
$ccShowInstance->setDbShowId($show_id);
|
||||||
$ccShowInstance->setDbStarts($start);
|
$ccShowInstance->setDbStarts($start);
|
||||||
$ccShowInstance->setDbEnds($end);
|
$ccShowInstance->setDbEnds($end);
|
||||||
$ccShowInstance->setDbRecord($record);
|
$ccShowInstance->setDbRecord($record);
|
||||||
$ccShowInstance->save();
|
$ccShowInstance->save();
|
||||||
|
}
|
||||||
|
|
||||||
$show_instance_id = $ccShowInstance->getDbId();
|
$show_instance_id = $ccShowInstance->getDbId();
|
||||||
$showInstance = new ShowInstance($show_instance_id);
|
$showInstance = new ShowInstance($show_instance_id);
|
||||||
|
@ -877,6 +912,9 @@ class Show {
|
||||||
$showInstance->correctScheduleStartTimes();
|
$showInstance->correctScheduleStartTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date = new DateHelper();
|
||||||
|
$currentTimestamp = $date->getTimestamp();
|
||||||
|
|
||||||
$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);
|
||||||
|
|
||||||
|
@ -890,6 +928,7 @@ class Show {
|
||||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if ($rebroadcast_start_time > $currentTimestamp){
|
||||||
$newRebroadcastInstance = new CcShowInstances();
|
$newRebroadcastInstance = new CcShowInstances();
|
||||||
$newRebroadcastInstance->setDbShowId($show_id);
|
$newRebroadcastInstance->setDbShowId($show_id);
|
||||||
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
||||||
|
@ -900,6 +939,7 @@ class Show {
|
||||||
$newRebroadcastInstance->save();
|
$newRebroadcastInstance->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,6 +967,9 @@ class Show {
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
$date = new DateHelper();
|
||||||
|
$currentTimestamp = $date->getTimestamp();
|
||||||
|
|
||||||
if ($show->hasInstanceOnDate($start)){
|
if ($show->hasInstanceOnDate($start)){
|
||||||
$ccShowInstance = $show->getInstanceOnDate($start);
|
$ccShowInstance = $show->getInstanceOnDate($start);
|
||||||
$newInstance = false;
|
$newInstance = false;
|
||||||
|
@ -934,11 +977,14 @@ class Show {
|
||||||
$ccShowInstance = new CcShowInstances();
|
$ccShowInstance = new CcShowInstances();
|
||||||
$newInstance = true;
|
$newInstance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($start > $currentTimestamp){
|
||||||
$ccShowInstance->setDbShowId($show_id);
|
$ccShowInstance->setDbShowId($show_id);
|
||||||
$ccShowInstance->setDbStarts($start);
|
$ccShowInstance->setDbStarts($start);
|
||||||
$ccShowInstance->setDbEnds($end);
|
$ccShowInstance->setDbEnds($end);
|
||||||
$ccShowInstance->setDbRecord($record);
|
$ccShowInstance->setDbRecord($record);
|
||||||
$ccShowInstance->save();
|
$ccShowInstance->save();
|
||||||
|
}
|
||||||
|
|
||||||
$show_instance_id = $ccShowInstance->getDbId();
|
$show_instance_id = $ccShowInstance->getDbId();
|
||||||
$showInstance = new ShowInstance($show_instance_id);
|
$showInstance = new ShowInstance($show_instance_id);
|
||||||
|
@ -957,6 +1003,7 @@ class Show {
|
||||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if ($rebroadcast_start_time > $currentTimestamp){
|
||||||
$newRebroadcastInstance = new CcShowInstances();
|
$newRebroadcastInstance = new CcShowInstances();
|
||||||
$newRebroadcastInstance->setDbShowId($show_id);
|
$newRebroadcastInstance->setDbShowId($show_id);
|
||||||
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
||||||
|
@ -966,6 +1013,7 @@ class Show {
|
||||||
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
|
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
|
||||||
$newRebroadcastInstance->save();
|
$newRebroadcastInstance->save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
|
||||||
$next_date = $CC_DBC->GetOne($sql);
|
$next_date = $CC_DBC->GetOne($sql);
|
||||||
|
@ -1132,41 +1180,6 @@ class Show {
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDateFromTimestamp($p_timestamp){
|
|
||||||
$explode = explode(" ", $p_timestamp);
|
|
||||||
return $explode[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTimeFromTimestamp($p_timestamp){
|
|
||||||
$explode = explode(" ", $p_timestamp);
|
|
||||||
return $explode[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function formats a time by removing seconds
|
|
||||||
*
|
|
||||||
* When we receive a time from the database we get the
|
|
||||||
* format "hh:mm:ss". But when dealing with show times, we
|
|
||||||
* do not care about the seconds.
|
|
||||||
*
|
|
||||||
* @param int $p_timestamp
|
|
||||||
* The value which to format.
|
|
||||||
* @return int
|
|
||||||
* The timestamp with the new format "hh:mm", or
|
|
||||||
* the original input parameter, if it does not have
|
|
||||||
* the correct format.
|
|
||||||
*/
|
|
||||||
public static function removeSecondsFromTime($p_timestamp)
|
|
||||||
{
|
|
||||||
//Format is in hh:mm:ss. We want hh:mm
|
|
||||||
$timeExplode = explode(":", $p_timestamp);
|
|
||||||
|
|
||||||
if (count($timeExplode) == 3)
|
|
||||||
return $timeExplode[0].":".$timeExplode[1];
|
|
||||||
else
|
|
||||||
return $p_timestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShowInstance {
|
class ShowInstance {
|
||||||
|
|
Loading…
Reference in New Issue