From 5ff89eeba27aaae45d7669691a90c9e33233d0c4 Mon Sep 17 00:00:00 2001 From: denise Date: Mon, 15 Oct 2012 14:19:52 -0400 Subject: [PATCH 1/2] CC-4561: Can create overlapping shows when rebroadcasting a repeating show -fixed --- airtime_mvc/application/forms/AddShowWhen.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index a81c8d05d..eb4e68a35 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -208,9 +208,22 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm //this is a new show $overlapping = Application_Model_Schedule::checkOverlappingShows( $repeatShowStart, $repeatShowEnd); + + /* If the repeating show is rebroadcasted we need to check + * the rebroadcast dates relative to the repeating show + */ + if (!$overlapping && $formData['add_show_rebroadcast']) { + $overlapping = self::checkRebroadcastDates( + $repeatShowStart, $formData, $hours, $minutes); + } } else { $overlapping = Application_Model_Schedule::checkOverlappingShows( $repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]); + + if (!$overlapping && $formData['add_show_rebroadcast']) { + $overlapping = self::checkRebroadcastDates( + $repeatShowStart, $formData, $hours, $minutes, true); + } } if ($overlapping) { @@ -275,6 +288,39 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm return $valid; } + public function checkRebroadcastDates($repeatShowStart, $formData, $hours, $minutes, $showEdit=false) { + $overlapping = false; + for ($i = 1; $i <= 10; $i++) { + if (empty($formData["add_show_rebroadcast_date_".$i])) break; + $rebroadcastShowStart = clone $repeatShowStart; + /* formData is in local time so we need to set the + * show start back to local time + */ + $rebroadcastShowStart->setTimezone(new DateTimeZone( + Application_Model_Preference::GetTimezone())); + $rebroadcastWhenDays = explode(" ", $formData["add_show_rebroadcast_date_".$i]); + $rebroadcastWhenTime = explode(":", $formData["add_show_rebroadcast_time_".$i]); + $rebroadcastShowStart->add(new DateInterval("P".$rebroadcastWhenDays[0]."D")); + $rebroadcastShowStart->setTime($rebroadcastWhenTime[0], $rebroadcastWhenTime[1]); + $rebroadcastShowStart->setTimezone(new DateTimeZone('UTC')); + + $rebroadcastShowEnd = clone $rebroadcastShowStart; + $rebroadcastShowEnd->add(new DateInterval("PT".$hours."H".$minutes."M")); + + if ($showEdit) { + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $rebroadcastShowStart, $rebroadcastShowEnd, true, null, $formData['add_show_id']); + } else { + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $rebroadcastShowStart, $rebroadcastShowEnd); + } + + if ($overlapping) break; + } + + return $overlapping; + } + public function disable() { $elements = $this->getElements(); From 9d3271c03d28e902a57391a473e1552b317e4ae2 Mon Sep 17 00:00:00 2001 From: denise Date: Mon, 15 Oct 2012 15:36:38 -0400 Subject: [PATCH 2/2] CC-4562: Calendar: Add Show button is removed after editing a show from regular show to repeating show -fixed --- airtime_mvc/application/controllers/ScheduleController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index adf84380e..a8b5b557c 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -784,7 +784,10 @@ class ScheduleController extends Zend_Controller_Action if ($success) { $scheduler = new Application_Model_Scheduler(); - $scheduler->removeGaps($data['add_show_instance_id']); + $showInstances = CcShowInstancesQuery::create()->filterByDbShowId($data['add_show_id'])->find(); + foreach ($showInstances as $si) { + $scheduler->removeGaps($si->getDbId()); + } $this->view->addNewShow = true; $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } else {