Ejemplo n.º 1
0
    public function __construct()
    {
        // Guzzle RESTclient
        $wsUrl = SolrSafeOperatorHelper::clusterIni('WebService', 'BaseUrlUUMP', 'merck.ini') . SolrSafeOperatorHelper::clusterIni('WebService', 'Prefix', 'merck.ini');
        $this->client = new Client( $wsUrl );

        // Logger
        $filter           = new ezcLogFilter();
        $filter->severity = ezcLog::ERROR | ezcLog::INFO | ezcLog::WARNING;
        $this->logger     = ezcLog::getInstance();
        $this->logger->getMapper()->appendRule( new ezcLogFilterRule( $filter, new ezcLogUnixFileWriter( "var/log/", "esb_uump.log", 157286400, 3 ), true ) );
    }
Ejemplo n.º 2
0
    public function __construct()
    {
        // Guzzle RESTclient
        $this->builder = ServiceBuilder::factory(__DIR__ . '/../../classes/service/descriptor.php');


        $this->client = $this->builder['ldap'];

        // Logger
        $filter = new ezcLogFilter();
        $filter->severity = ezcLog::ERROR | ezcLog::INFO | ezcLog::WARNING;
        $this->logger = ezcLog::getInstance();
        $logFileName = "ws.log";
        if ( SolrSafeOperatorHelper::clusterIni('WebService', 'CountrySpecificLogs', 'merck.ini') == 'enabled' )
        {
            $clusterId = ClusterTool::clusterIdentifier();
            $logFileName = "ws_{$clusterId}.log";
        }
        $this->logger->getMapper()->appendRule(new ezcLogFilterRule( $filter, new ezcLogUnixFileWriter( "var/log/", $logFileName, 157286400, 3 ), true ) );
    }
Ejemplo n.º 3
0
    public function __construct( $params, $outputType, $blockName, $applicationName, $applicationObject, $applicationLocalized )
    {
        $this->redirectUrl = $applicationLocalized->getCustomParameter( 'ConfirmationPageURL' );

        if ( SolrSafeOperatorHelper::featureIsActive( 'ContactForm' ) )
        {
           $this->fromEmail =  SolrSafeOperatorHelper::feature( 'ContactForm', 'fromEmail');
           $this->toEmail = SolrSafeOperatorHelper::feature( 'ContactForm', 'toEmail');
        }
        if ( !$this->fromEmail )
        {
           $this->fromEmail = SolrSafeOperatorHelper::clusterIni( self::CONTACTUS_SETTING_BLOCK_NAME, 'FromEmail', 'merck.ini' );
        }
        if ( !$this->toEmail )
        {
           $this->toEmail = SolrSafeOperatorHelper::clusterIni( self::CONTACTUS_SETTING_BLOCK_NAME, 'ToEmail', 'merck.ini' );
        }

        $this->additionalMsg = SolrSafeOperatorHelper::clusterIni( self::CONTACTUS_SETTING_BLOCK_NAME, 'AdditionalEmailParameters', 'merck.ini' );

        parent::__construct( $params, $outputType, $blockName, $applicationName, $applicationObject, $applicationLocalized );
    }
    /**
     * @param array $parameters
     * @return array
     */
    protected function callEsbWrite( $parameters = null )
    {
        if ( is_null( $parameters ) )
        {
            /* @type $availableDateParams array */
            /* @type $availableParams array */
            $esbParams                  = array();
            $formatDate                 = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'FormatDate', 'merck.ini' );
            $availableDateParams        = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'AvailableDateParams', 'merck.ini' );
            $availableParams            = SolrSafeOperatorHelper::clusterIni('EsbSettings', 'AvailableParams', 'merck.ini' );
            $skipParametersIfEmptyValue = SolrSafeOperatorHelper::clusterIni('SkipParametersIfEmptyValue', 'SkipParameter', 'merck.ini' );

            foreach ( $availableParams as $esbParam )
            {
                if ( isset( $_POST[$esbParam] ) )
                {
                    if( $this instanceof ServiceUserUUMP && !empty( $availableDateParams ) && isset( $availableDateParams[$esbParam] ) && !empty($_POST[$esbParam]) )
                    {
                        $esbParams[$esbParam] = $this->convertDateforUUMP( $_POST[$esbParam], $formatDate );
                    }
                    else
                    {
                        if($esbParam != 'addressLine1' && $esbParam != 'addressLine2')
                        {
                            $esbParams[$esbParam] = strip_tags($_POST[$esbParam]);
                        }
                        else
                        {
                            $esbParams[$esbParam] = $_POST[$esbParam];
                        }
                    }

                    if( $this instanceof ServiceUserUUMP && !empty( $skipParametersIfEmptyValue ) && isset( $skipParametersIfEmptyValue[$esbParam] ) && empty( $_POST[$esbParam] ) )
                    {
                        unset( $esbParams[$esbParam] );
                    }
                }
            }
            $isHtmlEntitiesAlowed = self::isAddressEncodeAllowedOnCluster();

            $addressLine1 = $this->getBusinessNameMapping( 'addressLine1' );
            if ( isset( $esbParams[$addressLine1] ) && !empty( $esbParams[$addressLine1] ) && $isHtmlEntitiesAlowed )
            {
                $esbParams[$addressLine1] = htmlentities( $esbParams[$addressLine1], ENT_QUOTES, 'UTF-8' );
            }

            $addressLine2 = $this->getBusinessNameMapping( 'addressLine2' );
            if ( isset( $esbParams[$addressLine2] ) && !empty( $esbParams[$addressLine2] ) && $isHtmlEntitiesAlowed )
            {
                $esbParams[$addressLine2] = htmlentities( $esbParams[$addressLine2], ENT_QUOTES, 'UTF-8' );
            }

            if( SolrSafeOperatorHelper::featureIsActive( 'RegistrationSettings' ) )
            {
                if( isset( $_POST['emailAddress'] ) && ClusterTool::clusterIdentifier() == 'cluster_jp' )
                {
                    $usernameField = $this->getBusinessNameMapping( 'userName' );
                    $esbParams[$usernameField] = $_POST['emailAddress'];
                }
            }

            if ( in_array(self::SUBSCRIPTION_PHONE_CONSENT, $availableParams) )
            {
                $phoneConsent = array(
                    'consentCode' => self::SUBSCRIPTION_PHONE_CONSENT,
                    'consentStatus' => !empty( $esbParams[self::SUBSCRIPTION_PHONE_CONSENT] ) ? self::SUBSCRIPTION_STATUS_SUBSCRIBED : self::SUBSCRIPTION_STATUS_UNSUBSCRIBED,
                    'consentLastUpdate' => time(),
                );
                $parametersConsent = array(
                    'data' => array(
                        'profile' => array(
                            'userId'   => $this->getUserId(),
                            'countryOfRegistration' => $this->getCountryOfRegistration(),
                            'consents' => $phoneConsent,
                            'locale' => SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_locale' )
                        )
                    ),
                );
                $this->callWSHandler( $this->getEsbInterface( 'subsupdate' ), $parametersConsent );
                unset( $esbParams[self::SUBSCRIPTION_PHONE_CONSENT] );
            }
            $parameters = $this->getWriteParameters($esbParams);

            if( $this instanceof ServiceUserUUMP )
            {
                $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_locale' );
                if ( !is_null( $sl ) )
                {
                    $parameters['data']['profile']['locale'] = $sl;
                }
            }
        }

        $result = $this->callWSHandler( $this->getEsbInterface( 'write' ), $parameters );

        return $result;
    }
    public function contentResultMain( $force = false )
    {
        $filters            = array();
        $evrikaCity = isset($_GET['f0']) ? $_GET['f0'] : null;
        $evrikaSpecialty = isset($_GET['f1']) ? $_GET['f1'] : null;
        $solrFilter         = $this->solrFilter(false, filter_var($_GET['year'], FILTER_VALIDATE_INT), filter_var($_GET['month'], FILTER_VALIDATE_INT), filter_var($_GET['events'], FILTER_SANITIZE_STRING),filter_var($_GET['specialty'], FILTER_VALIDATE_FLOAT), $evrikaCity, $evrikaSpecialty);
        //$solrFacetsFiler    = $this->solrFacetsFilter();

        if( $solrFilter )
            $filters[] = $solrFilter;

        /*if( $solrFacetsFiler )
            $filters[] = $solrFacetsFiler;*/

        $headlineSortKey = SolrSafeOperatorHelper::clusterIni( 'ContentListApplicationSettings' , 'HeadlineSortKey', 'merck.ini' );
        $headlineSortKey = empty( $headlineSortKey ) ? 'attr_headline_lc_s' : $headlineSortKey;

        switch ( $this->sortBy )
        {
            // @TODO: get the clusterIdentifier based on SiteAccess settings
            case self::SORT_BEST_MATCH:
                if ( trim($this->searchQuery) != '' )
                    $sort = "score desc, {$headlineSortKey} asc";
                break;
            case self::SORT_MOST_POPULAR:
                header( 'x-ez-most-popular-node: '.$this->rootNodeIds[0] );
                $sort = 'attr_content_rating_'.ClusterTool::clusterIdentifier()."_f desc, {$headlineSortKey} asc";
                break;
            case self::SORT_MOST_VIEWED:
                header( 'x-ez-most-view-node: '.$this->rootNodeIds[0] );
                $sort = 'attr_view_counter_'.ClusterTool::clusterIdentifier()."_i desc, {$headlineSortKey} asc";
                break;
            case self::SORT_ALPHABETICAL:
                $sort = "{$headlineSortKey} asc";
                break;
            case self::SORT_MOST_RECENT:
                // default sort
            default:
                // no sort provided - we default to most recent
                $sort = "attr_date_dt desc, {$headlineSortKey} asc";
                break;
        }

        $fields = array(
            'attr_headline_t',
            'attr_'.ClusterTool::clusterIdentifier().'_url_s',
            'meta_guid_ms',
            'attr_date_dt',
            'attr_promo_description_t',
            'attr_date_start_dt',
            'attr_date_end_dt',
        );

        $searchQuery = $this->searchQuery !== '' ? strip_tags( $this->searchQuery ) : '*:*';

        $params = array(
            'indent'        => 'on',
            'q'             => $searchQuery,
            'fq'            => implode(' AND ' , $filters),
            'start'         => $this->offset,
            'rows'          => $this->limit,
            'fl'            => implode(',', $fields),
            'qt'            => '',
            'explainOther'  => '',
            'hl.fl'         => '',
            'sort'          => $sort,
        );

        if( trim($this->searchQuery) != '' )
            $params = array_merge( $params, $this->solrHighlightParams() );

        if ($this->isSolrJsonDebug() )
            $this->contentList->pushResult( 'params', $params, true);

        return SolrTool::rawSearch( $params );
    }
    /**
     * @param eZTemplate $tpl
     * @param string $operatorName
     * @param array $operatorParameters
     * @param string $rootNamespace
     * @param string $currentNamespace
     * @param mixed $operatorValue
     * @param array $namedParameters
     */
    function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
    {
        switch ($operatorName)
        {
            /*******************************************************************************/
            /*                             Solr Safe Operators                             */
            /*******************************************************************************/

            case 'ezfind_raw_fetch':
                $operatorValue = SolrSafeOperatorHelper::ezfindRawFetch(
                    $namedParameters['params'],
                    $namedParameters['nodeIdsOnly']
                );
                break;
            case 'getUrlSolr':
                $operatorValue = SolrSafeOperatorHelper::getUrlSolr($namedParameters['solrdata']);
                break;
            case 'getDatesPDFavailable':
                $operatorValue = SolrSafeOperatorHelper::getDatesPDFavailable(
                    $namedParameters['onlineDate'],
                    $namedParameters['daysAvailable']
                );
                break;
            case 'getViewCounter':
                $operatorValue = SolrSafeOperatorHelper::getViewCounter(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier']
                );
                break;
            case 'getRatings':
                $operatorValue = SolrSafeOperatorHelper::getRatings(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier']
                );
                break;
            case 'getJavascriptFiles':
                $operatorValue = SolrSafeOperatorHelper::getJavascriptFiles(
                    $namedParameters['application_name'],
                    $namedParameters['type'],
                    $namedParameters['isConsult']
                );
                break;
            case 'getLessFiles':
                $operatorValue = SolrSafeOperatorHelper::getLessFiles(
                    $namedParameters['application_name'],
                    $namedParameters['application'],
                    $namedParameters['isConsult']
                );
                break;
            case 'getInfosApp':
                $operatorValue = SolrSafeOperatorHelper::getInfosApp($namedParameters['application_identifier']);
                break;
            case 'getHostNameFromURL':
                $operatorValue = SolrSafeOperatorHelper::getHostNameFromURL($namedParameters['url']);
                break;
            case 'context':
                $operatorValue = SolrSafeOperatorHelper::context($namedParameters['url']);
                break;
            case 'getMetas':
                $operatorValue = SolrSafeOperatorHelper::getMetas($namedParameters['applicationName']);
                break;
            case 'getSolrData':
                $operatorValue = SolrSafeOperatorHelper::getSolrData(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier'],
                    $namedParameters['extended_fields']
                );
                break;
            case 'getCustomParameter':
                $operatorValue = SolrSafeOperatorHelper::getCustomParameter(
                    $namedParameters['application'],
                    $namedParameters['parameter_name'],
                    $namedParameters['context']
                );
                break;
            case 'getAppIdentifierForIcon':
                $operatorValue = SolrSafeOperatorHelper::getAppIdentifierForIcon($namedParameters['application']);
                break;
            case 'getApplicationUrl':
                $operatorValue = SolrSafeOperatorHelper::getApplicationUrl($namedParameters['identifier']);
                break;
            case 'mappingNameSpe':
                $operatorValue = SolrSafeOperatorHelper::mappingNameSpe($namedParameters['specialtie']);
                break;
            case 'getMappingSpe':
                $operatorValue = SolrSafeOperatorHelper::getMappingSpe();
                break;
            case 'getCustomerTypes':
                $operatorValue = SolrSafeOperatorHelper::getCustomerTypes();
                break;
            case 'getMainSpecialities':
                $operatorValue = SolrSafeOperatorHelper::getMainSpecialities();
                break;
            case 'getUserSpecialities':
                $operatorValue = SolrSafeOperatorHelper::getUserSpecialities();
                break;
            case 'noSeoLink':
                $operatorValue = SolrSafeOperatorHelper::noSeoLink($operatorValue);
                break;
            case 'getTaxoTranslation':
                $operatorValue = SolrSafeOperatorHelper::getTaxoTranslation(
                    $namedParameters['identifier'],
                    $namedParameters['remote_id']
                );
                break;
            case 'cluster_ini':
                $operatorValue = SolrSafeOperatorHelper::clusterIni(
                    $namedParameters['section'],
                    $namedParameters['variable'],
                    $namedParameters['ini_file']
                );
                break;
            case 'truncateContentRelated':
                $operatorValue = SolrSafeOperatorHelper::truncateContentRelated($namedParameters['text']);
                break;
            case 'myCertificatesEnabled':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive("MyCertificates");
                break;
            case 'appHasSpeciality':
                $operatorValue = SolrSafeOperatorHelper::appHasSpeciality();
                break;
            case 'setClusterIdentifier':
                // No $operatorValue modification is normal
                SolrSafeOperatorHelper::setClusterIdentifier($namedParameters['clusterIdentifier']);
                break;
            case 'featureIsActive':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive($namedParameters['featureCode']);
                break;
            case 'feature':
                $operatorValue = SolrSafeOperatorHelper::feature(
                    $namedParameters['featureCode'],
                    $namedParameters['value']
                );
                break;
            case 'alphabet':
                $operatorValue = SolrSafeOperatorHelper::alphabet();
                break;
            case 'generateIso6391':
                $operatorValue = SolrSafeOperatorHelper::generateIso6391($namedParameters['regionalSettingsLocale']);
                break;
            case 'staticfile':
                $operatorValue = SolrSafeOperatorHelper::staticFile(
                    $operatorValue,
                    $namedParameters['quote'],
                    $namedParameters['skip_slash']
                );
                break;
            case 'showHelpDeskPhoneInHeader':
                $operatorValue = !(SolrSafeOperatorHelper::feature('HelpDeskSettings', 'HidePhoneNumberInHeader'));
                break;
            case 'showHelpDeskPhoneOnPage':
                $operatorValue = !(SolrSafeOperatorHelper::feature('HelpDeskSettings', 'HidePhoneNumberOnPage'));
                break;
            case 'getFooterHTML':
                $operatorValue = SolrSafeOperatorHelper::getFooterHTML($namedParameters['footerBlockIdentifier']);
                break;
            case 'getLocaleBySystemCode':
                $operatorValue = SolrSafeOperatorHelper::getLocaleBySystemCode($namedParameters['systemCode']);
                break;
            case 'buildExitUrl':
                $operatorValue = SolrSafeOperatorHelper::buildExitUrl($namedParameters['url']);
                break;
            case 'getUserToken':
                $operatorValue = SolrSafeOperatorHelper::getUserToken();
                break;
            case 'clusterHasFeaturedChannel':
                $operatorValue = SolrSafeOperatorHelper::clusterHasFeaturedChannel();
                break;
            case 'aliasDimensions':
                $operatorValue = SolrSafeOperatorHelper::aliasDimensions($namedParameters['alias']);
                break;
            case 'hasImageArticleFromSolr':
                $operatorValue = SolrSafeOperatorHelper::hasImageArticleFromSolr(
                    $namedParameters['solrdata'],
                    $namedParameters['media_case']
                );
                break;
            case 'getImageArticleUrl':
                $operatorValue = SolrSafeOperatorHelper::getImageArticleUrl(
                    $namedParameters['media_case'],
                    $namedParameters['object_id'],
                    $namedParameters['language'],
                    $namedParameters['alias']
                );
                break;
            case 'getImageArticleUrlFromSolr':
                $operatorValue = SolrSafeOperatorHelper::getImageArticleUrl(
                    $namedParameters['media_case'],
                    $namedParameters['solrdata']['object_id'],
                    $namedParameters['solrdata']['language'],
                    $namedParameters['alias']
                );
                break;
            case 'isHidden':
                $operatorValue = SolrSafeOperatorHelper::isHidden($namedParameters['contentobject_id']);
                break;
            case 'isObjectGloballyVisible':
                $operatorValue = SolrSafeOperatorHelper::isObjectGloballyVisible($namedParameters['contentobject_id']);
                break;
            case 'getClusterVisibilities':
                $operatorValue = SolrSafeOperatorHelper::getClusterVisibilities($namedParameters['contentobject_id']);
                break;
            case 'parseTranslationTagParams':
                $operatorValue = SolrSafeOperatorHelper::parseTranslationTagParams($namedParameters['params']);
                break;
            case 'isSendToColleagueDisabled':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive('DisableSendToColleague')
                    ? SolrSafeOperatorHelper::feature('DisableSendToColleague', 'IsDisabled')
                    : false;
                break;
            case 'getListOfValueOptions':
                $operatorValue = SolrSafeOperatorHelper::getListOfValueOptions( $namedParameters['business_name'], $namedParameters['filter'] );
                break;
            case 'getListOfValues':
                $operatorValue = SolrSafeOperatorHelper::getListOfValues( $namedParameters['business_name'], $namedParameters['filter'] );
                break;
            case 'solrDateToStamp':
                $operatorValue = strtotime($namedParameters['date']) > 3600*24*2 ? SolrTool::getTimestampFromSolr($namedParameters['date']) : 0;
                break;
            case 'getSeoParam':
                $operatorValue = SolrSafeOperatorHelper::getSeoParam($namedParameters['applicationLocalized'], $namedParameters['name'], $namedParameters['params']);
                break;
            case 'applicationHasSeoSpeciality':
                $operatorValue = SolrSafeOperatorHelper::applicationHasSeoSpeciality($namedParameters['applicationIdentifier']);
                break;
            case 'seoIsEnabled':
                $operatorValue = SolrSafeOperatorHelper::seoIsEnabled($namedParameters['applicationIdentifier']);
                break;
            case 'includeEsi':
                $operatorValue = SolrSafeOperatorHelper::includeEsi( $namedParameters['src'], $namedParameters['debug'] );
                break;
            case 'imageDecHash':
                $operatorValue = SolrSafeOperatorHelper::imageDecHash( $operatorValue );
                break;
            case 'bannerDecHash':
                $operatorValue = SolrSafeOperatorHelper::bannerDecHash( $operatorValue );
                break;
            case 'getAndStoreGPNotebookHS':
                $operatorValue = self::getAndStoreGPNotebookHS( );
                break;
            case 'isPromoTaxonomyVisible':
                $operatorValue = SolrSafeOperatorHelper::isPromoTaxonomyVisible( $namedParameters['values'] );
                break;
            case 'translateTaxonomy':
                $operatorValue = SolrSafeOperatorHelper::translateTaxonomy( $namedParameters['code'] );
                break;
            case 'getPublisherArticleUrl':
                $operatorValue = SolrSafeOperatorHelper::getPublisherArticleUrl( $namedParameters['publisher'], $namedParameters['articleId'] );
                break;
        }
    }
Ejemplo n.º 7
0
                 'type'      => 'string',
                 'required'  => true,
                 'location'  => 'json'
             )
         ),
         'cr' => array(
             'location' => 'uri',
             'description' => 'Country of registration',
             'required' => true
         )
     )
 ),
 // EzP.Subs.F - Subs update
 'subsupdate' => array(
     'extends'   =>  'abstract',
     'uri'       =>  SolrSafeOperatorHelper::clusterIni('WebService', 'Prefix', 'merck.ini').'/Subs/Write?Country_of_Registration={cr}',
     'summary'   =>  'Update user subsc. in Lyris after saving consents infos',
     'parameters'=>  array(
         'Data'  =>  array(
             'type'      =>  'array',
             'required'  =>  'true',
             'location'  =>  'json',
             'items'     =>  array(
                 'Username'  =>  array(
                     'type'      =>  'string',
                     'required'  =>  true,
                     'location'  =>  'json'
                 ),
                 'Subs'  =>  array(
                     'type'      =>  'array',
                     'required'  =>  'true',
Ejemplo n.º 8
0
<?php

return array(
    'name' => 'Univadis',
    'apiVersion' => 0.3,
    'baseUrl' => (\SolrSafeOperatorHelper::featureIsActive('UUMP') ? \SolrSafeOperatorHelper::clusterIni('WebService', 'BaseUrlUUMP', 'merck.ini') . \SolrSafeOperatorHelper::clusterIni('WebService', 'Prefix', 'merck.ini') : \SolrSafeOperatorHelper::clusterIni('WebService', 'BaseUrl', 'merck.ini')),
    'description' => 'RESTful Webservice for ESB',
    'operations' => array(
        'abstract' => array(
            'httpMethod' => 'POST'
        ),
        'createtoken' => array(
            'extends' => 'abstract',
            'uri' => '/createtoken',
            'summary' => 'Creates token for given username',
            'parameters' => array(
                'data' => array(
                    'email' => 'string',
                    'countryOfRegistration' => 'string'
                )
            )
        )
    )
);
/**
 * up to date event recently created
*/
function updateDateEvent($_service, $_event, $_tampon) {
	try {
		//actual date
		$datetime = new DateTime('now');

		//end event date
		$end = new Google_EventDateTime();
		$end->setDateTime($datetime->format("Y-m-d\TH:i:s"));
		$end->setTimeZone('Europe/Paris');
		$_event->setEnd($end);				

		//event description (cronjob output)
		$_event->setDescription($_tampon);

		//update event
		$_service->events->update(SolrSafeOperatorHelper::clusterIni('ConfigCalendar', 'CalendarId', 'calendar.ini'), $_event->getId(), $_event);

		$cli = eZCLI::instance();
		$cli->output('Event id : ' . $_event->getId() . ' updated');	
	} catch(Exception $e) {
		$cli = eZCLI::instance();
		$cli->output($e->getMessage());
	}
}
    /**
     * @param bool $force
     * @return array
     */
    public function contentResultMain( $force = false )
    {
        $filters            = array();
        $solrFilter         = $this->solrFilter();
        $solrFacetsFiler    = $this->solrFacetsFilter();

        if( $solrFilter )
            $filters[] = $solrFilter;

        if( $solrFacetsFiler )
            $filters[] = $solrFacetsFiler;

        $headlineSortKey = SolrSafeOperatorHelper::clusterIni( 'ContentListApplicationSettings' , 'HeadlineSortKey', 'merck.ini' );
        $headlineSortKey = empty( $headlineSortKey ) ? 'attr_headline_lc_s' : $headlineSortKey;
        $sort            = '';
        // TODO: check if this check is needed:
        $rootNodeIds = $this->rootNodeIds;
        if ( isset( $this->rootNodeIds[0] ) && is_array( $this->rootNodeIds[0] ) ) {
            $rootNodeIds = $this->rootNodeIds[0];
        }

        switch ( $this->sortBy )
        {
            case self::SORT_BEST_MATCH:
                if ( trim($this->searchQuery) != '' )
                    $sort = "score desc, {$headlineSortKey} asc";
                break;
            case self::SORT_MOST_POPULAR:
                header( 'x-ez-most-popular-node: ' . 'P' . implode('PP', $rootNodeIds) . 'P' );
                $sort = 'attr_content_rating_'.ClusterTool::clusterIdentifier()."_f desc, {$headlineSortKey} asc";
                break;
            case self::SORT_MOST_VIEWED:
                header( 'x-ez-most-view-node: ' . 'P' . implode('PP', $rootNodeIds) . 'P' );
                $sort = 'attr_view_counter_'.ClusterTool::clusterIdentifier()."_i desc, {$headlineSortKey} asc";
                break;
            case self::SORT_ALPHABETICAL:
                $sort = "{$headlineSortKey} asc";
                break;
            case self::SORT_MOST_RECENT:
                // default sort
            default:
                // no sort provided - we default to most recent
                $sort = "attr_date_dt desc, {$headlineSortKey} asc";
                break;
        }

        $fields = array_values($this->getFields());

        $searchQuery = isset( $_REQUEST['q'] ) ? strip_tags( $_REQUEST['q'] ) : '*:*';

        $params = array(
            'indent'        => 'on',
            'q'             => $searchQuery,
            'fq'            => implode(' AND ' , $filters),
            'start'         => $this->offset,
            'rows'          => $this->limit,
            'fl'            => implode(',', $fields),
            'qt'            => '',
            'explainOther'  => '',
            'hl.fl'         => '',
            'sort'          => $sort,
        );

        if( trim($this->searchQuery) != '' )
            $params = array_merge( $params, $this->solrHighlightParams() );

        if ( $this->withFacets )
            $params = array_merge( $params, $this->unfilteredFacetsParams() );

        if ($this->isSolrJsonDebug() )
            $this->contentList->pushResult( 'params', $params, true);

        return SolrTool::rawSearch( $params, 'php', true, false );
    }
    /**
     * @param string $kw
     * @return array
     */
    public function keywordsAutocomplete( $kw = null )
    {
        eZDebug::accumulatorStart( __CLASS__.'::'.__FUNCTION__, 'Merck' );
        
        $solrTextAttributesSuffix = SolrSafeOperatorHelper::clusterIni( 'SolrSettings', 'TextAttributesSuffix', 'merck.ini' );

        // taken from eZFindServerCallFunctions
        $result = array();
        if( is_null($kw) )
            $kw = isset($_GET['term']) ? $_GET['term'] : '';

        $findINI = eZINI::instance( 'ezfind.ini' );
        $limit   = $findINI->variable( 'AutoCompleteSettings', 'Limit');

        if ( $this->contentList->iniMerck()->hasVariable( 'ContentListApplicationSettings', 'KeywordsAutoCompleteLimit' ) )
            $limit = $this->contentList->iniMerck()->variable( 'ContentListApplicationSettings', 'KeywordsAutoCompleteLimit' );

        $minLength = 3;
        if ( $this->contentList->iniMerck()->hasVariable( 'ContentListApplicationSettings', 'KeywordsAutoCompleteMinLength' ) )
            $minLength = SolrSafeOperatorHelper::clusterIni('ContentListApplicationSettings', 'KeywordsAutoCompleteMinLength', 'merck.ini');

        $input = mb_strtolower( $kw, 'UTF-8' );

        if ( mb_strlen( $input, 'UTF-8') < $minLength )
        {
            return array();
        }

        $this->parseRequestParams();

        $solrFilter      = $this->solrFilter();
        $solrFacetsFiler = $this->solrFacetsFilter();

        // we autocomple on portal language only
        $filters = array(
            'meta_language_code_ms:'.substr( eZINI::instance()->variable( 'RegionalSettings', 'Locale'), 0, 3).'*'
        );

        if( $solrFilter )
            $filters[] = $solrFilter;
        if( $solrFacetsFiler )
            $filters[] = $solrFacetsFiler;

        // step 1 - get autocomplete terms from solr
        $params = array( 'q'                => '*:*',
                         'qf'               => 'k_spellcheck'.$solrTextAttributesSuffix,
                         'rows'             => 0,
                         'fq'               => implode( ' AND ', array_merge( $filters, array( '-k_spellcheck'.$solrTextAttributesSuffix.':"'.$input.'"' ) ) ),
                         'json.nl'          => 'arrarr',
                         'facet'            => 'true',
                         'facet.method'     => 'enum',
                         'facet.field'      => 'k_spellcheck'.$solrTextAttributesSuffix,
                         'facet.limit'      => $limit,
                         'facet.mincount'    => 1,
                         'facet.prefix'     => $input
        );
        $solrResults = SolrTool::rawSearch( $params );
        $sourceTerms = $solrResults['facet_counts']['facet_fields']['k_spellcheck'.$solrTextAttributesSuffix];

        // step 2 - get snomed terms from autocompletion terms
        $queries        = array();
        $searchTerms    = array_keys($sourceTerms);
        $searchTerms[]  = $input; // we add the input too as the previous request will return an emtpy set if it is a complete word
        $terms          = MMGlobalSearchDictionaryTerm::fetchSolrAutocompleteTerms( $searchTerms, null, $limit * 5 );

        // step 3 - we confront the terms to the current context
        $solrHighlightParams = $this->solrHighlightParams();
        foreach( $terms as $term )
        {
            if( mb_strtolower( $term, 'utf-8' ) == $input )
                continue;

            $query = array();
            foreach( explode( ' ', $solrHighlightParams['hl.fl'] ) as $field )
                $query[] = $field.':"'.addslashes( $term ).'"';

            $queries[] = implode( ' OR ', $query );
        }

        $params = array( 'q'                => '*:*',
                         'qf'               => 'k_spellcheck'.$solrTextAttributesSuffix,
                         'rows'             => 0,
                         'fq'               => implode( ' AND ', $filters ),
                         'json.nl'          => 'arrarr',
                         'facet'            => 'true',
                         'facet.query'      => $queries,
                         'facet.mincount'    => 0,
        );

        $solrResults = SolrTool::rawSearch( $params );
        $i           = 0;

        foreach( $solrResults['facet_counts']['facet_queries'] as $solrTerm => $solrTermCount )
        {
            if( $solrTermCount )
            {
                $term = $terms[$i];
                $result[] = array(  'label'    => $term,
                                    'count'    => $solrTermCount );
                if( count( $result ) >= $limit )
                    break;
            }
            $i++;
        }
        usort( $result, function($a, $b){ return $a['count'] < $b['count']; } );

        // step 4 - complete list with regular solr search if needed

        $termsIndex = null;
        while ( count( $result ) < $limit )
        {
            if( is_null($termsIndex) )
            {
                foreach( $result as $arr )
                    $termsIndex[mb_strtolower( trim($arr['label']), 'utf-8' )] = true;
            }

            $term = each( $sourceTerms );
            if(!$term)
                break;
            $key = mb_strtolower( $term['key'], 'utf-8' );

            if( !isset( $termsIndex[$key] ) )
            {
                $result[] = array( 'label' => $term['key'],
                                   'count' => $term['value'] );
                $termsIndex[$key] = true;
            }
        }

        eZDebug::accumulatorStop( __CLASS__.'::'.__FUNCTION__ );

        return $result;
    }
Ejemplo n.º 12
0
 /**
  * @return string
  */
 private static function getFormSecretSeed()
 {
     return SolrSafeOperatorHelper::clusterIni('FormXSRF', 'SecretSeed', 'merck.ini');
 }
    /**
     * Renders the block (returns HTML)
     *
     * @return string HTML
     **/
    public function render()
    {
        $tpl = eZTemplate::factory();

        $tpl->setVariable( 'articles', $this->getSolrArticles() );
        $tpl->setVariable( 'additional_classes', $this->additionalClasses() );
        $tpl->setVariable( 'app', $this->applicationObject );
        $tpl->setVariable( 'app_localized', $this->applicationLocalized );
        $tpl->setVariable( 'app_url_alias', $this->appUrlAlias() );
        $tpl->setVariable( 'cluster_identifier', ClusterTool::clusterIdentifier() );
        $tpl->setVariable( 'include_app_name', SolrSafeOperatorHelper::clusterIni( 'HomePageSettings', 'ShowApplicationInMoreLink', 'merck.ini' ) );
        $tpl->setVariable( 'nb_articles', $this->nbArticles );
        $tpl->setVariable( 'publisher_logo', $this->publisherLogo() );
        $tpl->setVariable( 'view_mode', $this->viewMode() );
        $tpl->setVariable( 'application_url', SolrSafeOperatorHelper::getApplicationUrl($this->applicationObject->attribute('identifier')) );
        $tpl->setVariable( 'with_feed', $this->_application->resultHandler->withFeed );

        $blockResult = $tpl->fetch( 'design:presenters/block/applist.tpl' );
        eZTemplate::resetInstance();

        return $blockResult;
    }
    /**
     * @param eZTemplate $tpl
     * @param string $operatorName
     * @param array $operatorParameters
     * @param string $rootNamespace
     * @param string $currentNamespace
     * @param mixed $operatorValue
     * @param array $namedParameters
     */
    function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
    {
        switch ($operatorName)
        {
            case 'timestampToDateISO':
                $operatorValue = date('c', $namedParameters['timestamp']);
                break;
            case 'ezstr_replace':
                $operatorValue = str_replace(
                    $namedParameters['search'],
                    $namedParameters['replace'],
                    $namedParameters['text']
                );
                break;
            case 'hash_set':
                $hash                          = $namedParameters['hash'];
                $hash[$namedParameters['key']] = $namedParameters['val'];
                $operatorValue                 = $hash;
                break;
            case 'currentApplication':
                $operatorValue = ApplicationDefault::instance();
                break;
            case 'getApplicationName':
                if ($namedParameters['application'] instanceof ApplicationDefault)
                {
                    $operatorValue = $namedParameters['application']->applicationName();
                }
                break;
            case 'getTableEmbeddedName':
                $pattern = '/<td class="MMTableCellHead" ?.*>(.*)<\/td>/';
                preg_match_all($pattern, $namedParameters['htmlCode'], $matches);

                $operatorValue = $matches[1][0];
                break;
            case 'external_app_cookie_key':
                $operatorValue = ExternalApplication::createExternalApplicationCookieKey(
                    $namedParameters['localized_application']
                );
                break;
            case 'getCurrentCluster':
                $operatorValue = ClusterTool::clusterIdentifier();
                break;
            case 'checkIfSiteMatchesType':
                $contexts = array(
                    ContextTool::APP_MOBILE_DESIGN,
                    ContextTool::FRONT_DESIGN,
                    ContextTool::MOBILE_DESIGN
                );

                $operatorValue = (in_array($namedParameters['site_type'], $contexts)) ? ContextTool::instance(
                )->siteIsTypeOf($namedParameters['site_type']) : false;
                break;
            case 'import_status_xml_mdd':
                $statusXmlMdd = array(
                    1 => 'COMPLETE_SUCCESS',
                    2 => 'SUCCESS_WITH_WARNINGS',
                    3 => 'BLOCKING_ERROR',
                    4 => 'CRITICAL_ERROR',
                    5 => 'FATAL_ERROR'
                );

                $operatorValue = (isset($statusXmlMdd[$namedParameters['status']]) ? $statusXmlMdd[$namedParameters['status']] : $namedParameters['status']);
                break;
            case 'import_status_mdd_ez':
                $statusMddEz = array(
                    '-1' => 'DO_NOT_TREAT',
                    0    => 'INITIAL',
                    1    => 'SYNCHRO',
                    2    => 'ARTICLE_REF',
                    4    => 'CRITICAL_ERROR',
                    8    => 'FATAL_ERROR'
                );

                $operatorValue = (isset($statusMddEz[$namedParameters['status']]) ? $statusMddEz[$namedParameters['status']] : $namedParameters['status']);
                break;
            case 'getUserCustomerType':
                $user          = MMUsers::getCurrentUserObject();
                $operatorValue = ($user) ? $user->attribute('customer_type') : 'User not logged in';
                break;
            case 'isUserDataMissing':
                $instance      = MMUserData::instance();
                $operatorValue = $instance->isUserDataMissing($namedParameters['name']);
                break;
            case 'isMobile':
                $operatorValue = ContextTool::instance()->isMobile();
                break;
            case 'getExternalConfiguration':
                $operatorValue = ApplicationExternalConfiguration::getExternalConfiguration($namedParameters['id']);
                break;
            case 'getLocalizedApplicationByIdentifier':
                $operatorValue = CacheApplicationTool::buildLocalizedApplicationByIdentifier(
                    $namedParameters['identifier']
                );
                break;
            case 'getWebtrendsTimezone':
                $d = new DateTime('now', new DateTimeZone(eZINI::instance()->variable('TimeZoneSettings', 'TimeZone')));

                $operatorValue = ($d->getOffset() / 3600);
                break;
            case 'getChinaProvinceCity':
                $operatorValue = ChinaLocation::fetchProvincesAndCities();
                break;
            case 'isCatchUpAppNameEnabled':
                $operatorValue = MMGlobalSearch::isCatchUpAppNameEnabled();
                break;
            case 'gmdate':
                $operatorValue = gmdate($namedParameters['format'], $namedParameters['duration']);
                break;
            case 'mb_strtoupper':
                $operatorValue = mb_strtoupper($namedParameters['str']);
                break;
            case 'preg_replace':
                $operatorValue = preg_replace(
                    $namedParameters['pattern'],
                    $namedParameters['replacement'],
                    $namedParameters['subject'],
                    $namedParameters['$limit']
                );
                break;
            case 'html_entity_decode':
                $operatorValue = html_entity_decode($namedParameters['string']);
                break;
            case 'urlencode':
                $operatorValue = urlencode($namedParameters['string']);
                break;
            case 'json_encode':
                $operatorValue = json_encode($namedParameters['value']);
                break;
            case 'domain':
                $operatorValue = ContextTool::instance()->domain();
                break;
            case 'getUumpDateFormat':
                $operatorValue = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'FormatDate', 'merck.ini' );
                break;
            case 'html_contains_image':
                $operatorValue = SolrSafeOperatorHelper::htmlContainsImage($namedParameters['string']);
                break;
            case 'preg_match':
                $operatorValue = preg_match (
                    $namedParameters['pattern'],
                    $namedParameters['subject']
                );
                break;
        }
    }
Ejemplo n.º 15
0
 /**
  * @return bool
  */
 public static function canStore()
 {
     return (\SolrSafeOperatorHelper::clusterIni('TicketLogin', 'Log', 'merck.ini') == 'enabled');
 }
    /**
     * @param $publisherFolder PublisherFolder
     * @return string
     */
    public function publisherFolderFilter ( $publisherFolder )
    {
        $languageFilters = array();
        $path = $publisherFolder->attribute('path');

        if ( is_array($publisherFolder->attribute('languages')) )
            $languages = $publisherFolder->attribute('languages');
        else
            $languages = LocaleTool::languageList();

        if ( $publisherFolder->attribute('fallback') )
            $languageFilters = SolrTool::solrLanguageFilter( $languages );
        else
            $languageFilters[] = "meta_language_code_ms:{$languages[0]}";
        
        $publisherFilter = '( subattr_publisher_folder___source_id____s:"'.$path.'"'
                          .' AND ( ' . implode(' OR ', $languageFilters) . ' ) )';
        
        //#48332 - get content for quiz_train_your_brain from 13th August 2015 
        $dateRestrictions = SolrSafeOperatorHelper::clusterIni('MedicalQuizDateRestriction','PublisherFolderDateRestriction','merck.ini');
        if(!empty($dateRestrictions) && array_key_exists($path, $dateRestrictions)){
            if($dateRestrictions[$path]){
                $publisherFilter = '( subattr_publisher_folder___source_id____s:"'.$path.'"'
                          .' AND (attr_online_date_dt:["'.$dateRestrictions[$path].'" TO NOW])'
                          .' AND ( ' . implode(' OR ', $languageFilters) . ' ) )';
            }
        }
        return $publisherFilter;
    }
Ejemplo n.º 17
0
    /**
     * Logs the user in eZPublish taking the data from the ESB
     * /!\ Does not check login / password. This check needs to be done before!!!!!
     *
     * @param string $uuid
     * @param ESBResult $esbResult
     * @param boolean $rememberMe
     * @param boolean $context
     * @return array destUrl or null if error
     */
    public static function esbLogin( $uuid, $esbResult, $rememberMe = false, $context = false )
    {
        $localizedLoginApplication = CacheApplicationTool::buildLocalizedApplicationByIdentifier( 'login' );

        $validationStatus = $esbResult->getValidationStatus();
        if ( $validationStatus == 'PV' && $localizedLoginApplication->getCustomParameter( 'RestrictPendingUsers' ) == 1 )
        {
            UserLog::instance()->esb_status('Pending')->store();
            
            $redirectURL = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'PendingUserStaticPage' );
            if( SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) )
            {
                $redirectURL = $redirectURL . '#?vs=PV';
            }
            header( "Location: $redirectURL" );
            eZExecution::cleanExit();
        }
        else if ( $validationStatus == 'RP' && $localizedLoginApplication->getCustomParameter( 'RestrictRejectedUsers' ) == 1 )
        {
            UserLog::instance()->esb_status('Rejected')->store();
            
            $redirectURL = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'RejectedUserStaticPage' );
            if( SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) )
            {
                $redirectURL = $redirectURL . '#?vs=RP';
            }
            header( "Location: $redirectURL" );
            eZExecution::cleanExit();
        }

        if( is_null($esbResult->countryOfRegistration))
            $esbResult->countryOfRegistration = eZINI::instance()->variable( 'RegionalSettings', 'CountryOfRegistration' );

        if( is_null($esbResult->userSpecialty) )
        {
            self::logError( $uuid, null, $esbResult->toTicket(), 'Missing main specialty' );
            return null;
        }

        if( is_null( $esbResult->customerType ) )
        {
            self::logError( $uuid, null, $esbResult->toTicket(), 'Missing Customer type' );
            return null;
        }

        // temporary fix to parse forced string prepended with A
        $userSpeciality = $esbResult->userSpecialty = preg_replace( '#^A#', '', $esbResult->userSpecialty );
        $customerType = $esbResult->customerType = preg_replace( '#^A#', '', $esbResult->customerType );

        if( !preg_match('#^216\.#', $userSpeciality) )
        {
            self::logError( $uuid, null, $esbResult->toTicket(), "Invalid User specialty: $userSpeciality" );
            return null;
        }
        if( !preg_match( '#^102\.#', $customerType ) )
        {
            self::logError( $uuid, null, $esbResult->toTicket(), "Invalid Customer type: $customerType" );
            return null;
        }

        $esbResult->userName = $uuid;
        $esbResult->rememberMe = $rememberMe;
        $decodedContext = urldecode(urldecode($context));

        // If we need to check the Terms of Use for the cluster, we need to skip my-newsletters app for legal reasons (1-click unsubscribe).
        $toUToCheck = (    eZINI::instance( 'merck.ini')->hasVariable( 'LoginSettings', 'ToUCheck')
            && eZINI::instance( 'merck.ini' )->variable( 'LoginSettings', 'ToUCheck') == 'enabled'
            && !strpos($decodedContext, 'my-newsletters')
        );

        if( $toUToCheck ){
            $toUValidated = ( $esbResult->termsOfUse );
            $toUValidated &= ( $esbResult->privacyPolicy );

            if( $esbResult->forceToUValidated )
                $toUValidated = true;

            $esbResult->toUValidated = (bool)$toUValidated;
        }

        // Check if we need to check the autologin status for the cluster
        if( SolrSafeOperatorHelper::featureIsActive('RestrictAutologgedInUsers') && SolrSafeOperatorHelper::feature('RestrictAutologgedInUsers', 'Restricted')
            && in_array( $esbResult->autologin, array( 1, "yes" ) ))
        {
            $esbResult->autologin = true;
        }
        else
        {
            $esbResult->autologin = false;
        }

        if ( self::loginUser( $esbResult->toTicket() ) )
        {
            $user = MMUsers::getCurrentUserObject();

            $destUrl = ContextTool::instance()->contextUrl( $context );

            if( $toUToCheck && !$user->toUValidated() )
            {
                if( preg_match('#^(?:https?://[^/]+)'.eZINI::instance()->variable('SiteSettings', 'ToUAgreementPage').'?#', $destUrl) )
                    $destUrl = '/';
                $destUrl = preg_replace('#^https?://([^?]+)//#', '\1', $destUrl);
                $destUrl = eZINI::instance()->variable('SiteSettings', 'ToUAgreementPage')
                    .'?context='.urlencode($destUrl);
            }

            // Store user action in mm_front_user_action table
            $mmFrontUserAction = MMFrontUserAction::fetchByUsername( $esbResult->userName );
            if ( $mmFrontUserAction instanceof MMFrontUserAction )
            {
                $mmFrontUserAction->LastVisitDate = date( 'Y-m-d H:i:s' );
                $mmFrontUserAction->Processed = MMFrontUserAction::PROCESSED;
                $mmFrontUserAction->store(array('processed', 'last_visit_date'));
            }
            else
            {
                $mmFrontUserAction = MMFrontUserAction::create( array(
                        'id' => null,
                        'username' => $esbResult->userName,
                        'country_registration' => $esbResult->countryOfRegistration,
                        'processed' => MMFrontUserAction::PROCESSED,
                        'last_visit_date' => date( 'Y-m-d H:i:s' ),
                ) );
                $mmFrontUserAction->store();
            }

            if ( $rememberMe )
            {
                $userKey = !is_null($esbResult->userId) ? $esbResult->userId : $uuid;
                $cookieExpiration = time() + eZINI::instance( 'merck.ini' )->variable( 'TIBCOCookieSettings', 'TIBCOCookieExpiration' );
               
                //fix to remove the old cookie for new sso cluster #39800
                $splitDepth = eZINI::instance('merck.ini')->variable( 'CookieSettings', 'CookieDomainSplitDepth' );
                $splitDepth= 0;
                if( $splitDepth == 0 ) {
                    $cookieDomain = preg_replace('#^(https?://)?([^.]+.){1}#', '', contextTool::instance()->domain() );
                    $cookieExpirationToDelete = time() - 2000;
                    setcookie( 'remember_me', '', self::encryptText(json_encode($userKey)), $cookieExpirationToDelete, '/', $cookieDomain );
                }//end fix
                setcookie( 'remember_me', self::encryptText(json_encode($userKey)), $cookieExpiration, '/', CookieTool::getCookieDomain() );
            }
            else
            {
                $cookieExpiration = 0;
            }

            // Set cookie
            $esbSessionId = $esbResult->sessionID;
            $countryCode = '';
            if ( !empty( $esbSessionId ) )
            {
                $cookieName   = eZINI::instance( 'merck.ini' )->variable( 'TIBCOCookieSettings', 'TIBCOCookieName' );
                $esbSessionId = str_replace( ' ', '+', '"'.urldecode($esbSessionId).'"' );
                setrawcookie( $cookieName, $esbSessionId, $cookieExpiration, '/', CookieTool::getCookieDomain() );
            }
            
            // set residenceCountry country code for google tag manager
            $countryOfResidence = $esbResult->othersParams['countryOfResidence'] ? $esbResult->othersParams['countryOfResidence'] : ($esbResult->othersParams['Country_of_residence'] ? $esbResult->othersParams['Country_of_residence'] : null );
            if($countryOfResidence)
            {
                if($countryOfResidence > 2)
                {
                    $countries = SolrSafeOperatorHelper::clusterIni('CountryCode','CountryCode','merck.ini');
                    $countryCode = $countries[$esbResult->othersParams['Country_of_residence']];
                }
            }
            else
            {
                $countryCode = $esbResult->countryOfRegistration;
            }
            
            $esbResult -> setResidenceCountry($countryCode);
              
            return array(
                'destUrl' => $destUrl,
                'params'  => $esbResult->toTicket(),
            );
        }

        return null;
    }
    /**
     * @return array
     */
    public static function alphabet()
    {
        $hexFirstLetter = SolrSafeOperatorHelper::clusterIni('Alphabet', 'FirstLetterUnicode', 'merck.ini');
        $hexLastLetter = SolrSafeOperatorHelper::clusterIni('Alphabet', 'LastLetterUnicode', 'merck.ini');

        $letters = array();
        foreach ( range(hexdec($hexFirstLetter), hexdec($hexLastLetter)) as $int )
            $letters[] = mb_convert_encoding("&#x" . dechex($int) . ";", "UTF-8", "HTML-ENTITIES");

        return $letters;
    }
Ejemplo n.º 19
0
    /**
     * Checks if an url is valid for redirection
     * Allows urls from the current domain only
     * Excludes login pages and logff pages and register page
     * @param string $url
     * @return bool
     */
    public function checkRedirectUrl( $url )
    {
        if( self::checkRedirectDomain($url) )
        {
            $ini                    = eZINI::instance();
            $loginPage              = preg_replace('#^https?//[^/]+#', '', $ini->variable('SiteSettings', 'LoginPage'));
            $promoLoginPage         = preg_replace('#^https?://[^/]+#', '', $ini->variable('SiteSettings', 'PromoLoginPage'));
            $logoffPage             = preg_replace('#^https?://[^/]+#', '', $ini->variable('SiteSettings', 'LogoffPage'));
            $logoffConfirmationPage = preg_replace('#^https?://[^/]+#', '', $ini->variable('SiteAccessSettings', 'AfterLogoutUrl'));
            $registerUrl            = preg_replace('#^https?://[^/]+#', '', SolrSafeOperatorHelper::clusterIni( 'LoginSettings', 'RegisterUrl', 'merck.ini' ));
            $rejectedUserStaticPage = preg_replace('#^https?://[^/]+#', '', $ini->variable('SiteSettings', 'RejectedUserStaticPage'));

            // we do not want to redirect to the login page either
            if( !preg_match('#^https?://[^/]+(?:'.$loginPage.'|'.$promoLoginPage.'(?:[/\?].*)?$|'.$logoffPage.'|'.$logoffConfirmationPage.'|'.$registerUrl.'|'.$rejectedUserStaticPage.')#', $url) )
            {
                return true;
            }
        }

        return false;
    }
    'cluster' => 'Cluster'
) );

$script->startup();
$script->initialize();

if(!isset($options['cluster']) || empty($options['cluster']) || is_null($options['cluster'])) {
    echo "\nError : Cluster must be set, consult help for more informations\n";
    $script->shutdown();
    exit;
}

if(isset($options['cluster']) && !empty($options['cluster'])) {
    generateCache(array($options['cluster']), $options);
} else {
    $clusters = array_keys( SolrSafeOperatorHelper::clusterIni('DomainMappingSettings', 'ClusterDomains', 'merck.ini') );
    generateCache($clusters, $options);
}

$script->shutdown();

/**
 * @param $clusters
 * @param $options
 * @return void
 */
function generateCache($clusters, $options) {
    $cli = eZCLI::instance();

    foreach ( $clusters as $clusterPath )
    {
    protected function response( $uri )
    {
        switch( self::redirectMode() )
        {
            case self::LOGIN_REDIRECT_MODE_HTTP:
                header( "Location: $uri" );
                break;
            case self::LOGIN_REDIRECT_MODE_JS:
                header( "Content-type: application/json");
                if ( SolrSafeOperatorHelper::featureIsActive( 'UUMP' ) )
                {
                    header( "Accept: application/json");
                }
                echo json_encode( $uri );
                break;
            case self::LOGIN_REDIRECT_MODE_JSON:
                header('Content-type: application/json');

                $result = array();

                $result['status']           = $this->_isLoginSuccessful ? 0 : 1;
                $result['LoginRedirect']    = $this->_isLoginSuccessful ? $this->_destUrl : $uri;

                $mmUser = MMUsers::getCurrentUserObject();

                if ( $this->_isLoginSuccessful )
                {
                    $result['User']                     = $this->_esbResult->toArray();
                    $result['User']['mmSettings']       = $mmUser->getMMSettings();
                    $result['User']['unorderedAppList'] = $mmUser->getApplicationList();
                    $result['User']['alterboxMsgReset'] = $mmUser->hasPreference('alterboxMsgReset') ? $mmUser->getPreferences('alterboxMsgReset') : true;
                    
                    $result['cookies'] = CookieTool::setCookies();

                    $salutations    = SolrSafeOperatorHelper::clusterIni('Salutations', 'Salutation', 'merck.ini' );
                    $localeMap      = SolrSafeOperatorHelper::clusterIni('ESBSettings', 'ESBLocaleMap', 'merck.ini' );
                    $locale         = $this->_esbResult->language;
                    if ( isset($localeMap[$locale]) )
                        $locale = $localeMap[$locale];

                    $result['commonauth']       = array(
                        'user_id'           => $this->_esbResult->userName,
                        'MSDID'             => ( isset( $this->_esbResult->othersParams['crmMemberId'] ) && !empty($this->_esbResult->othersParams['crmMemberId']) ) ? $this->_esbResult->othersParams['crmMemberId'] : $this->_esbResult->countryOfRegistration.'000000X',
                        'userId'            => $this->_esbResult->userId,
                        'UUMPID'            => $this->_esbResult->userId,
                        'UVDSPam'           => null,
                        'ValidationStatus'  => $this->_esbResult->getValidationStatus(),
                        'ODMNum'            => null,
                        'ValidationDate'    => ($this->_esbResult->registrationDate) ? date('d-M-y', strtotime($this->_esbResult->registrationDate)) : null,
                        'TVFCode'           => 'MSD',
                        'Email'             => $this->_esbResult->emailAddress,
                        'cc'                => $this->_esbResult->countryOfRegistration,
                        'PhoneNum'          => isset($this->_esbResult->othersParams['phoneNumber']) ? $this->_esbResult->othersParams['phoneNumber'] : null,
                        'ZipCode'           => $this->_esbResult->postalCode,
                        'zipCode'           => $this->_esbResult->postalCode,
                        'Salutation'        => isset($salutations[$this->_esbResult->othersParams['salutation']]) ? $salutations[$this->_esbResult->othersParams['salutation']] : null,
                        'City'              => $this->_esbResult->city,
                        'Street'            => isset($this->_esbResult->othersParams['addressLine2']) ? $this->_esbResult->othersParams['addressLine2'] : null,
                        'Address'           => isset($this->_esbResult->othersParams['addressLine1']) ? $this->_esbResult->othersParams['addressLine1'] : null,
                        'Country'           => $this->_esbResult->countryOfRegistration,
                        'CustomerType'      => $this->_esbResult->customerType,
                        'SiteCRMStatus'     => null,
                        'LastName'          => $this->_esbResult->lastName,
                        'FirstName'         => $this->_esbResult->firstName,
                        'specialty'         => $this->_esbResult->userSpecialty,
                        'lng'               => LocaleTool::languageISO639Code($locale).'_'.LocaleTool::countryISO3166Code($locale),
                        'hostName'          => preg_replace('#^https?://#', '', ContextTool::instance()->domain()),
                        'LicenseNumber'     => isset($this->_esbResult->othersParams['licenseNumber']) ? $this->_esbResult->othersParams['licenseNumber'] : null,
                    );

                }
                echo json_encode($result);
                break;
        }
        eZExecution::cleanExit();
    }