From 8f5830757fdb123f1ed59df5f361520018e1e2ef Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 12 Oct 2012 14:26:54 -0400 Subject: [PATCH 1/8] CC-4553: Calendar: Can create overlapping show by repeat show's instances -fixed --- airtime_mvc/application/forms/AddShowWhen.php | 19 +++++------- airtime_mvc/application/models/Schedule.php | 30 ++++++++++++++----- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 86018ff1a..870e79183 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -199,20 +199,15 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $repeatShowEnd->add(new DateInterval("P".$daysAdd."D")); } while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) { - //need to get each repeating show's instance id - $qry = CcShowInstancesQuery::create() - ->filterByDbStarts($repeatShowStart->format('Y-m-d H:i:s')) - ->filterByDbEnds($repeatShowEnd->format('Y-m-d H:i:s')) - ->find(); - $count = $qry->count(); - if ($count > 1) { - $overlapping = true; - } elseif ($count == 1) { - $instanceId = $qry->getFirst()->getDbId(); - $overlapping = Application_Model_Schedule::checkOverlappingShows($repeatShowStart, $repeatShowEnd, $update, $instanceId); + if (!$formData['add_show_id']) { + //this is a new show + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $repeatShowStart, $repeatShowEnd); } else { - $overlapping = false; + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]); } + if ($overlapping) { $valid = false; $this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows')); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index eff64b2ec..1102efaff 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1157,14 +1157,21 @@ SQL; } public static function checkOverlappingShows($show_start, $show_end, - $update=false, $instanceId=null) + $update=false, $instanceId=null, $showId=null) { $overlapping = false; + + $params = array( + ':show_end1' => $show_end->format('Y-m-d H:i:s'), + ':show_end2' => $show_end->format('Y-m-d H:i:s'), + ':show_end3' => $show_end->format('Y-m-d H:i:s') + ); + + /* If a show is being edited, exclude it from the query * In both cases (new and edit) we only grab shows that * are scheduled 2 days prior */ - //$se = $show_end->format('Y-m-d H:i:s'); if ($update) { $sql = <<= (date(:show_end3) - INTERVAL '2 days') AND modified_instance = FALSE +SQL; + if (is_null($showId)) { + $sql .= << $show_end->format('Y-m-d H:i:s'), - ':show_end2' => $show_end->format('Y-m-d H:i:s'), - ':show_end3' => $show_end->format('Y-m-d H:i:s'), - ':instanceId' => $instanceId - ), 'all'); + $params[':instanceId'] = $instanceId; + } else { + $sql .= << $show_end->format('Y-m-d H:i:s'), ':show_end3' => $show_end->format('Y-m-d H:i:s')), 'all'); } + foreach ($rows as $row) { $start = new DateTime($row["starts"], new DateTimeZone('UTC')); $end = new DateTime($row["ends"], new DateTimeZone('UTC')); From e60a23aab44619356a52893c9b08d65c56032a56 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 12 Oct 2012 15:34:42 -0400 Subject: [PATCH 2/8] CC-4555: Can create overlapping shows with a repeating show if another show is on the last repeating day -fixed --- airtime_mvc/application/forms/AddShowWhen.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 870e79183..bf1f1c83d 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -163,7 +163,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } elseif (!$formData["add_show_no_end"]) { $popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"]; - $populateUntilDateTime = new DateTime($popUntil, new DateTimeZone('UTC')); + $populateUntilDateTime = new DateTime($popUntil); + $populateUntilDateTime->setTimezone(new DateTimeZone('UTC')); } //get repeat interval @@ -198,8 +199,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $repeatShowStart->add(new DateInterval("P".$daysAdd."D")); $repeatShowEnd->add(new DateInterval("P".$daysAdd."D")); } + /* Here we are checking each repeating show by + * the show day. + * (i.e: every wednesday, then every thursday) + */ while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) { - if (!$formData['add_show_id']) { + if ($formData['add_show_id'] == -1) { //this is a new show $overlapping = Application_Model_Schedule::checkOverlappingShows( $repeatShowStart, $repeatShowEnd); From b79e190d3c686fb000c2f7af71061389a9c1e8dc Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 12 Oct 2012 15:42:51 -0400 Subject: [PATCH 3/8] -small comment change --- airtime_mvc/application/forms/AddShowWhen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index bf1f1c83d..a81c8d05d 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -201,7 +201,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } /* Here we are checking each repeating show by * the show day. - * (i.e: every wednesday, then every thursday) + * (i.e: every wednesday, then every thursday, etc.) */ while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) { if ($formData['add_show_id'] == -1) { From a103c76378834d50684bab3bc831c5ac21f7fd18 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 15 Oct 2012 12:27:16 +0100 Subject: [PATCH 4/8] CC-4558: Make button in Now Playing consistent with same action in Calendar --- airtime_mvc/application/views/scripts/showbuilder/index.phtml | 4 ++-- airtime_mvc/public/js/airtime/showbuilder/main_builder.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/views/scripts/showbuilder/index.phtml b/airtime_mvc/application/views/scripts/showbuilder/index.phtml index 3239b82f6..04851dfc4 100644 --- a/airtime_mvc/application/views/scripts/showbuilder/index.phtml +++ b/airtime_mvc/application/views/scripts/showbuilder/index.phtml @@ -11,8 +11,8 @@
\ No newline at end of file +
From 5ff89eeba27aaae45d7669691a90c9e33233d0c4 Mon Sep 17 00:00:00 2001 From: denise Date: Mon, 15 Oct 2012 14:19:52 -0400 Subject: [PATCH 6/8] 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 7/8] 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 { From 03b32ea986f29de48730c89911bb5f92e47f646d Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Oct 2012 10:37:42 -0400 Subject: [PATCH 8/8] CC-4563 Library: Exception is found when remove a block by context menu - fixed --- airtime_mvc/public/js/airtime/library/library.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 161d18d45..a832134c1 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -815,9 +815,10 @@ var AIRTIME = (function(AIRTIME) { //playlist screen if this is the currently edited playlist. if ((data.ftype === "playlist" || data.ftype === "block") && screen === "playlist") { callback = function() { - + aMedia = []; + aMedia.push({"id": data.id, "type": data.ftype}); if (confirm('Are you sure you want to delete the selected item?')) { - AIRTIME.playlist.fnDelete(data.id); + AIRTIME.library.fnDeleteItems(aMedia); } }; }