deleteObject() public static method

Deletes a content object, or a list of content objects
public static deleteObject ( array $deleteIDArray, boolean $moveToTrash = false ) : array
$deleteIDArray array
$moveToTrash boolean
return array An array with operation status, always true
Beispiel #1
0
if ($http->hasPostVariable('SupportsMoveToTrash')) {
    if ($http->hasPostVariable('MoveToTrash')) {
        $moveToTrash = $http->postVariable('MoveToTrash') ? true : false;
    } else {
        $moveToTrash = false;
    }
}
$hideRemoveConfirm = $contentINI->hasVariable('RemoveSettings', 'HideRemoveConfirmation') ? $contentINI->variable('RemoveSettings', 'HideRemoveConfirmation') == 'true' ? true : false : false;
if ($http->hasSessionVariable('HideRemoveConfirmation')) {
    $hideRemoveConfirm = $http->sessionVariable('HideRemoveConfirmation');
}
if ($http->hasPostVariable("ConfirmButton") or $hideRemoveConfirm) {
    if (eZOperationHandler::operationIsAvailable('content_delete')) {
        $operationResult = eZOperationHandler::execute('content', 'delete', array('node_id_list' => $deleteIDArray, 'move_to_trash' => $moveToTrash), null, true);
    } else {
        eZContentOperationCollection::deleteObject($deleteIDArray, $moveToTrash);
    }
    if ($http->hasSessionVariable('RedirectURIAfterRemove') && $http->sessionVariable('RedirectURIAfterRemove')) {
        $Module->redirectTo($http->sessionVariable('RedirectURIAfterRemove'));
        $http->removeSessionVariable('RedirectURIAfterRemove');
        return $http->removeSessionVariable('RedirectIfCancel');
    } else {
        return $Module->redirectToView('view', array($viewMode, $contentNodeID, $contentLanguage));
    }
}
$showCheck = $contentINI->hasVariable('RemoveSettings', 'ShowRemoveToTrashCheck') ? $contentINI->variable('RemoveSettings', 'ShowRemoveToTrashCheck') == 'false' ? false : true : true;
$info = eZContentObjectTreeNode::subtreeRemovalInformation($deleteIDArray);
$deleteResult = $info['delete_list'];
$moveToTrashAllowed = $info['move_to_trash'];
$totalChildCount = $info['total_child_count'];
$hasPendingObject = $info['has_pending_object'];
    /**
     * Same test as {@link self::testRemovePendingSearchSeveralNodesForObject()}, with not all nodes removed
     * Use case
     * --------
     * 1. If all nodes are removed, pending action must also be removed
     * 2. If NOT all nodes are removed (at least one node remaining for object), pending action must NOT be removed (case tested here)
     *
     * @group issue_17932
     */
    public function testRemovePendingSearchNotAllNodesRemoved()
    {
        $this->folder->addNode( 43 );
        $folderObjectID = $this->folder->object->attribute( 'id' );

        $aNodeID = array( $this->folder->nodes[0]->attribute( 'node_id' ) ); // Only delete the first node

        eZContentOperationCollection::deleteObject( $aNodeID );
        $filterConds = array(
            'action'        => 'index_object',
            'param'         => $folderObjectID
        );
        $pendingCount = eZPersistentObject::count( eZPendingActions::definition(), $filterConds );
        self::assertGreaterThan( 0, $pendingCount, "eZContentOperationCollection::deleteObject() must remove pending action for object #$folderObjectID as all nodes have been removed" );
    }
 /**
  * Does the remove job.
  * Will use content_delete operation if available (workflow support)
  * @param array $aNodeID
  * @param bool $moveToTrash Indicates if we move content to trash or not. True by default
  * @internal
  */
 private function doRemove(array $aNodeID, $moveToTrash = true)
 {
     if (eZOperationHandler::operationIsAvailable('content_delete')) {
         $operationResult = eZOperationHandler::execute('content', 'delete', array('node_id_list' => $aNodeID, 'move_to_trash' => $moveToTrash), null, true);
     } else {
         eZContentOperationCollection::deleteObject($aNodeID, $moveToTrash);
     }
 }
<?php

$return = false;
$objectId = (int) $_REQUEST['contentobjectid'];
if ($objectId) {
    $eZObj = eZContentObject::fetch($objectId);
    if ($eZObj && $eZObj->attribute('can_remove') && $eZObj->attribute('status') != eZContentObject::STATUS_ARCHIVED) {
        $result = eZContentOperationCollection::deleteObject(array($eZObj->attribute('main_node_id')), true);
        $return = $result['status'];
    }
}
header('Content-Type: application/json');
echo json_encode($return);
eZExecution::cleanExit();