Where robots go to become sentient

Home / Blogs / eZ Blog / Finding double-published items

Finding double-published items

I had to find objects that had multiple locations for a client.  This is what I came up with:

 <?php
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance( array(  'description' => (
                                      "finds double-published objects" ),
                                      'use-session' => true,
                                      'use-modules' => true,
                                      'use-extensions' => true ) );
 
$script->startup();
 
$options = $script->getOptions( "", "[topNodeID]", array() );
$script->initialize();
 
$params['MainNodeOnly']         = true;
$params['IgnoreVisibility']   = true;
 
$topNodeID = ctype_digit($options["arguments"][0]) ? $options["arguments"][0] : 2;
 
$objects = eZContentObjectTreeNode::subTreeByNodeID( $params, $topNodeID );
foreach($objects as $object) {
        $parents=eZContentObjectTreeNode::getParentNodeIdListByContentObjectID( $object->ContentObject->ID );
        if (count($parents) != 1 ) {
                echo $object->attribute( 'path_identification_string')."\n";
        }
}
$script->shutdown();
?>