/**
     * @see eZContentObjectEditHandler::publish()
     * @param int $contentObjectID
     * @param eZContentObjectVersion $contentObjectVersion
     */
    function publish( $contentObjectID, $contentObjectVersion )
    {
        $contentObject = eZContentObject::fetch( $contentObjectID );

        if( $contentObject instanceof eZContentObject )
        {
            switch($contentObject->ClassIdentifier)
            {
                case 'article':
                {
                    ObjectVisibilityManager::updateGlobalLimitation($contentObject);

                    /* @type $mainNode eZContentObjectTreeNode */
                    /* @type $clustersToHide array */
                    $db                 = eZDB::instance();
                    $mainNode           = $contentObject->mainNode();
                    $clustersToHide     = eZINI::instance( 'merck.ini' )->variable( 'PublishSettings', 'clustersToHide' );
                    $publisherNodeId    = PublisherFolderTool::getPublisherNodeIdFromArticleNode($mainNode);
                    $publisherInfo      = PublisherFolderTool::getNodeIdToPathMapping($publisherNodeId);
                    $publisherClusters  = PublisherFolderTool::getClustersFromPath($publisherInfo['path']);
                    $inserted           = false;
                    
                    foreach( $clustersToHide as $clusterToHide )
                    {
                        if( in_array($clusterToHide, $publisherClusters) )
                        {
                            if ( !$inserted )
                            {
                                $db->query( sprintf(
                                    "INSERT INTO ezpending_actions (action, created, param)
                                        VALUES ('check_node_visibility', %d, '%s' )",
                                    time(),
                                    $contentObject->mainNodeID()
                                ));
                                $inserted = true;
                            }
                            
                            ObjectVisibilityManager::updateClusterLimitation($contentObjectID, $clusterToHide, true);
                        }
                    }
                }
                break;
            }
        }
    }
    /**
     * @param eZContentObjectTreeNode $node
     * @return string[]
     */
    public static function getArticleClusters( $node )
    {
        $publisherFolderPath = PublisherFolderTool::getPublisherFolderPathFromArticleNode($node);

        return PublisherFolderTool::getClustersFromPath($publisherFolderPath);
    }
    /**
     * Manage varnish cache
     * Called from Listener factory
     *
     * @param array $nodeList
     * @return array
     */
    public static function preBanUrl( $nodeList )
    {
        if ( empty($nodeList) )
            return array();

        $db              = eZDB::instance();
        $nodeList        = array_unique( $nodeList );
        $pendingNodeList = array();
        $clustersClear = array( 'cluster_france', 'cluster_mx', 'cluster_cn', 'cluster_us', 'cluster_au' );
        $query           = sprintf(
            "SELECT param_int FROM ezpending_actions 
             WHERE action = '%s' 
             AND param_int in ('%s') 
             LIMIT 1000",
            VarnishControl::PENDING_VARNISH_LABEL,
            implode(', ', $nodeList) 
        );

        foreach( $db->arrayQuery($query) as $row )
            $pendingNodeList[] = $row['param_int'];
        
        $remainingNodeList = array_diff( $nodeList, $pendingNodeList );

        if ( empty($remainingNodeList) )
            return array();
        
        foreach( $remainingNodeList as $nodeId )
        {
            $values = array();
            $timeStamp = time();
            /* @type $clusters array */
            $node = eZContentObjectTreeNode::fetch( $nodeId );

            if ( empty( $node ) )
            {
                continue;
            }
            elseif ( !$node->isMain() )
            {
                $node = $node->object()->mainNode();
            }

            if ( $node->classIdentifier() === 'article' )
            {
                $publisherPath = PublisherFolderTool::getPublisherFolderPathFromArticleNode($node);
            }
            elseif ( $node->classIdentifier() === 'publisher_folder' )
            {
                $publisherPath = PublisherFolderTool::getPublisherFolderPath( $node );
            }
            else
            {
                continue;
            }
            $clusters = PublisherFolderTool::getClustersFromPath($publisherPath);

            if(count($clusters) >5)
            {
                $clusters = $clustersClear;
            }
            foreach ( $clusters as $clusterIdentifier )
            {
                $row = sprintf( "('%s', %d, '%s', %d )", VarnishControl::PENDING_VARNISH_LABEL, $timeStamp, $clusterIdentifier, $nodeId );
                if( !in_array( $row, $values ) )
                {
                    $values[] = $row;
                }
            }

            if( !empty( $values ) )
            {
                $query = "INSERT INTO ezpending_actions (action, created, param, param_int) VALUES " . implode(', ', $values);
                $db->query( $query );
            }
        }

        return array();
    }