eZContentOperationCollection::moveNode PHP Method

moveNode() public static method

Moves a node
public static moveNode ( integer $nodeID, integer $objectID, integer $newParentNodeID ) : array
$nodeID integer
$objectID integer
$newParentNodeID integer
return array An array with operation status, always true
    public static function moveNode($nodeID, $objectID, $newParentNodeID)
    {
        if (!eZContentObjectTreeNodeOperations::move($nodeID, $newParentNodeID)) {
            eZDebug::writeError("Failed to move node {$nodeID} as child of parent node {$newParentNodeID}", __METHOD__);
            return array('status' => false);
        }
        eZContentObject::fixReverseRelations($objectID, 'move');
        return array('status' => true);
    }

Usage Example

Esempio n. 1
0
         if (!$selectedNode->canMoveTo($classID)) {
             eZDebug::writeError("Cannot move node {$nodeID} as child of parent node {$selectedNodeID}, the current user does not have create permission for class ID {$classID}", 'content/action');
             return $module->redirectToView('view', array('full', 2));
         }
         // Check if we try to move the node as child of itself or one of its children
         if (in_array($node->attribute('node_id'), $selectedNode->pathArray())) {
             eZDebug::writeError("Cannot move node {$nodeID} as child of itself or one of its own children (node {$selectedNodeID}).", 'content/action');
             return $module->redirectToView('view', array('full', $node->attribute('node_id')));
         }
     }
     // move selected nodes, this should probably be inside a transaction
     foreach ($nodeToMoveList as $nodeToMove) {
         if (eZOperationHandler::operationIsAvailable('content_move')) {
             $operationResult = eZOperationHandler::execute('content', 'move', array('node_id' => $nodeToMove['node_id'], 'object_id' => $nodeToMove['object_id'], 'new_parent_node_id' => $selectedNodeID), null, true);
         } else {
             eZContentOperationCollection::moveNode($nodeToMove['node_id'], $nodeToMove['object_id'], $selectedNodeID);
         }
     }
     return $module->redirectToView('view', array($viewMode, $selectedNodeID, $languageCode));
 } else {
     if ($module->isCurrentAction('MoveNodeRequest')) {
         /* This action is started through the pop-up menu when a "Move" is
          * requested and through the use of the "Move" button. It will start the
          * browser to select where the node should be moved to. */
         if (!$module->hasActionParameter('NodeID')) {
             eZDebug::writeError("Missing NodeID parameter for action " . $module->currentAction(), 'content/action');
             return $module->redirectToView('view', array('full', 2));
         }
         $nodeID = $module->actionParameter('NodeID');
         $node = eZContentObjectTreeNode::fetch($nodeID);
         if (!$node) {
All Usage Examples Of eZContentOperationCollection::moveNode