From 1b3a9f6e6af6f0f293dce77a0dc8065e3b875cb7 Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 9 Jul 2015 12:18:21 -0400 Subject: [PATCH 1/2] SAAS-924: Cannot edit repeating show if first instance has ended Reverted old behaviour where we set the show start and end date/time to the next repeating instance start and end. --- .../application/services/ShowFormService.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 92ffa4907..24c66e3ef 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -155,19 +155,14 @@ class Application_Service_ShowFormService if ($ccShowDay->isShowStartInPast()) { //for a non-repeating show, we should never allow user to change the start time. //for a repeating show, we should allow because the form works as repeating template form - $form->disableStartDateAndTime(); - - // Removing this - if there is no future instance, this will throw an error. - // If there is a future instance, then we get a WHEN block representing the next instance - // which may be confusing. - /*if (!$ccShowDay->isRepeating()) { + if (!$ccShowDay->isRepeating()) { $form->disableStartDateAndTime(); } else { list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); if ($this->hasShowStarted($showStart)) { $form->disableStartDateAndTime(); } - }*/ + } } $form->populate( @@ -183,6 +178,29 @@ class Application_Service_ShowFormService return $showStart; } + public function getNextFutureRepeatShowTime() + { + $ccShowInstance = CcShowInstancesQuery::create() + ->filterByDbShowId($this->ccShow->getDbId()) + ->filterByDbModifiedInstance(false) + ->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN) + ->orderByDbStarts() + ->findOne(); + + if (!$ccShowInstance) { + return null; + } + + $starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC")); + $ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC")); + $showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone(); + + $starts->setTimezone(new DateTimeZone($showTimezone)); + $ends->setTimezone(new DateTimeZone($showTimezone)); + + return array($starts, $ends); + } + private function populateInstanceFormWhen($form) { $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); @@ -437,7 +455,7 @@ class Application_Service_ShowFormService $ccShowInstance = CcShowInstancesQuery::create() ->filterByDbShowId($this->ccShow->getDbId()) ->filterByDbModifiedInstance(false) - ->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL) + ->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_EQUAL) ->orderByDbStarts() ->findOne(); From 721cd5a31bbfdbc880c07d7caa4c05f0f5f9c43d Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 13 Jul 2015 09:04:49 -0400 Subject: [PATCH 2/2] SAAS-924: Cannot edit repeating show if first instance has ended Added safeguard in case we don't find a future show instance --- airtime_mvc/application/services/ShowFormService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 24c66e3ef..8af6a78fa 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -158,7 +158,11 @@ class Application_Service_ShowFormService if (!$ccShowDay->isRepeating()) { $form->disableStartDateAndTime(); } else { - list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); + $showStartAndEnd = $this->getNextFutureRepeatShowTime(); + if (!is_null($showStartAndEnd)) { + $showStart = $showStartAndEnd["starts"]; + $showEnd = $showStartAndEnd["ends"]; + } if ($this->hasShowStarted($showStart)) { $form->disableStartDateAndTime(); } @@ -198,7 +202,7 @@ class Application_Service_ShowFormService $starts->setTimezone(new DateTimeZone($showTimezone)); $ends->setTimezone(new DateTimeZone($showTimezone)); - return array($starts, $ends); + return array("starts" => $starts, "ends" => $ends); } private function populateInstanceFormWhen($form)