From 787f19f69ab249d863ad73f82d912d8c12e464f7 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 24 Feb 2014 14:49:11 -0500 Subject: [PATCH] CC-5697: Editing a linked show's repeat day sets wrong day for show content When a user edits a show and changes the repeat day, we are really deleting the instances from the original repeat day and creating new instances. Therefore, we don't need to update the show content's start/end time in this case. --- .../application/services/ShowService.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index f206a4abb..ea4007267 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -20,6 +20,7 @@ class Application_Service_ShowService private $localShowStartHour; private $localShowStartMin; private $origCcShowDay; + private $instanceIdsForScheduleUpdates; public function __construct($showId=null, $showData=null, $isUpdate=false) { @@ -39,6 +40,7 @@ class Application_Service_ShowService $this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0; $this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0; $this->isUpdate = $isUpdate; + $this->instanceIdsForScheduleUpdates = array(); } public function editRepeatingShowInstance($showData) { @@ -230,12 +232,10 @@ class Application_Service_ShowService private function adjustSchedule($showData) { $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); - $ccShowInstances = CcShowInstancesQuery::create() - ->filterByDbShowId($this->ccShow->getDbId()) - ->find(); $this->updateScheduleStartEndTimes($showData); + $ccShowInstances = $this->ccShow->getCcShowInstancess(); foreach ($ccShowInstances as $instance) { $instance->updateScheduleStatus($con); } @@ -271,6 +271,7 @@ class Application_Service_ShowService $ccShows = array(); foreach ($ccShowDays as $day) { + $this->instanceIdsForScheduleUpdates = array(); $this->ccShow = $day->getCcShow(); $this->isRecorded = $this->ccShow->isRecorded(); @@ -881,7 +882,6 @@ SQL; private function updateScheduleStartEndTimes($showData) { $showId = $this->ccShow->getDbId(); - //DateTime in show's local time $newStartDateTime = new DateTime($showData["add_show_start_date"]." ". $showData["add_show_start_time"], @@ -890,12 +890,9 @@ SQL; $diff = $this->calculateShowStartDiff($newStartDateTime, $this->origCcShowDay->getLocalStartDateAndTime()); - $ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); - $instanceIds = array(); - foreach ($ccShowInstances as $ccShowInstance) { - array_push($instanceIds, $ccShowInstance->getDbId()); - } - Application_Service_SchedulerService::updateScheduleStartTime($instanceIds, $diff); + Application_Service_SchedulerService::updateScheduleStartTime( + $this->instanceIdsForScheduleUpdates, + $diff); } /** @@ -1070,6 +1067,7 @@ SQL; $ccShowInstance = $this->getInstance($utcStartDateTime); $newInstance = false; $updateScheduleStatus = true; + array_push($this->instanceIdsForScheduleUpdates, $ccShowInstance->getDbId()); } else { $newInstance = true; $ccShowInstance = new CcShowInstances();