CC-5241: deleting a linked show, show comes back in the schedule

This commit is contained in:
denise 2013-06-18 16:56:16 -04:00
parent c11021af0f
commit b95a0d7c4a
1 changed files with 30 additions and 15 deletions

View File

@ -618,29 +618,44 @@ SQL;
->filterByDbShowId($showId) ->filterByDbShowId($showId)
->filterByDbModifiedInstance(false) ->filterByDbModifiedInstance(false)
->filterByDbRebroadcast(0) ->filterByDbRebroadcast(0)
->orderByDbStarts()
->find(); ->find();
if ($ccShowInstances->isEmpty()) { if ($ccShowInstances->isEmpty()) {
return true; return true;
} }
//only 1 show instance left of the show, make it non repeating. /* We need to update the last_show in cc_show_days so the instances
else if (count($ccShowInstances) === 1) { * don't get recreated as the user moves forward in the calendar
$ccShowInstance = $ccShowInstances[0]; */
else if (count($ccShowInstances) >= 1) {
$lastShowDays = array();
/* Creates an array where the key is the day of the week (monday,
* tuesday, etc.) and the value is the last show date for each
* day of the week. We will use this array to update the last_show
* for each cc_show_days entry of a cc_show
*/
foreach ($ccShowInstances as $instance) {
$instanceStartDT = new DateTime($instance->getDbStarts(),
new DateTimeZone("UTC"));
$lastShowDays[$instanceStartDT->format("w")] = $instanceStartDT;
}
foreach ($lastShowDays as $dayOfWeek => $lastShowStartDT) {
$ccShowDay = CcShowDaysQuery::create() $ccShowDay = CcShowDaysQuery::create()
->filterByDbShowId($showId) ->filterByDbShowId($showId)
->filterByDbDay($dayOfWeek)
->findOne(); ->findOne();
$tz = $ccShowDay->getDbTimezone();
$startDate = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC")); $lastShowStartDT->setTimeZone(new DateTimeZone(
$startDate->setTimeZone(new DateTimeZone($tz)); $ccShowDay->getDbTimezone()));
$endDate = Application_Service_CalendarService::addDeltas($startDate, 1, 0); $lastShowEndDT = Application_Service_CalendarService::addDeltas(
$lastShowStartDT, 1, 0);
$ccShowDay->setDbFirstShow($startDate->format("Y-m-d")); $ccShowDay
$ccShowDay->setDbLastShow($endDate->format("Y-m-d")); ->setDbLastShow($lastShowEndDT->format("Y-m-d"))
$ccShowDay->setDbStartTime($startDate->format("H:i:s")); ->save();
$ccShowDay->setDbRepeatType(-1);
$ccShowDay->save(); }
//remove the old repeating deleted instances. //remove the old repeating deleted instances.
CcShowInstancesQuery::create() CcShowInstancesQuery::create()