/** * Switches automatically between a node and solrdata * * @param eZContentObjectTreeNode|string[] $node * @return string */ static function getApplicationName($node) { if ( $node instanceof eZContentObjectTreeNode ) return NodeTool::getApplicationFromNode($node); elseif ( is_array($node) && isset($node['app_identifiers'][0]) ) return $node['app_identifiers'][0]; else return ''; }
/** * @param eZContentObjectTreeNode $node * @return string */ public static function getApplicationIdentifierFromNode ( $node ) { return NodeTool::getApplicationFromNode($node); }
/** * @param $courseId * @return array */ protected static function fetchNodeAndAppFromCourseId( $courseId ) { $nodeList = eZFunctionHandler::execute( 'content', 'tree', array( 'parent_node_id' => 2, 'attribute_filter' => array( array( 'article/publisher_internal_id', '=', $courseId ) ), 'class_filter_type' => 'include', 'class_filter_array' => array( 'article' ), 'main_node_only' => false, ) ); foreach ( $nodeList as $node ) { $application = NodeTool::getApplicationFromNode($node); if ( $application ) { $isCertificate = SolrSafeOperatorHelper::getCustomParameter( $application, 'HasCertificates', 'application' ); if ( $isCertificate ) { eZContentObject::clearCache(); return array( 'application' => $application, 'node' => $node, ); } } } eZContentObject::clearCache(); return false; }
$articleContentObject = $relatedArticles[0]; } else { if( $pdfContentObject->reverseRelatedObjectCount( false, false ) > 0 ) { $reverseRelatedObjectlist = $pdfContentObject->reverseRelatedObjectList( false, false ); $articleContentObject = $reverseRelatedObjectlist[0]; } } if( $articleContentObject instanceof eZContentObject ) { /* @type $articleNode eZContentObjectTreeNode */ $articleNode = $articleContentObject->mainNode(); $application = NodeTool::getApplicationFromNode($articleNode); $publisherFolderInfo = PublisherFolderTool::getPublisherFolderPathFromArticleNode($articleNode, true); $publisherFolderPath = $publisherFolderInfo['path']; $publisherFolderTranslation = PublisherFolderTool::getPublisherFolderTranslationFromPublisherFolder($publisherFolderInfo['pfid']); if( isset($publisherFolderTranslation['name']) ) { $publisherFolderTranslatioName = $publisherFolderTranslation['name']; } $articleObjecId = $articleContentObject->ID; } } //Insert into tracking table MMTrackingPdf::addTrack($clusterIdentifier, $userId, $application, $pdfId, $articleObjecId, $date, $publisherFolderPath, $publisherFolderTranslatioName); } }
/** * @param $node eZContentObjectTreeNode * @return bool */ public static function getFileApplicationCanRead(&$node) { $relatedObjects = $node->object()->reverseRelatedObjectList(false, eZContentObjectTreeNode::classAttributeIDByIdentifier('download_ressource') ); try { if(count($relatedObjects) == 0) throw new Exception('No article related to this object'); /** @var eZContentObject $articleObject */ /** @var eZContentObjectTreeNode $articleNode */ $articleObject = $relatedObjects[0]; $articleNode = $articleObject->mainNode(); $applicationIdentifier = NodeTool::getApplicationFromNode($articleNode); /** @var ApplicationDefault $application */ $application = ApplicationFactory::fetchByUri($applicationIdentifier); if(!$application->canRead()) { throw new Exception('Can\'t read'); } return true; } catch (Exception $e) { return false; } }
/** * @param int $courseId * @return array */ static protected function fetchNodeAndAppFromCourseId( $courseId ) { $nodeList = eZFunctionHandler::execute( 'content', 'tree', array( 'parent_node_id' => 2, 'attribute_filter' => array( array( 'article/publisher_internal_id', '=', $courseId ) ), 'class_filter_type' => 'include', 'class_filter_array' => array( 'article' ), 'main_node_only' => false, ) ); foreach( array_keys($nodeList) as $key ) { $node = $nodeList[$key]; $application = NodeTool::getApplicationFromNode ( $node ); if( $application ) { eZContentObject::clearCache(); return array( 'application' => $application, 'node' => $node, ); } unset($nodeList[$key]); eZContentObject::clearCache(); } eZContentObject::clearCache(); return false; }