CC-4961: Show linking

This commit is contained in:
denise 2013-04-26 16:10:01 -04:00
parent 52655ab375
commit a5264aac1e
1 changed files with 14 additions and 8 deletions

View File

@ -45,20 +45,25 @@ class Application_Model_Scheduler
$this->checkUserPermissions = $value; $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) { foreach ($itemsToMove as $itemToMove) {
$ccShowInstance = CcShowInstancesQuery::create() $ccShowInstance = CcShowInstancesQuery::create()
->findPk($itemToMove["instance"]); ->findPk($itemToMove["instance"]);
//does the item being moved belong to a linked show //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")); 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,10 +560,11 @@ class Application_Model_Scheduler
//need to keep same id for resources if we want REST. //need to keep same id for resources if we want REST.
if (isset($file['sched_id'])) { if (isset($file['sched_id'])) {
$sched = CcScheduleQuery::create() /*$sched = CcScheduleQuery::create()
->filterByDbInstanceId($instance->getDbId()) ->filterByDbInstanceId($instance->getDbId())
->filterByDbFileId($file["id"]) ->filterByDbFileId($file["id"])
->findOne(); ->findOne();*/
$sched = CcScheduleQuery::create()->findPk($file["sched_id"]);
$excludeIds[] = intval($sched->getDbId()); $excludeIds[] = intval($sched->getDbId());