/** * @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 array $contentObjectList */ function checkObjectVisibility ($contentObjectList) { foreach ( array_keys($contentObjectList) as $index ) { $contentObjectId = $contentObjectList[$index]['contentobject_id']; echo "Checking visibility of object $contentObjectId\n"; $articleContentObject = eZContentObject::fetch($contentObjectId); if ( $articleContentObject && $articleContentObject->attribute('class_identifier') === "article" ) ObjectVisibilityManager::updateGlobalLimitation($articleContentObject); unset($articleContentObject); eZContentObject::clearCache(); } }
/** * Brightcove - update article visibility on media change * Called from Listener factory */ static function bcCheckArticlesRelatedToMedia() { $args = func_get_args(); if( empty($args[0]) || !isset( $args[0]['id'] ) ) return; $id = $args[0]['id']; $eZBrightcoveObject = eZBrightcoveObject::fetch( array( 'id' => $id ) ); if( !($eZBrightcoveObject instanceof eZBrightcoveObject) ) return; $mediaContentObjectId = $eZBrightcoveObject->attribute('contentobject_id'); if( empty( $mediaContentObjectId ) ) return; $mediaContentObject = eZContentObject::fetch( $mediaContentObjectId ); //Get related articles if( $mediaContentObject->reverseRelatedObjectCount( false, 0, array('AllRelations' => true ) ) == 0 ) return; $relatedArticleContentObjects = $mediaContentObject->reverseRelatedObjectList( false, 0, false, array('AllRelations' => true ) ); $relatedArticleContentObjects = array_merge($relatedArticleContentObjects, self::getRelatedCoreContentArticle($mediaContentObjectId)); foreach( $relatedArticleContentObjects as $relatedArticleContentObject ) { if( $relatedArticleContentObject instanceof eZContentObject ) ObjectVisibilityManager::updateGlobalLimitation($relatedArticleContentObject); } }
if ( $i%100 == 0 ) $cli->notice( "$i nodes have been treated." ); $i++; if ( !isset($result) || !isset($result['contentobject_id']) ) { $cli->warning("We somehow got an invalid MySQL entry"); continue; } $contentObjectId = $result['contentobject_id']; $contentObject = eZContentObject::fetch($contentObjectId); if ( $contentObject instanceof eZContentObject ) ObjectVisibilityManager::updateGlobalLimitation ( $contentObject ); else { $cli->warning("$contentObjectId is not a valid object."); continue; } unset($contentObject); eZContentObject::clearCache(); } $offset+= $limit; } $cli->notice( "Treatment completed successfully; $i nodes treated." );