Пример #1
0
                    // we need to get the parent article(s)
                    $expirationDuration = $dataMap['expiration_duration']->content();
                    $relatedArticles    = array();
                    $relatedObjects     = $node->object()->reverseRelatedObjectList(false, eZContentObjectTreeNode::classAttributeIDByIdentifier('download_ressource') );

                    if(!isset($articleId) && count($relatedObjects) > 1)
                    {
                        /* @var $Module eZModule */
                        header('HTTP/1.1 403 Forbidden');
                        echo "<h1>Forbidden access</h1>\n";
                        eZExecution::cleanExit();
                    }

                    if(isset($articleId))
                    {
                        $article = eZContentObjectTreenode::fetch($articleId);
                        if($article)
                        {
                            $dataMap = $article->dataMap();
                            if( isset($dataMap['online_date'])
                                && $dataMap['online_date']->hasContent() )
                            {
                                /* @type $onlineDateContent eZDate */
                                $onlineDateContent = $dataMap['online_date']->content();
                                $onlineDate        = $onlineDateContent->timestamp();
                                $dates             = SolrSafeOperatorHelper::getDatesPDFavailable($onlineDate,$expirationDuration);

                                if( $dates['daysLeft'] > 0 )
                                {
                                    $articleObject = $article->object();
                                    $relatedArticles[] = $articleObject;
    /**
     * @param eZContentObjectTreenode $node
     * @param array $row
     * @return array
     */
    protected static function nodeHasForbiddenWords( &$node, &$row )
    {
        /* @type $clustersToHide array */
        $clustersToHide = eZINI::instance( 'merck.ini' )->variable( 'PublishSettings', 'clustersToHide' );
        $returnArray    = array();
        
        foreach ($clustersToHide as $cluster)
        {
            /* @type $languageList array */
            $clusterIni = eZINI::fetchFromFile( "./extension/$cluster/settings/site.ini" );
            $languageList = $clusterIni->variable('RegionalSettings', 'SiteLanguageList');
        
            foreach( $languageList as $locale )
            {
                /* @type $nodeDatamap eZContentObjectAttribute[] */
                $nodeDatamap = $node->object()->fetchDataMap(false, $locale);

                if( !$nodeDatamap )
                    continue;

                if( $nodeDatamap['forbidden_article']->attribute('data_int') == 1 )
                {
                    // node is marked from publisher as containing some forbidden words = we hide
                    $returnArray[$cluster] = array(
                        'toHide'   => true,
                        'toDelete' => true,
                        'comment'  => 'marked by publisher',
                    );
                    break;
                }
                
                $forbiddenWordsArray = self::getForbiddenWordsArray($cluster);

                if(empty($forbiddenWordsArray))
                {
                    $returnArray[$cluster] = array(
                        'toHide'   => false,
                        'toDelete' => true,
                        'comment'  => 'no forbidden words on cluster',
                    );
                    continue;
                }

                $lgExplode      = explode('-', $locale);
                $languageFilter = $lgExplode[0] . '-*';

                $params = array(
                            'indent'   => 'on',
                            'qt'       => 'standard',
                            'q'        => '*:*',
                            'start'    => 0,
                            'stop'     => 0,
                            'fq'       => implode(' AND ', array(
                                'meta_node_id_si:'.$node->attribute('node_id'),
                                'meta_language_code_ms:'.$languageFilter,
                                'meta_installation_id_ms:'.eZSolr::installationID()
                    )),
                );

                $isInSolrResult = SolrTool::rawSearch($params, 'php', false);

                if( !$isInSolrResult['response']['numFound'] )
                {
                    // the node is not in solr. We postpone its check
                    if( $row['created'] < time() - 3600 * 4 )
                    {
                        // the node was added more than 4 hours ago. It should be in solr. We ask for a reindex
                        eZSearch::addObject( $node->object() );

                        $returnArray[$cluster] = array(    
                            'toHide'   => true,
                            'toDelete' => false,
                            'comment'  => 'not indexed in solr yet',
                        );
                        break;
                    }

                    if( $row['created'] < time() - 3600 * 48 )
                    {
                        eZLog::write( sprintf( "%s\t Node %s still not in solr after 48h", date('Y-m-d H:i:s'), $node->attribute('node_id') ), 'updatevisibility.log' );
                        $returnArray[$cluster] = array(
                            'toHide'   => true,
                            'toDelete' => true,
                            'comment'  => 'node is taking too long to be indexed',
                        );
                        break;
                    }
                }

                $params['q'] = implode(' ', $forbiddenWordsArray);
                $solrResults = SolrTool::rawSearch($params, 'php', false);

                if( !$solrResults['response']['numFound'] )
                {
                    // content has forbidden words => we hide
                    $returnArray[$cluster] = array(
                        'toHide'   => true,
                        'toDelete' => true,
                        'comment'  => 'has forbidden words',
                    );
                    break;
                }            
            }

            if ( !isset($returnArray[$cluster]) )
            {
                $returnArray[$cluster] = array(
                    'toHide'   => false,
                    'toDelete' => true,
                    'comment'  => 'default case'
                );
            }
        }
        
        return $returnArray;
    }