/** * @return string */ protected static function refuseToU() { MMUserLogin::logoutUser(); CookieTool::destroyCookie( 'remember_me' ); $redirectURL = ContextTool::instance()->domain().'/logoutActions.php'; return $redirectURL; }
/** * @param string $username * @param ESBResult $esbResult * @return array */ public static function readCall( $username, $esbResult ) { $countryOfRegistration = self::getCountryOfRegistration(); $params = eZINI::instance('merck.ini')->variable( 'EsbSettings', 'AvailableParams' ); if ( !isset( $params ) || !is_array( $params ) ) { MMUserLogin::logError( $username, null, $esbResult->toTicket(), 'Missing esb login parameters. Check merck.ini configuration.' ); return; } if( !in_array( 'Registration_date', $params ) && SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) ) { $params[] = 'Registration_date'; } // List of needed profile information $readParameters = array( 'Data' => array( 'Username' => $username, 'Params' => $params ), 'cr' => $countryOfRegistration ); // Fires a request to get user profile data return WSHelper::call( "read", $readParameters ); }
<?php // Suppression session EZP MMUserLogin::logoutUser(); // Redirection vers logoutActions.php (Suppression session PHP-ESI) $redirectURL = "/logoutActions.php"; if ( isset( $_GET['context'] ) ) { $context = urldecode( $_GET['context'] ); if ( preg_match( '#^(?:https?://|/)#', $context ) ) { if ( strpos( $context, '/' ) === 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' ) );
<?php /* @type $Params string[] */ MMUserLogin::$isLogin = true; $module = $Params['Module']; $tpl = eZTemplate::factory(); $Result = array(); $siteINI = ezINI::instance( 'site.ini' ); $state = MMUserLogin::loginUser(); if ( $state ) { $destUrl = $siteINI->variable( 'SiteAccessSettings', 'JSPUrl' ); if( isset($_GET['context'])) { $context = trim($_GET['context']); if( preg_match( '#^(?:https?://|/)#', $context) ) { $destUrl = urldecode($_GET['context']); } } header('Location: '.$destUrl ); eZExecution::cleanExit(); } else {
<?php MMUserLogin::$isLogin = true; if( in_array( ClusterTool::clusterIdentifier(), array( 'cluster_be_fr', 'cluster_be_nl', 'cluster_ca_fr', 'cluster_ca_en', 'cluster_ch_fr', 'cluster_ch_de' ) ) && 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; case 'fre-CH': $value = 'fr_CH'; break; case 'ger-CH': $value = 'de_CH'; break; case 'fre-CA': $value = 'fr_CA'; break; case 'eng-CA': $value = 'en_CA'; break;
/** * @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; }
/** * @param string $token * @return array */ protected static function decryptToken($token) { $token = str_replace(array('|', '_'), array('+', '/'), $token); return MMUserLogin::uncryptTicket($token); }
/** * @param array $params * @return array */ public function writeUnmapped($params = null) { if (!$params && !is_array($params)) { $params = array(); foreach ($_POST as $k => $v) { $params[$k] = $v; } } $esbParams = $this->getWriteParameters($params); $result = $this->callEsbWrite($esbParams); $uuid = MMUsers::getCurrentUserId(); $ticketParams = array( 'Username' => $uuid, 'Country_of_registration' => $this->getCountryOfRegistration(), ); $ticketParams = array_merge($params, $ticketParams); $result['Ticket'] = MMUserLogin::encryptText( json_encode( $ticketParams ) ); return $result; }
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(); } }
/** * @param array $uncrytedTicket * @return MMUsers */ public static function createOrUpdateMMUser( $uncrytedTicket ) { $userId = $uncrytedTicket['uuid']; $customerType = $uncrytedTicket['customerType']; if ( isset($uncrytedTicket['userSpeciality']) ) { $userSpeciality = $uncrytedTicket['userSpeciality']; } else { $userSpeciality = $uncrytedTicket['mainSpeciality']; } $state = $uncrytedTicket['state']; $country = eZIni::instance('site.ini')->variable('RegionalSettings','CountryOfRegistration'); $language = $uncrytedTicket['language']; /** * @todo: check $language entry format and parse it if needed to get an iso code on 2 chars */ $iniMapping = eZINI::instance('mercktaxonomymapping.ini'); $taxonomyType = $iniMapping->variable( 'Taxonomy', 'SpecialtiesTaxonomyType'); $specialtiesMappingINI = $iniMapping->variable( 'Taxonomy', 'Specialties' ); $customerTypesMappingINI = $iniMapping->variable( 'Taxonomy', 'CustomerTypes' ); if($taxonomyType != "transitive") { if ( isset( $customerTypesMappingINI[$customerType] ) ) { $customerType = $customerTypesMappingINI[$customerType]; } else { $customerType = $customerTypesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-CT', $userId, $country ); } if ( isset( $specialtiesMappingINI[$userSpeciality] ) ) { $userSpeciality = $specialtiesMappingINI[$userSpeciality]; } else { $userSpeciality = $specialtiesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-SPE', $userId, $country ); } } else { $customerTypesMapping = SolrSafeOperatorHelper::getCustomerTypes(); if ( !isset( $customerTypesMapping["$customerType"] ) ) { // fill with default value $customerType = $customerTypesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-CT', $userId, $country ); } $specialtiesMapping = SolrSafeOperatorHelper::getUserSpecialities(); if ( !isset( $specialtiesMapping[(string)$userSpeciality] ) ) { // fill with default value $userSpeciality = $specialtiesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-SPE', $userId, $country ); } } /** @var MMUsers $user */ $user = MMUsers::fetchByIdAndCountry( $userId, $country ); $isModifiedUser = false; if ( $user ) { if ( $customerType != $user->attribute('customer_type') ) { $user->setAttribute('customer_type', $customerType); $isModifiedUser = true; } if ( $userSpeciality !== $user->attribute('user_speciality') ) { $mainSpeciality = UserSpecialityContentSpeciality::getContentSpeciality ( $userSpeciality ); $defaultAdditionalSpecialities = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setAttribute('user_speciality', $userSpeciality); // mapping main_spe additional spe $preferences = $user->getPreferences(); $userAditionalSpecialities = $preferences['specialities']; array_shift($userAditionalSpecialities); $tmp = array_diff( $userAditionalSpecialities, $defaultAdditionalSpecialities ); if( empty( $tmp ) ) // we don't modify the user spes if he has changed his selection { $preferences["specialities"] = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setPreferences($preferences); } $user->setPreferences($preferences); // The user specialty has been modified, we need to update it for Quiz-type applications of the current cluster if( CacheApplicationTool::buildLocalizedApplicationByIdentifier('train-the-brain') instanceof ApplicationLocalized) { $playerScoring = QuizPlayerScoring::fetchOneBy( array( 'application_id' => (int)$app->applicationObject->id, 'uuid' => $user->attribute( 'uuid' ) ) ); // Checking if the current user has scored at least once for the application if( $playerScoring ) { foreach( FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' ) as $k => $t ) { if( ($k . "") === ($userSpeciality . "") ) { // Updating the user specialty id in the player scoring table $playerScoring->setAttribute( 'user_specialty', $t['id'] ); $playerScoring->store(); } } // Scheduling a ranking update QuizPendingRankingUpdate::add( $playerScoring->attribute( 'global_ranking' ), $app->applicationObject->id ); } } $isModifiedUser = true; } if ( $country != $user->attribute('country') ) { $user->setAttribute('country', $country); $isModifiedUser = true; } if( $language != $user->attribute( 'language' ) ) { $user->setAttribute('language', $language ); $isModifiedUser = true; } if ( $state != $user->attribute('state') ) { $user->setAttribute('state', $state); $isModifiedUser = true; } if ( $isModifiedUser ) { $user->setAttribute('date_update', time()); $user->store(); } // set gpnotebook hand shake data in preferences if($user->getGPNotebookHS()) { SolrSafeOperatorHelper::getAndStoreGPNotebookHS(); } } else { $mainSpeciality = UserSpecialityContentSpeciality::getContentSpeciality ( $userSpeciality ); $insertedArray = array ( 'uuid' => $userId, 'customer_type' => $customerType, 'user_speciality' => $userSpeciality, 'country' => $country, 'language' => $language, 'date_update' => time(), 'state' => $state, ); $user = new MMUsers ($insertedArray); $user->store(); // mapping main_spe additional spe $preferences = $user->getPreferences(); $preferences["specialities"] = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setPreferences($preferences); $isModifiedUser = true; } if ( $isModifiedUser ) { // Tag Lyris user to be reimported : $user->tagLyrisToProcess(); } return $user; }
public function relog() { $uuid = isset( $this->_input['uuid'] ) ? $this->_input['uuid'] : null; //$h = isset( $_COOKIE['h'] ) ? $_COOKIE['h'] : null; $h = isset( $this->_input['h'] ) ? $this->_input['h'] : null; $context = isset( $this->_input['context'] ) ? $this->_input['context'] : ContextTool::instance()->domain().'/'; //delete session id cookie //unset($_COOKIE['h']); if ( is_null( $uuid ) || is_null( $h ) ) { MMUserLogin::logError( $uuid, null, null, 'Empty uuid or hash given on Relog' ); return $this->relogError(); } if ( $h != sha1( eZINI::instance( 'merck.ini' )->variable( 'TicketLogin', 'DESKey' ) . $uuid ) ) { MMUserLogin::logError( $uuid, null, null, 'Invalid hash given on Relog' ); return $this->relogError(); } UserLog::instance()->action( 'rememberme' )->uuid( $uuid )->step( 'received' )->store(); $esbResult = new ESBResult(); if ( !SolrSafeOperatorHelper::featureIsActive('UUMP') ) { $datas = static::readCall( $uuid, $esbResult ); } else { $readService = ESBFactory::getUserService(); $parameters = $readService->getFormParameters($uuid); $datas = $readService->read( $parameters, $uuid ); } $isPopulated = static::populateESBResult( $esbResult, $datas ); $this->_esbResult = $esbResult; if ( !$isPopulated ) { // error log caught on WS stack return $this->relogError(); } $esbResult->login = ( $esbResult->userId === $uuid ); if ( !$isPopulated ) { // error log caught on WS stack return $this->relogError(); } $loginResult = MMUserLogin::esbLogin( $uuid, $esbResult, true, $context ); if ( $loginResult ) { $this->_isLoginSuccessful = true; $this->_destUrl = $loginResult['destUrl']; UserLog::instance() ->uuid( $uuid ) ->esb_status( 'Accepted' ) ->store(); $user = MMUsers::getCurrentUserObject(); $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_language' ); $customerLanguage = !is_null( $sl ) ? $sl : eZINI::instance()->variable( 'RegionalSettings', 'ContentObjectLocale' ); if( SolrSafeOperatorHelper::featureIsActive( 'AsynchronousAnalyticsLoginCall' ) && SolrSafeOperatorHelper::feature( 'AsynchronousAnalyticsLoginCall', 'GoogleAnalytics' ) ) { $amq = new ActiveMQManager(); $domains = eZINI::instance( 'merck.ini' )->variable( 'DomainMappingSettings', 'ClusterDomains' ); $domain = isset( $domains[ClusterTool::clusterIdentifier()] ) ? $domains[ClusterTool::clusterIdentifier()] : 'unidentified.univadis.com'; $gasl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'ga_visitor_country' ); $gaCountry = !is_null( $gasl ) ? $gasl : $user->attribute( 'country' ); $gaParams = array( 'v' => 1, 'tid' => 'UA-41415675-6', 'uid' => $uuid, 't' => 'event', 'ec' => 'esb', 'ea' => 'login', 'ni' => 1, 'cd1' => $uuid, 'cd2' => 'logged', 'cd7' => $gaCountry, 'dh' => preg_replace( '#^.*?\.#', '', $domain ), ); $gaParams = 'https://ssl.google-analytics.com/collect?' . http_build_query( $gaParams ); $amq->sendMessageToQueue( 'portail.analytics.google', $gaParams ); } // Stringify params $loginResult['params'][AppBarControl::COOKIE_UNORDERED_APPLIST_KEY] = $user->getApplicationList(); $loginResult['params'][MMUsers::COOKIE_KEY] = $user->getMMSettings(); $strParams = json_encode( $loginResult['params'] ); // Encrypts params $encryptedParams = MMUserLogin::encryptText( $strParams ); // Redirect to PHP-ESI $redirectURL = "/loginActions.php?context=" . urlencode( $loginResult['destUrl'] ) . "¶ms=" . urlencode( $encryptedParams ); if ( !MMUsers::checkCookieLaw() && SolrSafeOperatorHelper::feature('CookieLaw', 'Mode') == MMUsers::COOKIE_LAW_ACTIVE_VERSION_KEY) { $cookieLawPage = SolrSafeOperatorHelper::feature( 'CookieLaw', 'CookieLawPage' ); $redirectURL = ( $cookieLawPage ? $cookieLawPage : '/page/cookie-law' ); } // Branding reconsent check, done only if: // 1. feature ToUPPPopin enabled // 2. Always on WEB with this feature // 3. Only on mobile, whne setting showOnMobile is ON. if ( SolrSafeOperatorHelper::featureIsActive( 'ToUPPPopin') && ( !ContextTool::instance()->isMobile() || ( ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature('ToUPPPopin','showOnMobile') ) ) ) { $displayReconsent = $this->checkTouPPPopin( $datas ); // if we need to ask user for reconsent ($displayReconsent - taken fromESB response) we decide if we want page below if: // 1. On WEB and useDedicatedPage setting is ON // 2. On mobile and useDedicatedPageMobile setting is ON if ( $displayReconsent && ( ( !ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPage' ) ) || ( ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPageMobile' ) ) ) ) { CookieTool::destroyCookie( 'displayToUPPPopin' ); CookieTool::destroyCookie( 'displayToUPPPopin', '/', null ); CookieTool::setCookie( 'displayToUPPPage', 1, time() + ( 2 * 24 * 60 * 60 ) ); $touPpPageUrl = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'ToUPPPageUrl' ) . "/#?tpc=" . urlencode( $loginResult['destUrl'] ); $redirectURL = "/loginActions.php?context=" . urlencode( $touPpPageUrl ) . "¶ms=" . urlencode( $encryptedParams ); } } $this->response( $redirectURL ); } }