function deleteObject($objectId)
{
$moveToTrash = false;
$object = eZContentObject::fetch((int) $objectId);
if (!is_object($object))
{
return false;
}
$nodes = $object->attribute('assigned_nodes');
//remove all nodes that are not main and their subtree
foreach ($nodes as $node)
{
if (!$node->attribute('is_main'))
{
eZContentObjectTreeNode::removeSubtrees( array($node->attribute('node_id')), $moveToTrash );
}
}
//loop again for the mainnode
$nodes = $object->attribute('assigned_nodes');
foreach ($nodes as $node)
{
eZContentObjectTreeNode::removeSubtrees( array($node->attribute('node_id')), $moveToTrash );
}
return true;
}