diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index e3396b42b..78baca4ae 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -192,10 +192,6 @@ class Application_Model_ShowInstance { $newDateTime = clone $dateTime; - Logging::log("deltaDay: {$deltaDay}"); - Logging::log("deltaMin: {$deltaMin}"); - Logging::log("addDeltas: original time {$newDateTime->format('Y-m-d H:i:s')}"); - $days = abs($deltaDay); $mins = abs($deltaMin); @@ -216,8 +212,6 @@ class Application_Model_ShowInstance { $newDateTime->sub($minInterval); } - Logging::log("addDeltas: modified time {$newDateTime->format('Y-m-d H:i:s')}"); - return $newDateTime; } @@ -252,6 +246,21 @@ class Application_Model_ShowInstance { return "Can't move show into past"; } + if ($this->isRecorded()) { + + //rebroadcasts should start at max 1 hour after a recorded show has ended. + $minRebroadcastStart = self::addDeltas($newEndsDateTime, 0, 60); + //check if we are moving a recorded show less than 1 hour before any of its own rebroadcasts. + $rebroadcasts = CcShowInstancesQuery::create() + ->filterByDbOriginalShow($this->_instanceId) + ->filterByDbStarts($minRebroadcastStart->format('Y-m-d H:i:s'), Criteria::LESS_THAN) + ->find(); + + if (count($rebroadcasts) > 0) { + return "Can't move a recorded show less than 1 hour before its rebroadcasts."; + } + } + if ($this->isRebroadcast()) { try { @@ -438,7 +447,7 @@ class Application_Model_ShowInstance { public function delete() { global $CC_DBC; - + // see if it was recording show $recording = $this->isRecorded(); // get show id @@ -448,7 +457,7 @@ class Application_Model_ShowInstance { $current_timestamp = gmdate("Y-m-d H:i:s"); - if ($current_timestamp <= $this->getShowInstanceEnd()) { + if ($current_timestamp <= $this->getShowInstanceEnd()) { if ($show->isRepeating()) { CcShowInstancesQuery::create()