swapNode() public static method

Swap a node with another one
public static swapNode ( integer $nodeID, integer $selectedNodeID, array $nodeIdList = [] ) : array
$nodeID integer
$selectedNodeID integer
$nodeIdList array
return array An array with operation status, always true
Esempio n. 1
0
     if (!$nodeParent || !$selectedNodeParent) {
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel', array());
     }
     if (!$nodeParent->canMoveTo($selectedObjectClassID)) {
         eZDebug::writeError("Cannot move an object of class {$selectedObjectClassID} to node {$nodeParentNodeID} (no create permission)");
         return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array());
     }
     if (!$selectedNodeParent->canMoveTo($objectClassID)) {
         eZDebug::writeError("Cannot move an object of class {$objectClassID} to node {$selectedNodeParentNodeID} (no create permission)");
         return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array());
     }
     // exchange contentobject ids and versions.
     if (eZOperationHandler::operationIsAvailable('content_swap')) {
         $operationResult = eZOperationHandler::execute('content', 'swap', array('node_id' => $nodeID, 'selected_node_id' => $selectedNodeID, 'node_id_list' => array($nodeID, $selectedNodeID)), null, true);
     } else {
         eZContentOperationCollection::swapNode($nodeID, $selectedNodeID, array($nodeID, $selectedNodeID));
     }
     return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
 } else {
     if ($module->isCurrentAction('SwapNodeRequest')) {
         /* This action brings a browse screen up to select with which the selected
          * node should be swapped. It will not actually move the nodes. */
         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) {
             return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel', array());
         }