Blogs / Steven E. Bailey / Finding double-published items

Finding double-published items

Wednesday 29 June 2011 2:47:59 pm

  • Currently 4 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

By : Steven E. Bailey

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();
?>

Blog Post Discussion

Finding double-published items