return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'); } $existingNode = eZContentObjectTreeNode::fetch($nodeID); if (!$existingNode) { return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } $class = $object->contentClass(); if ($module->isCurrentAction('AddAssignment')) { $selectedNodeIDArray = eZContentBrowse::result('AddNodeAssignment'); if (!is_array($selectedNodeIDArray)) { $selectedNodeIDArray = array(); } if (eZOperationHandler::operationIsAvailable('content_addlocation')) { $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true); } else { eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray); } } else { if ($module->isCurrentAction('SelectAssignmentLocation')) { $ignoreNodesSelect = array(); $ignoreNodesClick = array(); $assigned = eZNodeAssignment::fetchForObject($objectID, $object->attribute('current_version'), 0, false); $publishedAssigned = $object->assignedNodes(false); $isTopLevel = false; foreach ($publishedAssigned as $element) { $append = false; if ($element['parent_node_id'] == 1) { $isTopLevel = true; } foreach ($assigned as $ass) { if ($ass['parent_node'] == $element['parent_node_id']) {
/** * Adds a location to provided content. * Prefer using SQLIContent::addLocation() instead of calling this method directly * @param SQLILocation $location * @param SQLIContent $content * @internal */ public function addLocationToContent(SQLILocation $location, SQLIContent $content) { $nodeID = $content->attribute('main_node_id'); if (!$nodeID) { // No main node ID, object has not been published at least once throw new SQLIContentException(__METHOD__ . ' => Cannot directly add a location to a not-yet-published content. Content Object ID = ' . $content->attribute('id') . '. Try to use SQLIContent::addLocation()'); } $objectID = $content->attribute('id'); $locationNodeID = $location->getNodeID(); // Check first if content has already an assigned node in provided location $assignedNodes = $content->assignedNodes(false); for ($i = 0, $iMax = count($assignedNodes); $i < $iMax; ++$i) { if ($locationNodeID == $assignedNodes[$i]['parent_node_id']) { eZDebug::writeWarning(__METHOD__ . ' => Content with ObjectID #' . $objectID . ' already has a location as a child of node #' . $locationNodeID); return; } } eZDebug::accumulatorStart('sqlicontentpublisher_add_location', 'sqlicontentpublisher', 'Adding a location for object #' . $objectID); $selectedNodeIDArray = array($locationNodeID); if (eZOperationHandler::operationIsAvailable('content_addlocation')) { $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true); } else { eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray); } $content->refreshLocations(); eZDebug::accumulatorStop('sqlicontentpublisher_add_location'); }