From fac96996e3244adb0dfa8ded826f9c0e745f0323 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 3 May 2013 11:37:11 -0400 Subject: [PATCH] CC-5084: Repeating show edited to linked doesn't add content to repeat instances Fixed. If the each repeating instance has different content, we replace it with the first instance's content --- .../application/services/SchedulerService.php | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index 6f1dcb920..2cf5711fc 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -170,7 +170,11 @@ class Application_Service_SchedulerService $ccSchedules = CcScheduleQuery::create() ->filterByDbInstanceId($ccShowInstance->getDbId()) ->find(); - if ($ccSchedules->isEmpty()) { + /* If the show instance is empty OR it has different content than + * the first instance, we cant to fill/replace with the show stamp + * (The show stamp is taken from the first show instance's content) + */ + if ($ccSchedules->isEmpty() || self::replaceInstanceContentCheck($ccShowInstance, $showStamp)) { $nextStartDT = $ccShowInstance->getDbStarts(null); foreach ($showStamp as $item) { @@ -205,6 +209,30 @@ class Application_Service_SchedulerService } } + private static function replaceInstanceContentCheck($ccShowInstance, $showStamp) + { + $currentShowStamp = CcScheduleQuery::create() + ->filterByDbInstanceId($ccShowInstance->getDbId()) + ->orderByDbStarts() + ->find(); + + $counter = 0; + foreach ($showStamp as $item) { + if ($item->getDbFileId() != $currentShowStamp[$counter]->getDbFileId() || + $item->getDbStreamId() != $currentShowStamp[$counter]->getDbStreamId()) { + CcScheduleQuery::create() + ->filterByDbInstanceId($ccShowInstance->getDbId()) + ->delete(); + return true; + } + } + + /* If we get here, the content in the show instance is the same + * as what we want to replace it with, so we can leave as is + */ + return false; + } + public function emptyShowContent($instanceId) { try {