Пример #1
0
    public function htmlBuildResult()
    {
        $this->sessionCheck();

        // info for Varnish
        $expireMinutesVarnish = $this->getCustomParameter('ExpireMinutesVarnish');

        if ($expireMinutesVarnish)
        {
            $time   = strtotime("+$expireMinutesVarnish minutes");

            header('Expires: ' . gmdate( 'D, d M Y H:i:s',  $time) . ' GMT');
            header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT');
        }

        $currentUser = self::user();
        $env         = new MMEnvironment();
        $controller  = new MMHomePageController();

        $this->pushResult( 'zones_', $controller->fetchZones( $env->currentId() ) );
        $this->pushResult( 'fp', $this->getFetchParams() );
        $this->pushResult( 'isAnonymous' , (bool)(!$currentUser) );
        $this->pushResult( 'current_user', $currentUser );

        if( !$currentUser )
        {
            $this->pushResult('anonymous_application_ids', array_map( function($v){ return strval($v); }, CountryAppsBar::fetchAppsBarApplicationIds() ));
        }

        $addTrainTheBrain = $this->getCustomParameter('AddTrainTheBrainToHomePage');
        if ($addTrainTheBrain)
        {
            $this->pushResult('quiz_block', 1);
        }
    }
    /**
     * @return int[]
     */
    public function applicationIds()
    {
        if( is_null($this->_applicationIds) )
        {
            $this->_applicationIds = CountryAppsBar::fetchAppsBarApplicationIds();
        }

        return $this->_applicationIds;
    }
    /**
     * 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;
    }
    private function buildResultList()
    {
        $applications = array();
        $applicationIds = array();
        $applicationsByName = array();
        
        foreach( CountryApplicationLibrary::fetchAuthorizedApplicationIds() as $appId )
        {
            if( $appId == 0 )
                continue;
            
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication( $appId );
            
            if( !($applicationLocalized instanceof ApplicationLocalized) )
                continue;

            // Hack : Temporary patch to override in localized application the mm_application.parent_id
            if ( $applicationLocalized->getCustomParameter('DirectAccessDisable') === true )
                continue;

            if( (bool)$applicationLocalized->applicationObject->attribute('application_library') )
            {
                if($applicationLocalized->restrictionLevel() == ApplicationObject::RESTRICTION_LEVEL_LIMITED)
                {
                    if(MMLimitedApplicationsAllowedUsers::hasCurrentUserAccessToApp($applicationLocalized->application_id))
                    {
                        $applications[] = $applicationLocalized->applicationObject;
                        $applicationIds[] = $appId;
                    }
                }
                else
                {
                    $applications[] = $applicationLocalized->applicationObject;
                    $applicationIds[] = $appId;
                }
            }
        }
        
        /* @var $app ApplicationObject */
        foreach( $applications as $k => $app )
            $applicationsByName[$app->applicationLocalized()->attribute('headline')] = $app;
        uksort( $applicationsByName, function($a, $b){ return strnatcasecmp($a, $b); });

        // display all applications
        $this->pushResult('application_ids'     , $applicationIds);
        $this->pushResult('applications_by_name', $applicationsByName);

        // for anonymous users
        $ids = CountryAppsBar::fetchAppsBarApplicationIds();
        $applications_anonymous = array();
        foreach($ids as $id)
            $applications_anonymous[] = (string)$id;
        $this->pushResult('applications_anonymous', $applications_anonymous);

        // banners
        $banners        = array();
        $base           = $this->applicationLocalized()->applicationUrl().'/';
        
        /* @var $application ApplicationObject */
        /* @var $homepageApplication MMHomePage */
        $homepageApplication = ApplicationFactory::fetchByUri('/');
        foreach( $homepageApplication->getAppsToAdd() as $application )
        {
            $bannerFiles = $application->applicationLocalized()->getBanners();

            if (is_array($bannerFiles) && !is_null($bannerFiles['big']) && !is_null($bannerFiles['small']))
            {
                $banners[] = array(
                    'id'        => $this->applicationLocalized()->attribute('id'),
                    'img'       => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/big/'.ClusterTool::clusterIdentifier().'.png'),
                    'img_small' => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/small/'.ClusterTool::clusterIdentifier().'.png'),
                    'label'     => $application->applicationLocalized()->attribute('headline'),
                    'url'       => $base . $application->applicationLocalized()->attribute('url'),
                );
            }

            if( count($banners) >= self::BANNER_ITEMS_LIMIT )
                break;
        }

        $this->pushResult('banners', $banners);
    }
    public function run()
    {
        $cluster = ClusterTool::clusterIdentifier();

        if ( !$cluster )
        {
            $this->debug( 'MMLyrisUserImportHandler : Used siteaccess is not a cluster, run the cronjob with a cluster siteaccess', 'Lyris' );
            return;
        }

        $db = eZDB::instance();
        /* @type $clusterMapping array */
        $clusterMapping = eZINI::instance( 'merck.ini' )->variable( 'ClusterSettings', 'CountryMapping' );

        try
        {
            $this->debug( 'MMLyrisUserImportHandler : BEGIN', 'Lyris' );

            $countries = array_keys( $clusterMapping, $cluster );

            foreach ( $countries as $currentCountryLanguage )
            {
                list( $currentCountry, $currentLanguage ) = explode( '|', $currentCountryLanguage );

                $this->debug( "MMLyrisUserImportHandler : Now treating country '$currentCountry' with language '$currentLanguage' (could be empty)", 'Lyris' );

                $userImportList = MMLyrisUserImport::fetchUnprocessedListByCountryLanguage( $currentCountry, $currentLanguage, null, false );

                foreach ( $userImportList as &$item )
                {
                    $username = trim( $item['username'] );
                    $country = trim( $item['country_registration'] );

                    $this->debug( 'Importing <' . $username . ' -- ' . $country . '>... ', 'Lyris' );
                    $db->begin();

                    $mainSpecialty = trim( $item['specialty'] );

                    $mmUser = MMUsers::fetchByIdAndCountry( $username, $country );
                    if ( empty( $mmUser ) )
                    {
                        $m = array();
                        if ( preg_match('#^216\.#', $mainSpecialty, $m) )
                        {
                            $contentSpecialty = UserSpecialityContentSpeciality::getContentSpeciality ( $mainSpecialty );
                            $specialties = MMUserLogin::getAddSpecialties( $contentSpecialty );
                        }
                        else
                            $specialties = MMUserLogin::getAddSpecialties( $mainSpecialty );

                        $applications = CountryAppsBar::fetchAppsBarApplicationIds( $item['customer_type'], $mainSpecialty, $country );
                        $customerType = $item['customer_type'];
                    }
                    else
                    {
                        $applications = $mmUser->getApplicationList();
                        $country = trim( $mmUser->attribute( 'country' ) );
                        $mainSpecialty = trim( $mmUser->userSpecialityId() );
                        $mSpe = trim( $mmUser->mainSpecialityId() );
                        $specialties = $mmUser->getSpecialities();

                        if ( ($i = array_search($mSpe, $specialties)) !== false )
                        {
                            unset($specialties[$i]);
                        }

                        $customerType = $mmUser->customerTypeId();
                    }

                    $mmUserExport = MMLyrisUserExport::fetchByUsernameAndCountry( $username, $country );

                    // Remove old entry to be sure NULL values will be set :
                    if ( !empty( $mmUserExport ) )
                    {
                        $mmUserExport->remove();
                    }
                    $mmUserExport = new MMLyrisUserExport( array(
                        'username' => $username
                    ) );
                    $mmUserExport->setAttribute( 'processed', 0 );
                    $mmUserExport->setAttribute( 'country_registration', empty( $country ) ? null : $country );
                    $mmUserExport->setAttribute( 'user_specialty', empty( $mainSpecialty ) ? null : $mainSpecialty );
                    $additionalSpecialties = trim( implode( ',', $specialties ) );
                    $mmUserExport->setAttribute( 'additional_specialties', empty( $additionalSpecialties ) ? null : $additionalSpecialties );
                    $mmUserExport->setAttribute( 'apps', $this->createXML( $applications ) );
                    $mmUserExport->setAttribute( 'customer_type', $customerType );

                    $mmUserExport->store();

                    $mmUserImport = MMLyrisUserImport::fetchByUsernameAndCountry( $username, $country );

                    if ( $mmUserImport instanceof MMLyrisUserImport )
                    {
                        $mmUserImport->setAttribute( 'processed', 1 );
                        $mmUserImport->store();
                    }
                    else
                    {
                        $this->debug( "User '$username' does not exist in '$country' !!!", 'LYRIS IMPORT ERROR', eZDebug::LEVEL_ERROR );
                    }

                    $db->commit();
                    $this->debug( '... DONE.', 'Lyris' );

                }
                $this->debug( count( $userImportList ) . ' items treated', 'MMLyrisUserImportHandler : END' );
            }
        }
        catch ( Exception $e )
        {
            $this->debug( $e, 'LYRIS IMPORT ERROR', eZDebug::LEVEL_ERROR );
            $db->rollback();
        }
    }
    /**
     * 
     * @return eZTemplate
     */
    public function tpl()
    {
        $tpl = parent::tpl();

        // test if user is logged
        $userId         = MMUsers::getCurrentUserId();
        $currentUser    = MMUsers::fetchById( $userId );
        $isLogged       = !empty($currentUser);

        $salt = eZINI::instance( 'merck.ini' )->variable( 'TicketLogin', 'DESKey' );
        $hash = sha1($this->getApplicationId() . $salt);

        $tpl->setVariable('application_id', $this->getApplicationId());
        $tpl->setVariable('is_logged'     , $isLogged);
        $tpl->setVariable('hash'          , $hash);

        // applications for anonymous users
        $applications_anonymous = array();

        if( !$isLogged )
        {
            $ids = CountryAppsBar::fetchAppsBarApplicationIds();

            // convert ids in string
            $applications_anonymous = explode(',', implode(',', $ids));
        }

        $tpl->setVariable('applications_anonymous', $applications_anonymous);

        if( $isLogged && SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) )
        {
            $gtmVariables = array(
                'visitorSpecialtyLabel' => SolrSafeOperatorHelper::getTaxoTranslation( 'user_specialty', $this->user()->userSpecialityId() ),
                'visitorTypeLabel'      => SolrSafeOperatorHelper::getTaxoTranslation( 'customer_type',  $this->user()->customerTypeId() )
            );
            $gtmToPush = isset( $this->_result['gtm_variables'] ) ? array_merge( $this->_result['gtm_variables'], $gtmVariables ) : $gtmVariables;
            $tpl->setVariable( 'gtm_visitorvariables', $gtmToPush );
        }

        return $tpl;
    }