$collections += eZInformationCollection::fetchCollectionCountForObject($objectID); } $tpl = eZTemplate::factory(); $tpl->setVariable('module', $module); $tpl->setVariable('collections', $collections); $tpl->setVariable('remove_type', 'objects'); $Result = array(); $Result['content'] = $tpl->fetch('design:infocollector/confirmremoval.tpl'); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/infocollector', 'Collected information'))); return; } if ($module->isCurrentAction('ConfirmRemoval')) { $objectIDArray = $http->sessionVariable('ObjectIDArray'); if (is_array($objectIDArray)) { foreach ($objectIDArray as $objectID) { eZInformationCollection::removeContentObject($objectID); } } } if (eZPreferences::value('admin_infocollector_list_limit')) { switch (eZPreferences::value('admin_infocollector_list_limit')) { case '2': $limit = 25; break; case '3': $limit = 50; break; default: $limit = 10; break; }
/** * Deletes the current object, all versions and translations, and corresponding tree nodes from the database * * 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. */ function purge() { $delID = $this->ID; // Who deletes which content should be logged. eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ), 'Comment' => 'Purged the current object: eZContentObject::purge()' ) ); $db = eZDB::instance(); $db->begin(); $attrOffset = 0; $attrLimit = 20; while ( $contentobjectAttributes = $this->allContentObjectAttributes( $delID, true, array( 'limit' => $attrLimit, 'offset' => $attrOffset ) ) ) { foreach ( $contentobjectAttributes as $contentobjectAttribute ) { $dataType = $contentobjectAttribute->dataType(); if ( !$dataType ) continue; $dataType->deleteStoredObjectAttribute( $contentobjectAttribute ); } $attrOffset += $attrLimit; } eZInformationCollection::removeContentObject( $delID ); eZContentObjectTrashNode::purgeForObject( $delID ); $db->query( "DELETE FROM ezcontentobject_tree WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_attribute WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_version WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_name WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcobj_state_link WHERE contentobject_id=$delID" ); $db->query( "DELETE FROM ezcontentobject WHERE id='$delID'" ); $db->query( "DELETE FROM eznode_assignment WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_role WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_discountrule WHERE contentobject_id = '$delID'" ); eZContentObject::fixReverseRelations( $delID, 'remove' ); eZSearch::removeObjectById( $delID ); // Check if deleted object is in basket/wishlist $sql = 'SELECT DISTINCT ezproductcollection_item.productcollection_id FROM ezbasket, ezwishlist, ezproductcollection_item WHERE ( ezproductcollection_item.productcollection_id=ezbasket.productcollection_id OR ezproductcollection_item.productcollection_id=ezwishlist.productcollection_id ) AND ezproductcollection_item.contentobject_id=' . $delID; $rows = $db->arrayQuery( $sql ); if ( count( $rows ) > 0 ) { $countElements = 50; $deletedArray = array(); // Create array of productCollectionID will be removed from ezwishlist and ezproductcollection_item foreach ( $rows as $row ) { $deletedArray[] = $row['productcollection_id']; } // Split $deletedArray into several arrays with $countElements values $splitted = array_chunk( $deletedArray, $countElements ); // Remove eZProductCollectionItem and eZWishList foreach ( $splitted as $value ) { eZPersistentObject::removeObject( eZProductCollectionItem::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); eZPersistentObject::removeObject( eZWishList::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); } } $db->query( 'UPDATE ezproductcollection_item SET contentobject_id = 0 WHERE contentobject_id = ' . $delID ); // Cleanup relations in two steps to avoid locking table for to long $db->query( "DELETE FROM ezcontentobject_link WHERE from_contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezcontentobject_link WHERE to_contentobject_id = '$delID'" ); // Cleanup properties: LastVisit, Creator, Owner $db->query( "DELETE FROM ezuservisit WHERE user_id = '$delID'" ); $db->query( "UPDATE ezcontentobject_version SET creator_id = 0 WHERE creator_id = '$delID'" ); $db->query( "UPDATE ezcontentobject SET owner_id = 0 WHERE owner_id = '$delID'" ); if ( isset( $GLOBALS["eZWorkflowTypeObjects"] ) and is_array( $GLOBALS["eZWorkflowTypeObjects"] ) ) { $registeredTypes =& $GLOBALS["eZWorkflowTypeObjects"]; } else { $registeredTypes = eZWorkflowType::fetchRegisteredTypes(); } // Cleanup ezworkflow_event etc... foreach ( array_keys( $registeredTypes ) as $registeredTypeKey ) { $registeredType = $registeredTypes[$registeredTypeKey]; $registeredType->cleanupAfterRemoving( array( 'DeleteContentObject' => $delID ) ); } $db->commit(); }