static function deleteNodeWhereParent($node, $id) { eZContentObjectTreeNode::removeNode(eZContentObjectTreeNode::findNode($node, $id)); }
/** * Archives the current object and removes assigned nodes * * Transaction unsafe. If you call several transaction unsafe methods you must enclose * the calls within a db transaction; thus within db->begin and db->commit. * * @param int $nodeID */ function removeThis( $nodeID = null ) { $delID = $this->ID; // Who deletes which content should be logged. eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ), 'Comment' => 'Setted archived status for the current object: eZContentObject::remove()' ) ); $nodes = $this->attribute( 'assigned_nodes' ); if ( $nodeID === null or count( $nodes ) <= 1 ) { $db = eZDB::instance(); $db->begin(); $mainNodeKey = false; foreach ( $nodes as $key => $node ) { if ( $node->attribute( 'main_node_id' ) == $node->attribute( 'node_id' ) ) { $mainNodeKey = $key; } else { $node->removeThis(); } } if ( $mainNodeKey !== false ) { $nodes[$mainNodeKey]->removeNodeFromTree( true ); } $this->setAttribute( 'status', eZContentObject::STATUS_ARCHIVED ); eZSearch::removeObjectById( $delID ); $this->store(); eZContentObject::fixReverseRelations( $delID, 'trash' ); // Delete stored attribute from other tables $db->commit(); } else if ( $nodeID !== null ) { $node = eZContentObjectTreeNode::fetch( $nodeID , false ); if ( is_object( $node ) ) { if ( $node->attribute( 'main_node_id' ) == $nodeID ) { $db = eZDB::instance(); $db->begin(); foreach ( $additionalNodes as $additionalNode ) { if ( $additionalNode->attribute( 'node_id' ) != $node->attribute( 'main_node_id' ) ) { $additionalNode->remove(); } } $node->removeNodeFromTree( true ); $this->setAttribute( 'status', eZContentObject::STATUS_ARCHIVED ); eZSearch::removeObjectById( $delID ); $this->store(); eZContentObject::fixReverseRelations( $delID, 'trash' ); $db->commit(); } else { eZContentObjectTreeNode::removeNode( $nodeID ); } } } else { eZContentObjectTreeNode::removeNode( $nodeID ); } }