Author Topic

Łukasz Serwatka

Thursday 29 September 2005 5:07:25 am

Comment32267

Use this, set correct login and password, since you need user with remove access, and set depth 1 if you remove from class which is container.

#!/usr/bin/env php
<?php
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );

include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/ezscript.php' );

$cli =& eZCLI::instance();
$script =& eZScript::instance();

$script->startup();

$script->initialize();

/**
 * @param array $classID
 * @param int $parentNodeID
 * @param int $depth
 * @param string $login
 * @param string $password
 */
function &deleteNodes ( $classID, $parentNodeID, $depth, $login, $password )
{
	eZUser::loginUser( $login, $password );

	$deleteIDArray = array();

	$nodeArray =& eZContentObjectTreeNode::subTree(  array(
	'ClassFilterType' => 'include',
	'ClassFilterArray' => $classID,
	'Depth' => $depth,
	), $parentNodeID
	);
	foreach ( $nodeArray as $node )
	{
		$deleteIDArray[] = $node->attribute( 'main_node_id' );
	}

	eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, false );
}

deleteNodes ( array( 2 ), 2, 1, 'admin', '1234' );

$script->shutdown();
?>

Run from Exponential root.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog