From 3f97b071fed3c136d81501e0fc92690e0b360661 Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 30 May 2013 11:06:45 -0400 Subject: [PATCH] CC-5187: Edit show -> disable linking option if show is currently playing --- .../application/services/ShowFormService.php | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index a82279a56..6b3e67239 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -99,8 +99,9 @@ class Application_Service_ShowFormService public function delegateShowFormPopulation($forms) { $this->populateFormWhat($forms["what"]); - $this->populateFormWhen($forms["when"]); - $this->populateFormRepeats($forms["repeats"]); + //local show start DT + $showStart = $this->populateFormWhen($forms["when"]); + $this->populateFormRepeats($forms["repeats"], $showStart); $this->populateFormWho($forms["who"]); $this->populateFormStyle($forms["style"]); $this->populateFormLive($forms["live"]); @@ -136,6 +137,9 @@ class Application_Service_ShowFormService $form->disableStartDateAndTime(); } else { list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); + if ($this->hasShowStarted($showStart)) { + $form->disableStartDateAndTime(); + } } } @@ -147,6 +151,8 @@ class Application_Service_ShowFormService 'add_show_end_time' => $showEnd->format("H:i"), 'add_show_duration' => $ccShowDay->formatDuration(true), 'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0)); + + return $showStart; } private function populateInstanceFormWhen($form) @@ -179,7 +185,13 @@ class Application_Service_ShowFormService $form->getElement('add_show_repeats')->setOptions(array("disabled" => true)); } - private function populateFormRepeats($form) + /** + * + * Enter description here ... + * @param $form + * @param DateTime $nextFutureShowStart user's local timezone + */ + private function populateFormRepeats($form, $nextFutureShowStart) { $ccShowDays = $this->ccShow->getCcShowDays(); @@ -219,6 +231,14 @@ class Application_Service_ShowFormService if (!$this->ccShow->isLinkable() || $this->ccShow->isRecorded()) { $form->getElement('add_show_linked')->setOptions(array('disabled' => true)); } + + /* Because live editing of a linked show is disabled, we will disable + * the linking option if the current show is being edited. We don't + * want the user to suddenly not be able to edit the current show + */ + if ($this->hasShowStarted($nextFutureShowStart)) { + $form->getElement('add_show_linked')->setOptions(array('disabled' => true)); + } } private function populateFormWho($form) @@ -295,6 +315,22 @@ class Application_Service_ShowFormService $form->populate($formValues); } + /** + * + * Enter description here ... + * @param DateTime $showStart user's local time + */ + private function hasShowStarted($p_showStart) { + $showStart = clone $p_showStart; + $showStart->setTimeZone(new DateTimeZone("UTC")); + + if ($showStart->format("Y-m-d H:i:s") < gmdate("Y-m-d H:i:s")) { + return true; + } else { + return false; + } + } + /** * * Before we send the form data in for validation, there