From a5264aac1e80686fa39a995e3170a437cc74cd02 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 26 Apr 2013 16:10:01 -0400 Subject: [PATCH] CC-4961: Show linking --- airtime_mvc/application/models/Scheduler.php | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 9e2c432ae..dd05c19c7 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -45,20 +45,25 @@ class Application_Model_Scheduler $this->checkUserPermissions = $value; } - private function validateItemMove($itemsToMove, $afterItem) + private function validateItemMove($itemsToMove, $destination) { - $afterInstanceId = $afterItem["instance"]; + $destinationInstanceId = $destination["instance"]; + $destinationCcShowInstance = CcShowInstancesQuery::create() + ->findPk($destinationInstanceId); + $isDestinationLinked = $destinationCcShowInstance->getCcShow()->isLinked(); foreach ($itemsToMove as $itemToMove) { $ccShowInstance = CcShowInstancesQuery::create() ->findPk($itemToMove["instance"]); //does the item being moved belong to a linked show - $linked = $ccShowInstance->getCcShow()->isLinked(); + $isSourceLinked = $ccShowInstance->getCcShow()->isLinked(); - if ($linked && $itemToMove["instance"] != $afterInstanceId) { + if ($isSourceLinked && $itemToMove["instance"] != $destinationInstanceId) { throw new Exception(_("Linked items can only be moved within its own show")); - } + } /*elseif ($isDestinationLinked && $isSourceLinked) { + throw new Exception(_("Items can only be moved to and from unlinked shows")); + }*/ } } @@ -555,11 +560,12 @@ class Application_Model_Scheduler //need to keep same id for resources if we want REST. if (isset($file['sched_id'])) { - $sched = CcScheduleQuery::create() + /*$sched = CcScheduleQuery::create() ->filterByDbInstanceId($instance->getDbId()) ->filterByDbFileId($file["id"]) - ->findOne(); - + ->findOne();*/ + $sched = CcScheduleQuery::create()->findPk($file["sched_id"]); + $excludeIds[] = intval($sched->getDbId()); $file["cliplength"] = $sched->getDbClipLength();