CC-3094 : Rebroadcast editing problems

This commit is contained in:
Naomi Aro 2011-12-02 13:31:54 +01:00
parent 878fa3461d
commit 198340ac67
2 changed files with 58 additions and 34 deletions

View file

@ -105,6 +105,13 @@ class Application_Model_Show {
return $res; return $res;
} }
//remove everything about this show.
public function deleteShow()
{
$show = CcShowQuery::create()->findPK($this->_showId);
$show->delete();
}
public function resizeShow($deltaDay, $deltaMin) public function resizeShow($deltaDay, $deltaMin)
{ {
global $CC_DBC; global $CC_DBC;
@ -280,7 +287,7 @@ class Application_Model_Show {
$showId = $this->getId(); $showId = $this->getId();
$sql = "SELECT starts FROM cc_show_instances " $sql = "SELECT starts FROM cc_show_instances "
."WHERE instance_id = $showId " ."WHERE show_id = $showId AND rebroadcast = 1"
."ORDER BY starts"; ."ORDER BY starts";
$rebroadcasts = $CC_DBC->GetAll($sql); $rebroadcasts = $CC_DBC->GetAll($sql);
@ -1229,8 +1236,10 @@ class Application_Model_Show {
$showInstance->correctScheduleStartTimes(); $showInstance->correctScheduleStartTimes();
} }
//don't create rebroadcasts for a deleted recorded show.
if ($ccShowInstance->getDbModifiedInstance() == false) {
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
}
if ($p_interval == 'P1M'){ if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP. /* When adding months, there is a problem if we are on January 31st and add one month with PHP.

View file

@ -399,19 +399,30 @@ class Application_Model_ShowInstance {
global $CC_DBC; global $CC_DBC;
// see if it was recording show // see if it was recording show
$recording = CcShowInstancesQuery::create() $recording = $this->isRecorded();
->findPK($this->_instanceId)
->getDbRecord();
// get show id // get show id
$showId = CcShowInstancesQuery::create() $showId = $this->getShowId();
->findPK($this->_instanceId)
->getDbShowId(); $show = $this->getShow();
$current_timestamp = gmdate("Y-m-d H:i");
if ($current_timestamp < $this->getShowInstanceStart()) {
if ($show->isRepeating()) {
CcShowInstancesQuery::create() CcShowInstancesQuery::create()
->findPK($this->_instanceId) ->findPK($this->_instanceId)
->setDbModifiedInstance(true) ->setDbModifiedInstance(true)
->save(); ->save();
//delete the rebroadcasts of the removed recorded show.
if ($recording) {
CcShowInstancesQuery::create()
->filterByDbOriginalShow($this->_instanceId)
->delete();
}
/* Automatically delete all files scheduled in cc_schedules table. */ /* Automatically delete all files scheduled in cc_schedules table. */
CcScheduleQuery::create() CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId) ->filterByDbInstanceId($this->_instanceId)
@ -423,8 +434,6 @@ class Application_Model_ShowInstance {
->filterByDbModifiedInstance(false) ->filterByDbModifiedInstance(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
@ -434,6 +443,12 @@ class Application_Model_ShowInstance {
->filterByDbId($showId) ->filterByDbId($showId)
->delete(); ->delete();
} }
}
else {
$show->deleteShow();
}
}
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
if($recording){ if($recording){