Delete children objects where create data is less than "X" hour - eZ Publish 5

86 Views Asked by At

I need simple php code for deleting children objects in ez publish 5, i'm trying to create cron job file and delete objects in ez publish where created date is leess then "x" hour , in my case it is 24 hour. if some have had wrote this code before, please share it me too, it would be very helpful for me.

Best regards :)

i trying  this  but not working and crack database:


#!/usr/bin/env php
<?php

include_once( 'ezpublish_legacy/kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'ezpublish_legacy/kernel/classes/ezcontentobject.php' );
include_once( 'ezpublish_legacy/kernel/classes/datatypes/ezuser/ezuser.php' );
include_once( 'ezpublish_legacy/lib/ezutils/classes/ezcli.php' );
include_once( 'ezpublish_legacy/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( 230 ), 336, 1, 'admin', 'publish' );

$script->shutdown();
?>

1

There are 1 best solutions below

0
Anonymouse On

This question is closed, i do not get here clear answer and did it with to myself. i get only -1 for this question lol