CC-5666: Deleting a show instance can revert the 'no end' option
This commit is contained in:
parent
a648f7fa2d
commit
9e5cfe0d39
|
@ -667,11 +667,7 @@ SQL;
|
|||
|
||||
$showId = $ccShowInstance->getDbShowId();
|
||||
if ($singleInstance) {
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbStarts($ccShowInstance->getDbStarts(), Criteria::GREATER_EQUAL)
|
||||
->filterByDbEnds($ccShowInstance->getDbEnds(), Criteria::LESS_EQUAL)
|
||||
->find();
|
||||
$ccShowInstances = array($ccShowInstance);
|
||||
} else {
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
|
@ -680,7 +676,9 @@ SQL;
|
|||
}
|
||||
|
||||
if (gmdate("Y-m-d H:i:s") <= $ccShowInstance->getDbEnds()) {
|
||||
$this->deleteShowInstances($ccShowInstances, $ccShowInstance->getDbShowId());
|
||||
$this->deleteShowInstances($ccShowInstances, $showId);
|
||||
} else {
|
||||
throw new Exception("Cannot delete a show instance in the past");
|
||||
}
|
||||
|
||||
Application_Model_StoredFile::updatePastFilesIsScheduled();
|
||||
|
@ -688,6 +686,7 @@ SQL;
|
|||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
||||
$con->commit();
|
||||
|
||||
return $showId;
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
|
@ -723,12 +722,18 @@ SQL;
|
|||
CcShowQuery::create()
|
||||
->filterByDbId($showId)
|
||||
->delete();
|
||||
/* There is only one cc_show_instance if the user selects 'Delete This Instance'
|
||||
* There is more than one cc_show_instance if the user selects 'Delete This
|
||||
* Instance and All Following'. We only need to set the last_show value
|
||||
* when 'Delete This Instance and All Following' has been selected
|
||||
*/
|
||||
} elseif (count($ccShowInstances) > 1) {
|
||||
$this->setLastRepeatingShowDate($showId);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkToDeleteCcShow($showId)
|
||||
private function setLastRepeatingShowDate($showId)
|
||||
{
|
||||
// check if there are any non deleted show instances remaining.
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
|
@ -736,13 +741,9 @@ SQL;
|
|||
->orderByDbStarts()
|
||||
->find();
|
||||
|
||||
if ($ccShowInstances->isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
/* We need to update the last_show in cc_show_days so the instances
|
||||
* don't get recreated as the user moves forward in the calendar
|
||||
*/
|
||||
else if (count($ccShowInstances) >= 1) {
|
||||
$lastShowDays = array();
|
||||
|
||||
//get the show's timezone
|
||||
|
@ -782,6 +783,32 @@ SQL;
|
|||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Some cc_show_day records may not get updated because there may not be an instance
|
||||
// left on one of the repeating days so we have to find the entries where the last_show is
|
||||
// still null
|
||||
$showDays = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbRepeatType(0, Criteria::GREATER_EQUAL)
|
||||
->filterByDbLastShow(null)
|
||||
->find();
|
||||
foreach ($showDays as $showDay) {
|
||||
$showDay->setDbLastShow($showDay->getDbFirstShow())->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function checkToDeleteCcShow($showId)
|
||||
{
|
||||
// check if there are any non deleted show instances remaining.
|
||||
$ccShowInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->filterByDbRebroadcast(0)
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
|
||||
if ($ccShowInstances->isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue