/**
  * @return string
  */
 protected static function refuseToU()
 {
     MMUserLogin::logoutUser();
     CookieTool::destroyCookie( 'remember_me' );
     $redirectURL = ContextTool::instance()->domain().'/logoutActions.php';
     return $redirectURL;
 }
    /**
     * @return eZINI
     */
    static public function iniMerck()
    {
        if(is_null(self::$_iniMerck))
        {
            self::$_iniMerck = eZINI::instance('merck.ini');
        }

        return self::$_iniMerck;
    }
 static private function sessionArray()
 {
     if( MMUserLogin::$isLogin ) 
     {
         eZSession::start();
         return $_SESSION;
     }
     
     if ( is_null(self::$_localSession) )
     {
         eZSession::start();
         self::$_localSession = $_SESSION;
         if ( !isset($_COOKIE['eZSESSID']) )
         {
             setcookie( 'eZSESSID', session_id(), null, '/', CookieTool::getCookieDomain() );
             $_COOKIE['eZSESSID'] = session_id();
         }
         eZSession::stop();
     }
     return self::$_localSession;
 }
    private function iframeBuildResult()
    {
        $url = $_COOKIE[$this->cookieKey()];

        CookieTool::destroyCookie($this->cookieKey(), '/', null);

        if($url == 1)
        {
            if ( $this->applicationObject()->externalLinkHandler() )
            {
                $url = $this->applicationObject()->externalLinkHandler()->getNodeUrl( $this->node );
                $url = $this->getDeeplink( $url );
            }
            else
            {
                $url = '/bad_config';
            }
        }
        if ($url == null && isset($_REQUEST['r']))
        {
            $url = urldecode($_REQUEST['r']);
        }

        $backUrl    = isset($_REQUEST['bu']) ? $_REQUEST['bu'] : eZINI::instance()->variable('SiteAccessSettings', 'BaseUrl');

        if ( $this->isDeeplinkApplication() )
        {
            $redirect = !$this->displayIframe();
        }
        else
        {
            $redirect = ( $this->mustRedirect() || ( isset($_REQUEST['r']) && $_REQUEST['r'] ) );
        }

        if ( !$this->isOnExitPageView() && !$this->displayIframe() )
        {
            $redirect = true;
        }

        // Trick used for pages that needed POST form submit, that coudn't be done by CURL.
        $usePostMethod = SolrSafeOperatorHelper::getCustomParameter( $this->applicationObject->identifier, 'usePostMethod', 'application' );
        if( $redirect && !$usePostMethod && (!$this->isOnExitPageView() || !$this->displayIframe()))
        {
            header('Location: '.$url);
            eZExecution::cleanExit();
        }

        $applicationList = AppBarControl::instance()->applicationIds();
        sort($applicationList);

        $displayIframe = true;
        if ( !$this->isOnExitPageView() )
        {
            $displayIframe = $this->displayIframe();
        }
        $url = in_array('arg', array_keys($this->_params['UserParameters'])) ? $url . $this->_params['UserParameters']['arg'] : $url;
        $this->pushResult('iframe'          , $displayIframe);
        $this->pushResult('url'             , $url);
        $this->pushResult('back_url'        , $backUrl);
        $this->pushResult('app_list_hash'   , md5( $this->user() ? json_encode($applicationList) : 'anonymous' ));
        $this->pushResult('add_to_my_apps'  , ( $this->user() && $this->applicationObject->getParent() != null && !in_array( $this->getApplicationId(), AppBarControl::instance()->applicationIds() ) && $this->getApplicationId() != 0));
        $this->pushResult('app'             , $this->applicationObject());
        $oldSkipPage = SolrSafeOperatorHelper::getCustomParameter($this->applicationObject->identifier, 'SkipExitPage', 'application');
        $skipPage = $oldSkipPage || !$this->exitStrategy();
        // hack to redirect external apps which doesn't have entry exits
        if( $this->isOnExitPageView() && $skipPage )
        {
            $this->pushResult('skip_exit_page_redirect', true);
        }
    }
    /**
     * @param int[] $applicationIds
     * @return int[]
     */
    public function store($applicationIds = null)
    {
        $oldApplicationIds = false;
        if($this->user())
        {
            $oldApplicationIds = $this->user()->getApplicationList();
        }

        if( is_array($applicationIds) )
        {
            $this->_applicationIds = $applicationIds;
        }

        if ( !$this->user() )
        {
            CookieTool::destroyCookie(self::COOKIE_UNORDERED_APPLIST_KEY);
            return null;
        }

        $applicationIds = $this->applicationIds();
        $this->user()->setApplicationList($applicationIds);
        $this->user()->setCookie();

        sort($applicationIds);

        CookieTool::setCookie( self::COOKIE_UNORDERED_APPLIST_KEY, $applicationIds );

        if($oldApplicationIds)
        {
            $diff = array_values(array_diff($oldApplicationIds, $this->_applicationIds));

            if(is_array($diff) && count($diff) > 1)
            {
                return $diff;
            }

            else if(count($diff) == 1)
            {
                $idDeleted  = $diff[0];
                $apps       = CountryApplicationLibrary::fetchAuthorizedApplicationIds();

                if( !in_array($idDeleted, $apps) )
                {
                    return false;
                }

                return $diff;
            }
        }
        return false;
    }
 public static function destroyCookie()
 {
     CookieTool::destroyCookie( self::COOKIE_KEY );
 }
Example #7
0
<?php

MMUserLogin::$isLogin = true;

if(    in_array( ClusterTool::clusterIdentifier(), array( 'cluster_be_fr', 'cluster_be_nl' ) )
    && isset( $_REQUEST['ll']) 
){
    $value = false;
    
    switch( $_REQUEST['ll'] )
    {
        case 'fr':
        case 'fre-BE':
            $value = 'fr_BE'; 
            break;
        case 'nl':
        case 'dut-BE':
            $value = 'nl_BE';
            break;
    }
    
    if( $value )
        setcookie( 'BE_Login', $value, 0, '/', CookieTool::getCookieDomain() );
    
}

$login = ESBFactory::getLoginService( 'login', $_REQUEST );
$login->login();

eZExecution::cleanExit();
    /**
     * @return array
     */
    public static function applicationList()
    {
        # Hotfix #23450 note-8
        if ( !isset($_COOKIE['remember_me']) )
        {
            $cookieExpiration = time() + eZINI::instance('merck.ini')->variable('TIBCOCookieSettings', 'TIBCOCookieExpiration');
            $uuid = MMUsers::getCurrentUserId();
            setcookie('remember_me', MMUserLogin::encryptText(json_encode($uuid)), $cookieExpiration, '/', CookieTool::getCookieDomain());
        }

        $out = array('applicationList' => array());
        $host = 'http://' . self::host();

        if ( isset($_POST['application']) )
        {
            $applicationIdList = array((int) $_POST['application']);
        }
        else
        {
            $applicationIdList = AppBarControl::instance()->applicationIds();
        }

        foreach ( $applicationIdList as $applicationId )
        {
            if ( !is_numeric($applicationId) )
            {
                continue;
            }
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($applicationId);
            $application = ($applicationLocalized) ? $applicationLocalized->applicationObject() : null;

            if ( $applicationLocalized )
            {
                $application = $applicationLocalized->applicationObject();
            }

            if ( isset($application) )
            {
                $applicationType = $application->applicationType();

                $icons = array(
                    'icon' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico.png',
                    ),
                    'icon_hd' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_hd.png',
                    ),
                    'icon_active' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_active.png',
                    ),
                    'icon_active_hd' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_active_hd.png'
                    ),
                );

                foreach($icons as $key => $iconData)
                {
                    $path = sprintf('apps/%s/%s', $application->attribute('identifier'), $iconData['file']);
                    $fullPath = StaticData::clusterFilePath(ClusterTool::clusterIdentifier(), $path);
                    if ($fullPath)
                    {
                        $icons[$key]['path'] = StaticData::externalUrl(ClusterTool::clusterIdentifier(), $path);
                        $icons[$key]['md5'] = md5_file($fullPath);
                    }
                }

                $path = '/' . $applicationLocalized->attribute('url');
                $url = $host . $path;
                if ( $application->isPureExternal() )
                {
                    $url = $applicationLocalized->attribute("external_url");
                }

                $outApplicationListArray = array(
                    'id'         => $applicationId,
                    'identifier' => $application->attribute('identifier'),
                    'name'       => $applicationLocalized->attribute('name'),
                    'headline'   => $applicationLocalized->attribute('headline'),
                    'type'       => $applicationType->attribute('internal_type'),
                    'url'        => $url,
                    'path'       => $path,
                    'javascript' => self::getJavascript($application->attribute('identifier'), 'application'));

                foreach($icons as $key => $icon)
                {
                    $outApplicationListArray[$key] = array(
                        '100' => array('path' => $icon['path'], $icon['md5']),
                    );
                }
                $out['applicationList'][] = $outApplicationListArray;
            }
        }
        return $out;
    }
    /**
     * Logs in the user if applied username and password is
     * valid. The userID is returned if successful, false if not.
     *
     * @param array $params
     * @return bool
     */
    public static function loginUser($params = null)
    {
        $uncryptedTicket = array();

        if($params)
        {
            $uncryptedTicket["uuid"]           = $params["Username"];
            $uncryptedTicket["customerType"]   = $params["Customer_type"];
            $uncryptedTicket["userSpeciality"] = $params["User_specialty"];
            $uncryptedTicket["state"]          = $params["Province"];
            $uncryptedTicket["country"]        = $params["Country_of_registration"];
            $uncryptedTicket['toUValidated']   = isset( $params['toUValidated'] ) ? $params['toUValidated'] : true;
            $uncryptedTicket['autologin']      = isset( $params['autologin'] ) ? $params['autologin'] : false;
        }
        else
        {
            $http = eZHTTPTool::instance();

            $hashedTicket = $http->getVariable( 't' );
            if ( empty( $hashedTicket ) )
            {
                return false;
            }

            $uncryptedTicket = self::uncryptTicket ( $hashedTicket );
        }
        
        if ( !self::validateTicket($uncryptedTicket) )
        {
            return false;
        }

        $mmUser = self::createOrUpdateMMUser($uncryptedTicket);
        if( isset($uncryptedTicket['toUValidated']) )
        {
            $mmUser->toUValidated( $uncryptedTicket['toUValidated'] );
        }
        if( isset($uncryptedTicket['autologin']) )
        {
            $mmUser->isAutologin( $uncryptedTicket['autologin'] );
        }
        MMUsers::setCurrentUserObject($mmUser);

        AppBarControl::instance()->store();
        MMSelections::setCookie();
        MMUsers::setCookieUserPreferences();

        $catchUpSpe = $mmUser->getPreference( 'catchUpSpe' );
        if ( !empty( $catchUpSpe ) )
        {
            setcookie ('catchUpSpe', '1', CookieTool::getDefaultCookieExpiration(), '/', CookieTool::getCookieDomain() );
        }
        return true;
    }
    /**
     * Creates a profile
     *
     * @return array
     */
    public function create()
    {
        if( SolrSafeOperatorHelper::featureIsActive( 'RegistrationSettings' ) && SolrSafeOperatorHelper::feature( 'RegistrationSettings', 'DisableRegistration' ) == true ) {
            return array( 'data' => array( 'errorCode'=> 9 ) ); 
        }

        // 1st step - Checks fields
        $r = $this->checkUsername();
        if ( $r !== true )
        {
            return $r;
        }

        $r = $this->checkEmail();
        if ( $r !== true )
        {
            return $r;
        }
        $isHtmlEntitiesAlowed = self::isAddressEncodeAllowedOnCluster();

        // 2nd step - Process fields
        $addressLine1 = $this->getBusinessNameMapping( 'addressLine1' );
        if ( isset( $_POST[$addressLine1] ) && !empty( $_POST[$addressLine1] ) && $isHtmlEntitiesAlowed )
        {
            $_POST[$addressLine1] = htmlentities( $_POST[$addressLine1], ENT_QUOTES, 'UTF-8' );
        }

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

        /* @type $createParams array */
        $params       = array();
        $createParams = SolrSafeOperatorHelper::clusterIni('EsbSettings', 'CreateParamsTypes', 'merck.ini' );
        foreach ( $createParams as $key => $value )
        {
            if ( isset( $_POST[$key] ) )
            {
                $params[$key] = ( trim( $value ) == 'int' ) ? intval( $_POST[$key] ) : $_POST[$key];
            }            
        }

        $actId = $this->getBusinessNameMapping( 'actId' );
        if ( isset( $_REQUEST[$actId] ) )
        {
            $params[$actId] = $_REQUEST[$actId];
        }

        if ( $this instanceof ServiceUserUUMP )
        {
            $params['privacyPolicyDate'] = date('Ymdhis');
        }

        // managing validation status cases
        // 1. Override taken from cluster settings.
        $defaultValidationStatus = SolrSafeOperatorHelper::clusterIni('DefaultValidationStatus', 'DefaultValidationStatus', 'merck.ini' );
        $defaultValidationStatus = !empty( $defaultValidationStatus ) && isset( $defaultValidationStatus ) ? $defaultValidationStatus : 'PV' ;
        if( $this instanceof ServiceUserUUMP && !empty( $defaultValidationStatus ) && isset( $defaultValidationStatus ) )
        {
            $params['validationStatus'] = $defaultValidationStatus;
        }

        // 2. Russian helpdesk-register validates user by default.
        if( isset( $_POST['register-helpdesk']) && $_POST['register-helpdesk'] == 1 && !isset( $_POST['termsOfUse'] ))
        {
            $params['validationStatus'] = 'VP';

            $params['termsOfUse'] = isset( $_POST['helpdeskTermsOfUse']) ? 1 : 0;
            $params['privacyPolicy'] = isset( $_POST['helpdeskPrivacyPolicy']) ? 1 : 0;
        }

        // 3. German "kontakt" validation result.
        if ( $this instanceof ServiceUserUUMP && isset( $params['WEB_SERVICE_AJAX_FIELD_1'] ) )
        {
            if( $params['WEB_SERVICE_AJAX_FIELD_1'] == "kontakt" )
            {
                $params['validationStatus'] = 'PV';
            }
            unset( $params['WEB_SERVICE_AJAX_FIELD_1'] );            
        }

        // 4. German "DocCheck" validation result.
        if ( $this instanceof ServiceUserUUMP && ( isset( $params['DocCheck_username'] ) && $params['DocCheck_username'] != "" ) && ( isset( $params['Password_doccheck'] ) && $params['Password_doccheck'] != "" ) )
        {
            $params['validationStatus'] = 'VP';
            unset( $params['DocCheck_username'] );
            unset( $params['Password_doccheck'] );
        }

        // 5. US 1.8 if user is validated by eshcp we have crmMemberId field stored, so we also must validate user with VP
        if ( SolrSafeOperatorHelper::featureIsActive( "Univadis18Redesign" ) && isset($params['crmMemberId']) && $params['crmMemberId'] != "" )
        {
            $params['validationStatus'] = 'VP';
        }

        // 3rd step - ESB Create
        $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_language' );
        if( !is_null( $sl ) )
        {
            $language = $sl;
        }
        else
        {
            $language = eZINI::instance( 'site.ini' )->variable( 'RegionalSettings', 'ContentObjectLocale' );
            $merckIni = eZINI::instance( 'merck.ini' );
            if ( $merckIni->hasVariable( 'EsbSettings', 'Language' ) )
            {
                $language = $merckIni->variable( 'EsbSettings', 'Language' );
            }
        }

        $apps = array();
        $appsIds = CountryAppsBar::fetchAppsBarApplicationIds( $_POST[$this->getBusinessNameMapping( 'customerType' )] );
        foreach ( $appsIds as $key => $value )
        {
            $apps[] = array(
                $this->getBusinessNameMapping( 'appId' )    => $value,
                $this->getBusinessNameMapping( 'appOrder' ) => $key + 1
            );
        }

        $subsUni = $this->getUnivadisSubscriptions();
        $subsMsd = $this->getMsdSubscriptions();
        $subsSun = $this->getSunshineAct();

        $consents = array_merge( $subsUni, $subsMsd );
        if(!empty($subsSun))
        {
            $consents = array_merge( $consents, $subsSun );
        }

        if( $createParams[self::SUBSCRIPTION_PHONE_CONSENT] )
        {
            $consents[] = array(
                'consentCode'       => self::SUBSCRIPTION_PHONE_CONSENT,
                'consentStatus'     => !empty( $_POST[self::SUBSCRIPTION_PHONE_CONSENT] ) ? self::SUBSCRIPTION_STATUS_SUBSCRIBED : self::SUBSCRIPTION_STATUS_UNSUBSCRIBED,
                'consentLastUpdate' => time(),
            );
            unset( $params[self::SUBSCRIPTION_PHONE_CONSENT] );
        }

        // Add terms of use, private policies and OptIn consents
        if ( SolrSafeOperatorHelper::featureIsActive( 'ToUPPPopin' ) && ( $this instanceof ServiceUserUUMP ) )
        {
            $touVersion = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentToUConsentVersion' );
            $ppVersion  = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentPPConsentVersion' );

            $consents[] = array(
                'consentCode'       => 'termsOfUse_v' . $touVersion,
                'consentStatus'     => 'S',
                'consentLastUpdate' => time(),
            );

            $consents[] = array(
                'consentCode'       => 'privacyPolicy_v' . $ppVersion,
                'consentStatus'     => 'S',
                'consentLastUpdate' => time()
            );

            $subsOptIn = $this->getOptInSubscriptions();
            if ( !empty( $subsOptIn ) )
            {
                $consents = array_merge( $consents, $subsOptIn );
            }
        }

        $username = $this->getUsername();

        $userSpecialty = $_POST[$this->getBusinessNameMapping( 'userSpecialty' )];
        $mainSpecialty = UserSpecialityContentSpeciality::getContentSpeciality( $userSpecialty );


        $unifiedParameters = array(
            $this->getBusinessNameMapping( 'emailAddress' )          => $_POST[$this->getBusinessNameMapping( 'emailAddress' )],
            $this->getBusinessNameMapping( 'password' )              => $_POST[$this->getBusinessNameMapping( 'password' )],
            $this->getBusinessNameMapping( 'firstName' )             => $_POST[$this->getBusinessNameMapping( 'firstName' )],
            $this->getBusinessNameMapping( 'lastName' )              => $_POST[$this->getBusinessNameMapping( 'lastName' )],
            $this->getBusinessNameMapping( 'language' )              => $language,
            $this->getBusinessNameMapping( 'userSpecialty' )         => $userSpecialty,
            $this->getBusinessNameMapping( 'customerType' )          => $_POST[$this->getBusinessNameMapping( 'customerType' )],
            $this->getBusinessNameMapping( 'apps' )                  => $apps,
            $this->getBusinessNameMapping( 'consents' )              => $consents,
            $this->getBusinessNameMapping( 'additionalSpecialties' ) => MMUserLogin::getAddSpecialties( $mainSpecialty ),
            $this->getBusinessNameMapping( 'countryOfRegistration' ) => $this->getCountryOfRegistration(),
            $this->getBusinessNameMapping( 'countryOfResidence' )    => $_POST[$this->getBusinessNameMapping( 'countryOfResidence' )],
        );

        if ( isset( $_POST[$this->getBusinessNameMapping( 'secondName' )] ) )
        {
            $unifiedParameters[$this->getBusinessNameMapping( 'secondName' )] = $_POST[$this->getBusinessNameMapping( 'secondName' )];
        }

        if ( !is_null($username))
            $unifiedParameters[$this->getBusinessNameMapping( 'userName' )] = $username;

        if ( $this instanceof ServiceUserUUMP )
        {

            $parameters = array(
                'data' => array(
                    'profile' => $unifiedParameters
                )
            );

            $formatDate                 = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'FormatDate', 'merck.ini' );
            $availableDateParams        = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'AvailableDateParams', 'merck.ini' );
            $skipParametersIfEmptyValue = SolrSafeOperatorHelper::clusterIni('SkipParametersIfEmptyValue', 'SkipParameter', 'merck.ini' );
           
            foreach ( $params as $key => $value )
            {                
                if ( array_key_exists( $key, $parameters['data']['profile'] ) )
                {
                    unset( $params[$key] );
                }
                if( !empty( $availableDateParams ) && isset( $availableDateParams[$key] ) && !empty($value)  )
                {
                    $params[$key] = $this->convertDateforUUMP( $value, $formatDate );
                }
                if( !empty( $skipParametersIfEmptyValue ) && isset( $skipParametersIfEmptyValue[$key] ) && empty($value) )
                {
                    unset( $params[$key] );
                }
            }
            $parameters['data']['profile'] = array_merge( $parameters['data']['profile'], $params );

            $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_locale' );
            if ( !is_null( $sl ) )
            {
                $parameters['data']['profile']['locale'] = $sl;
            }
        }
        else
        {
            $parameters = array(
                'Data' => array_merge( $unifiedParameters, array( 'Params' => $params ) ),
                'cr'   => $this->getCountryOfRegistration()
            );
        }

        //LOG for locale field UUMP #36428
        if ( $this instanceof ServiceUserUUMP )
        {
            if( empty( $parameters['data']['profile']['locale'] ) )
            {
                $errorLocalMsg =  "\n\nEMPTY LOCALE:\nVALUES: " . json_encode( $parameters );
                \eZLog::write( $errorLocalMsg, 'esb_uump_locale.log');
            }
        }
        $result = $this->callWSHandler( $this->getEsbInterface( 'create' ), $parameters );

        if( SolrSafeOperatorHelper::featureIsActive('RegistrationAutologin') && SolrSafeOperatorHelper::feature('RegistrationAutologin', 'DisallowPendingUsers') == true && !isset( $_POST['register-helpdesk'] ))
        {
            if( $result['data']['profile']['validationStatus'] == 'PV' )
            {
                $result['RedirectPending'] = true;
                $result['RedirectPendingHref'] = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'PendingUserStaticPage' );
                return $result;
            }
        }

        // if the registration was successful, we need to log the user on eZ + Backend side too
        if ( $this instanceof ServiceUserUUMP )
        {
            $noErrorOnCreate = ( isset( $result['data']['errorCode'] ) && $result['data']['errorCode'] == 0 );
        }
        else
        {
            $noErrorOnCreate = ( isset( $result['Data']['ErrorCode'] ) && $result['Data']['ErrorCode'] == 0 );
        }

        if ( $noErrorOnCreate )
        {
            $allowRedirect            = false;
            $availableRedirectContext = SolrSafeOperatorHelper::feature( 'RegistrationSettings', 'AvailableContextList' );
            $context                  = $_POST['context'] != '' ? $_POST['context'] : null;

            if ( $context !== null && !empty( $availableRedirectContext ) )
            {
                if ( is_array( $availableRedirectContext ) && in_array( $context, $availableRedirectContext ) )
                {
                    $allowRedirect = true;
                }
            }

            // BUT only there is no pending validation needed
            // OR if we are on that local validation page
            if ( ( !SolrSafeOperatorHelper::featureIsActive( 'OverrideWSHandler' ) || self::verifyHash() ) && !isset( $_POST['register-helpdesk'] ))
            {
                if ( $this instanceof ServiceUserUUMP )
                {
                    $userName   = isset( $result['data']['profile']['userName'] ) ? $result['data']['profile']['userName'] : null;
                    $userId     = $result['data']['profile']['userId'];
                    $userSpecialty = isset( $result['data']['profile']['userSpecialty'] ) ? preg_replace('#^A#', '', $result['data']['profile']['userSpecialty']) : null;
                }
                else
                {
                    $readValues = $this->read( array( "User_specialty" ), $result['Data']['Username'] );
                    $parameters = $parameters['Data']['Params'];
                    $userName = isset( $result['Data']['Username'] ) ? $result['Data']['Username'] : null;
                    $userSpecialty = isset( $readValues['Data']['Params']['User_specialty'] ) ? $readValues['Data']['Params']['User_specialty'] : null;
                }

                $businessNames = $this->getBusinessNamesForTicket();
                $ticketParams  = array();
                foreach ( $businessNames as $ticketParam => $businessName )
                {
                    if ( isset( $parameters['data']['profile'][$businessName] ) )
                    {
                        $ticketParams[$ticketParam] = $parameters['data']['profile'][$businessName];
                    }
                    elseif ( isset( $_POST[$businessName] ) )
                    {
                        $ticketParams[$ticketParam] = $_POST[$businessName];
                    }
                    elseif ( $businessName == $this->getBusinessNameMapping( 'countryOfRegistration' ) )
                    {
                        $ticketParams[$ticketParam] = $this->getCountryOfRegistration();
                    }
                    else
                    {
                        eZDebug::writeError( 'Could not get registration param: ' . $businessName );
                    }
                }

                if( $this instanceof ServiceUserUUMP )
                {
                    $ticketParams['Username'] = $userId;
                }
                elseif ( !empty($userName) )
                {
                    $ticketParams['Username'] = $userName;
                }
                
                if ( !empty($userSpecialty) )
                {
                    $ticketParams['User_specialty'] = $userSpecialty;
                }
                
                // used in response to log to the php backend
                $result['AllowRedirect'] = $allowRedirect;

                $ticketParams['toUValidated'] = true;

                MMUserLogin::loginUser( $ticketParams );
                $mmUser = MMUsers::getCurrentUserObject();
                $ticketParams['mmSettings']       = $mmUser->getMMSettings();
                $ticketParams['unorderedAppList'] = $mmUser->getApplicationList();
                $ticketParams['alterboxMsgReset'] = $mmUser->hasPreference('alterboxMsgReset') ? $mmUser->getPreferences('alterboxMsgReset') : true;
                $result['Ticket'] = MMUserLogin::encryptText( json_encode( $ticketParams ) );

            }
        }
        // Consult Popin for France | mobile check disabled - it fails on STG
        if (/* ContextTool::instance()->isMobile() && */ in_array(ClusterTool::clusterIdentifier(), array('cluster_france'))) 
        {
            CookieTool::destroyCookie('displayConsultMobile');
            CookieTool::destroyCookie('displayConsultMobile', '/', null);
            CookieTool::setCookie('displayConsultMobile', $mmUser->getConsult(), time() + ( 2 * 24 * 60 * 60 ));
        }

        if( isset( $_POST['register-helpdesk'] ))
        {
            $result['helpdeskRegister'] = '1';
        }


        return $result;
    }
    protected function sessionCheck()
    {
        $esiKey = isset($_GET['key']) ? $_GET['key'] : null;
        if (   $esiKey
            && $esiKey != static::ANONYMOUS_ESIKEY
            && !self::user()
        ) {
            // logged-in key given and no eZ Session.
            HttpTool::noHTTPCache();
            CookieTool::destroyCookie(MMUsers::COOKIE_KEY);

            $newRelicApi = new \klpNrApi();
            $newRelicApi->setCustomMetric( 'Custom/Issues/HalfLogged', 1 );

            $this->tpl()->setVariable(  'forceUserLogout',
                                        MMUsers::COOKIE_KEY . '=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;'
            );
        }

        return true;
    }
Example #12
0
 public static function destroyCookieUserPreferences()
 {
     CookieTool::destroyCookie( 'alterboxMsgReset' );
     CookieTool::destroyCookie( 'gpNotebookHS' );
     CookieTool::destroyCookie( 'nccn_guidelines_approval_expiration' );
     CookieTool::destroyCookie( 'medicalNewsDemo' );
 }
    /**
     * @param string $remoteId
     * @param array $remoteList
     * @param string $clusterIdentifier
     */
    private function addView( $remoteId, $remoteList, $clusterIdentifier )
    {
        $db = MMDB::instance();
        array_push($remoteList, $remoteId);

        CookieTool::setCookie(self::FEEDBACK_COOKIE_NAME, $remoteList, CookieTool::getDefaultCookieExpiration());

        $query = sprintf(
            "INSERT INTO
                mm_readcount_remote
            SET
                remote_id          = '%s',
                cluster_identifier = '%s',
                date               = '%s',
                count              = 1,
                to_reindex         = 1
            ON DUPLICATE KEY UPDATE
                count   = count + 1,
                date    = '".date('Y-m-d H:i:s')."',
                to_reindex = 1",
            $remoteId,
            $db->escapeString($clusterIdentifier),
            date('Y-m-d H:i:s'));

        $db->query($query);
    }
    /**
     * @param string $url
     * @return bool
     */
    protected static function checkRedirectDomain($url)
    {
        $domain = CookieTool::getCookieDomain();

        if ( preg_match( '#^https?://(?:[^/]+)?'.str_replace('.', '\.', $domain).'(?:[?/].*)?$#', $url) )
        {
            return true;
        }

        $merckIni = eZINI::instance('merck.ini');
        $allowedRedirectDomains = $merckIni->hasVariable( 'CookieSettings', 'AllowedRedirectDomains' ) ?
                                    $merckIni->variable( 'CookieSettings', 'AllowedRedirectDomains' ) :
                                    array();
        foreach( $allowedRedirectDomains as $domain )
        {
            if ( preg_match( '#^https?://(?:[^/]+)?'.str_replace('.', '\.', $domain).'(?:[?/].*)?$#', $url) )
            {
                return true;
            }
        }

        return false;
    }
<?php

if ( MMUsers::getCurrentUserObject() )
{
    header( 'Content-Type: application/json' );

    if ( isset( $_POST['remove_cookie'] ) )
    {
        CookieTool::destroyCookie( 'displayToUPPPopin' );
        CookieTool::destroyCookie( 'displayToUPPPopin', '/', null );
        CookieTool::destroyCookie( 'displayToUPPPage' );
        CookieTool::destroyCookie( 'displayToUPPPage', '/', null );
        echo json_encode( array( 'result' => 0 ) );
        eZExecution::cleanExit();
    }

    $service = ESBFactory::getUserService();
    $userProfile = $service->form();

    $touPage = MMStaticPage::fetchPageByInternalId( 'terms-of-use' );

    $privacyPolicyPageInternalId = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'shortPrivacyPolicyPageInternalId' );
    $privacyPolicyPageInternalId = ( $privacyPolicyPageInternalId === false || is_null( $privacyPolicyPageInternalId ) || trim( $privacyPolicyPageInternalId ) == "" ) ? 'privacy-policy' : $privacyPolicyPageInternalId;
    $ppPage  = MMStaticPage::fetchPageByInternalId( $privacyPolicyPageInternalId );

    $currentToUConsentVersion       = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentToUConsentVersion' );
    $currentPPConsentVersion        = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentPPConsentVersion' );
    $hasCheckbox                    = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'hasCheckbox' );
    $precheckedCheckbox             = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'precheckedCheckbox' );
    $adaptConsentText               = in_array( ClusterTool::clusterIdentifier(), array( 'cluster_uk' ) ) ? true : false;
if ( !isset( $Params['mode'] ) || !isset( $Params['action'] ) )
{
    return $module->handleError( eZError::KERNEL_NOT_AVAILABLE );
}

$mode = SolrSafeOperatorHelper::feature('CookieLaw', 'Mode');
if ( !$mode )
{
    $mode = 'passive';
}
$action = $Params['action'];
$cookieKey = "cookie_{$mode}_optin_cookie";
$lifeTime = SolrSafeOperatorHelper::feature( 'CookieLaw' , 'Lifetime' );
$lifeTime = ( $lifeTime ? $lifeTime : 61516800 );
$cookieVersion = SolrSafeOperatorHelper::feature( 'CookieLaw' , 'Version' );
$cookieVersion = ( $cookieVersion ? $cookieVersion : 1 );

switch ( $action )
{
    case 'accept':
        setcookie( $cookieKey, $cookieVersion, time() + $lifeTime, '/', CookieTool::getCookieDomain() );
        break;
}

header('Content-type: application/json');
echo json_encode( array(
    'ErrorCode' => 0
) );

eZExecution::cleanExit();
Example #17
0
        {
            $context = ContextTool::instance()->domain() . $context;
        }
        if ( ContextTool::instance()->checkRedirectUrl( $context ) )
        {
            $redirectURL .= '?context='.urlencode( $context );
        }
    }

}

$isUserAction = ( isset( $Params['isUserAction'] ) && $Params['isUserAction'] );
if( $isUserAction )
{
    CookieTool::destroyCookie( 'remember_me' );
    CookieTool::destroyCookie( 'unorderedAppList' );
    CookieTool::destroyCookie( eZINI::instance( 'merck.ini' )->variable( 'TIBCOCookieSettings', 'TIBCOCookieName' ) );
    $cookiesToInvalidate = eZINI::instance( 'merck.ini' )->variable( 'LogoutSettings', 'InvalidateCookies' );
    if (is_array($cookiesToInvalidate))
    {
        foreach ($cookiesToInvalidate as $cookie)
        {
            CookieTool::destroyCookie( $cookie );
        }
    }
}

header("Location: $redirectURL");
eZExecution::cleanExit();

    /**
     * @param array $esbResponse
     * @return bool
     */
    public function checkTouPPPopin( $esbResponse )
    {
        $displayReconsent = false;
        if ( SolrSafeOperatorHelper::featureIsActive( 'ToUPPPopin' ) )
        {
            $expiry = time() + ( 2 * 24 * 60 * 60 );
            if ( isset( $esbResponse['data']['profile']['consents'] ) )
            {
                $captationRateisEnabled = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'userCaptationRateEnabled' );
                $touVersion             = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentToUConsentVersion' );
                $ppVersion              = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentPPConsentVersion' );

                $hasTou = false;
                $hasPp  = false;

                foreach ( $esbResponse['data']['profile']['consents'] as $consents )
                {
                    //check Term of use and privacy policies
                    if ( preg_match( '/termsOfUse_v' . $touVersion . '$/', $consents['consentCode'] ) )
                    {
                        if ( $consents['consentStatus'] === 'S' )
                        {
                            $hasTou = true;
                        }
                    }
                    elseif ( preg_match( '/privacyPolicy_v' . $ppVersion . '$/', $consents['consentCode'] ) )
                    {
                        if ( $consents['consentStatus'] === 'S' )
                        {
                            $hasPp = true;
                        }
                    }
                }

                if ( !$hasTou || !$hasPp )
                {
                    if ( $captationRateisEnabled )
                    {
                        $popinInfos = TouPpPopin::fetchByClusterIdentifier();
                        if ( is_null( $popinInfos ) )
                        {
                            $popinInfos = new TouPpPopin();

                            $popinInfos->setAttribute( 'cluster_identifier', ClusterTool::clusterIdentifier() );
                            // Default captation rate set to 0%
                            $popinInfos->setAttribute( 'captation', 0 );
                            $popinInfos->setAttribute( 'count', 0 );

                            $popinInfos->store();
                            $popinInfos = TouPpPopin::fetchByClusterIdentifier();
                        }
                        $captation = $popinInfos->attribute( 'captation' );
                        //if count >= 100, set to 0
                        $count = $popinInfos->attribute( 'count' ) >= 100 ? 0 : $popinInfos->attribute( 'count' );
                        if ( $count <= $captation )
                        {
                            CookieTool::setCookie( 'displayToUPPPopin', 1, $expiry );
                            $displayReconsent = true;
                        }
                        $popinInfos->count = $count + 1;
                        $popinInfos->store();
                    }
                    else
                    {
                        CookieTool::setCookie( 'displayToUPPPopin', 1, $expiry );
                        $displayReconsent = true;
                    }
                }
            }
            else
            {
                $captationRateisEnabled = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'userCaptationRateEnabled' );
                if ( $captationRateisEnabled )
                {
                    $popinInfos = TouPpPopin::fetchByClusterIdentifier();
                    if ( is_null( $popinInfos ) )
                    {
                        $popinInfos = new TouPpPopin();

                        $popinInfos->setAttribute( 'cluster_identifier', ClusterTool::clusterIdentifier() );
                        // Default captation rate set to 0%
                        $popinInfos->setAttribute( 'captation', 0 );
                        $popinInfos->setAttribute( 'count', 0 );

                        $popinInfos->store();
                        $popinInfos = TouPpPopin::fetchByClusterIdentifier();
                    }
                    $captation = $popinInfos->attribute( 'captation' );
                    //if count >= 100, set to 0
                    $count = $popinInfos->attribute( 'count' ) >= 100 ? 0 : $popinInfos->attribute( 'count' );
                    if ( $count <= $captation )
                    {
                        CookieTool::setCookie( 'displayToUPPPopin', 1, $expiry );
                        $displayReconsent = true;
                    }
                    $popinInfos->count = $count + 1;
                    $popinInfos->store();
                }
                else
                {
                    CookieTool::setCookie( 'displayToUPPPopin', 1, $expiry );
                    $displayReconsent = true;
                }
            }
        }

        return $displayReconsent;
    }