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();
} }
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); //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);
}
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

@ -31,7 +31,7 @@ class Application_Model_ShowInstance {
/* This function is weird. It should return a boolean, but instead returns /* This function is weird. It should return a boolean, but instead returns
* an integer if it is a rebroadcast, or returns null if it isn't. You can convert * an integer if it is a rebroadcast, or returns null if it isn't. You can convert
* it to boolean by using is_null(isRebroadcast), where true means isn't and false * it to boolean by using is_null(isRebroadcast), where true means isn't and false
* means that it is. */ * means that it is. */
public function isRebroadcast() public function isRebroadcast()
{ {
@ -399,40 +399,55 @@ 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();
CcShowInstancesQuery::create() $show = $this->getShow();
->findPK($this->_instanceId)
->setDbModifiedInstance(true)
->save();
/* Automatically delete all files scheduled in cc_schedules table. */
CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->delete();
// check if we can safely delete the show $current_timestamp = gmdate("Y-m-d H:i");
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbModifiedInstance(false)
->findOne();
/* If we didn't find any instances of the show that haven't if ($current_timestamp < $this->getShowInstanceStart()) {
* been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should if ($show->isRepeating()) {
* take care of deleting all of its instances. */
if(is_null($showInstancesRow)){ CcShowInstancesQuery::create()
CcShowQuery::create() ->findPK($this->_instanceId)
->filterByDbId($showId) ->setDbModifiedInstance(true)
->delete(); ->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. */
CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->delete();
// check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbModifiedInstance(false)
->findOne();
/* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should
* take care of deleting all of its instances. */
if(is_null($showInstancesRow)){
CcShowQuery::create()
->filterByDbId($showId)
->delete();
}
}
else {
$show->deleteShow();
}
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();