/** * Form submission handler for sending sms * @return array */ public function sm() { $subject = ezpI18n::tr( 'application/contactus', 'MAIL SUBJECT' ); $message = $this->prepareMessageText(); if (SolrSafeOperatorHelper::featureIsActive('ContactForm') && SolrSafeOperatorHelper::feature('ContactForm', 'AnonymousPrivacyPolicyCheckbox') && MMUsers::getCurrentUserObject() == null) { if (!isset($_POST['Privacy_policy'])) { return array( 'error' => 1, ); } } if ($this->shouldAppendCountryOfRegistration()) { $prefix = !empty($_POST['countryOfResidence']) ? '[' . $_POST['countryOfResidence'] . ']' : ''; $subject = "{$prefix} " . $subject; } //Send mail $emailTool = new MailTool( $subject, $this->fromEmail, $this->toEmail, $message, self::CONTACTUS_LOG_NAME ); $emailTool->sendMail(); return array( 'redirect_url' => $this->redirectUrl ); }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl( &$node = null ) { $merckIni = ExternalLinkHandlerBase::iniMerck(); $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); } $restUrl = $merckIni->variable( 'DriOnlineSettings', 'BaseLoginUrl' ); $vectorShared = mcrypt_create_iv( self::iv_size() ); $params = array( 'username' => $user->attribute( 'uuid' ), 'speciality' => $user->attribute( 'main_speciality' ), 'referrer' => $merckIni->variable( 'DriOnlineSettings', 'Referrer' ), 'action' => $merckIni->variable( 'DriOnlineSettings', 'Action' ), 'request_time' => time() ); $encodeArray = json_encode( $params ); $encodeArray = self::pad( $encodeArray ); $userEncrypt = $this->encrypt( $encodeArray, $vectorShared ); $urlParams = array( 'v' => base64_encode( $vectorShared ), 'val' => base64_encode( $userEncrypt ) ); return array( 'url' => $restUrl, 'params' => $urlParams ); }
/** * @return MMUsers */ public function user() { if( is_null($this->_user) ) { $this->_user = MMUsers::getCurrentUserObject(); } return $this->_user; }
public static function getUserData() { $user = MMUsers::getCurrentUserObject(); return array( 'UID' => MMeLearningList::getCountryPrefixForElearning() . $user->attribute( 'uuid' ), 'CID' => CertificatesWebservice::getProperCountryId( $user ), ); }
public function __construct( $params, $outputType, $blockName, $applicationName, $applicationObject, $applicationLocalized ) { parent::__construct( $params, $outputType, $blockName, $applicationName, $applicationObject, $applicationLocalized ); $this->user = MMUsers::getCurrentUserObject(); $ini = eZINI::instance( 'merck.ini' ); $this->applicationId = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'ApplicationId' ); $this->clientId = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'ClientId' ); $this->clientSecret = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'ClientSecret' ); $this->tokenRequestUrl = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'TokenRequestUrl' ); $this->tokenFileName = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'TokenFileName' ); $this->serviceUrl = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'ServiceUrl' ); $this->smsRecipients = $ini->variable( self::SMS_SETTING_BLOCK_NAME, 'SmsRecipients' ); }
public function getNodeUrl( &$node = null ) { $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); } $url = $this->application()->applicationLocalized()->attribute( 'external_url' ); $url = $this->buildUrl($url, $user); return $url; }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl(&$node = null) { $url = $this->application()->applicationLocalized()->attribute( 'external_url' ); $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); } $uuid = $user->attribute( 'uuid' ); $queryData = array( 'id' => $uuid, ); $url = $url . '?' . http_build_query($queryData); return $url; }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl( &$node = null ) { $baseUrl = $this->application()->applicationLocalized()->external_url; $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); return false; } $userId = $user->getCurrentUserId(); $params = array( 'uumpid' => $userId, ); $queryString = http_build_query($params); $url = $baseUrl.'?'.$queryString; return $url; }
/** * Form submission handler for creating session at remote location */ public function cs() { $http = BlockDefault::http(); $oldPassword = $http->hasPostVariable( 'OldPassword' ) ? utf8_decode( stripslashes( $http->postVariable( 'OldPassword' ) ) ) : ''; $user = MMUsers::getCurrentUserObject(); if ( !$user instanceof MMUsers ) { //TODO: return when user is not instanceof MMUsers } $data = array( 'Username' => $user->attribute( 'uuid' ), 'Password' => $oldPassword, ); $postData = http_build_query( $data ); $curlHandler = curl_init( $this->createSessionURL ); curl_setopt( $curlHandler, CURLOPT_POST, count( $data ) ); curl_setopt( $curlHandler, CURLOPT_POSTFIELDS, $postData ); curl_setopt( $curlHandler, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt( $curlHandler, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $curlHandler, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $curlHandler, CURLOPT_HEADER, TRUE ); curl_setopt( $curlHandler, CURLOPT_FOLLOWLOCATION, TRUE ); $response = curl_exec( $curlHandler ); if ( curl_errno( $curlHandler ) ) { eZLog::write( 'Curl error: ' . curl_error( $curlHandler ), 'changepassword.log' ); } else { eZLog::write( 'Curl ended without any errors', 'changepassword.log' ); } eZLog::write( 'Curl status: ' . print_r( curl_getinfo( $curlHandler ), true ), 'changepassword.log' ); eZLog::write( "\nUsername: {$data['Username']}\nPassword: ****\nURL: {$this->createSessionURL}\nQuery: {$postData}\nResponse: {$response}\n", 'changepassword.log' ); curl_close( $curlHandler ); }
/** * @param eZContentObjectTreeNode $node * @return array */ public function getNodeUrl( &$node = null ) { $merckIni = ExternalLinkHandlerBase::iniMerck(); $action = $merckIni->variable( 'AlexandriaSettings' , 'Action' ); $referer = $merckIni->variable( 'AlexandriaSettings' , 'Referer' ); $uuid = MMUsers::getCurrentUserObject()->uuid; $baseUrl = $merckIni->variable( 'AlexandriaSettings' , 'BaseLoginUrl' ); $url = $this->application()->applicationLocalized()->external_url; $requestTime = time(); if ( !$uuid ) { self::redirectToErrorPage(); } $vectorShared = mcrypt_create_iv( Crypter::iv_size() ); $params = array( 'username' => $uuid, 'referer' => $referer, 'action' => $action, 'request_time' => $requestTime, 'URL' => $url ); $encodeArray = json_encode( $params ); $encodeArray = Crypter::pad( $encodeArray ); $userEncrypt = Crypter::encrypt( $encodeArray, $vectorShared ); $urlParams = array( 'v' => base64_encode( $vectorShared ), 'val' => base64_encode( $userEncrypt ) ); return array( 'url' => $baseUrl, 'params' => $urlParams ); }
/** * @param string $content * @return array */ static function add( $content ) { $currentMMUser = MMUsers::getCurrentUserObject(); if( !$currentMMUser ) return false; $prcuh = self::fetchObject( self::definition(), null, array( 'md5_uuid' => md5( $currentMMUser->attribute( 'uuid' ) ) ) ); if( !$prcuh ) { $prcuh = new self(); $prcuh->setAttribute( 'md5_uuid', md5( $currentMMUser->attribute( 'uuid' ) ) ); } if( $prcuh && $content != 'undefined' ) { $prcuh->setAttribute( 'content', $content ); } $prcuh->store(); return array( 'token' => $prcuh->attribute( 'md5_uuid' ) ); }
/** * Accept NCCN Guidelines * @return array */ public function ang() { $user = MMUsers::getCurrentUserObject(); $date = $user->setNCCNGuidelinesApprovalExpiration(); MMUsers::setCookieUserPreferences(); return array( 'errorCode' => 0, 'date' => $date, ); }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl( &$node = null ) { $merckIni = ExternalLinkHandlerBase::iniMerck(); $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); } $esbParams = $merckIni->variable( 'EsbSettings', 'AvailableParams' ); if ( !in_array( 'Validation_status', $esbParams ) ) { $esbParams[] = 'Validation_status'; } // esb part of url generating $parameters = array( 'Data' => array( 'Username' => $user->attribute( 'uuid' ), 'Params' => $esbParams ), 'cr' => $user->attribute( 'country' ) ); $esbResponse = WSHelper::call( 'read', $parameters ); if ( !isset( $esbResponse['Data']['Params']['Email_address'] ) ) { self::redirectToErrorPage(); } $validStatuses = array( 'VP', '30' ); $isProperStatus = isset( $esbResponse['Data']['Params']['Validation_status'] ) && in_array( $esbResponse['Data']['Params']['Validation_status'], $validStatuses ); // test if proper ESB response - mainly status = Success if ( !$isProperStatus ) { self::redirectToErrorPage(); } $soapUser = $esbResponse['Data']['Params']['Email_address']; $soapPassword = $merckIni->variable( 'MdConsultSettings', 'SoapPassword' ); $applicationId = $merckIni->variable( 'MdConsultSettings', 'ApplicationId' ); $apiKey = $merckIni->variable( 'MdConsultSettings', 'ApiKey' ); $headerNamespace = $merckIni->variable( 'MdConsultSettings', 'HeaderNamespace' ); //$soapUrl = $merckIni->variable( 'MdConsultSettings', 'SoapUrl' ); // @dirty fix => we use a local version of the WSDL because of some type declaration duplicates $soapUrl = __DIR__.'/externallinkhandlerbrmdconsult.xml'; $headerbody = array( 'UsernameToken' => array( 'Username' => $apiKey, 'Password' => $soapPassword ) ); // soap part of url generating $soap = new SoapClient( $soapUrl ); $header = new SOAPHeader( $headerNamespace, 'Security', $headerbody, false ); $soap->__setSoapHeaders( $header ); $params = array( array( 'SiteID' => 'MSDBRZL', 'UserName' => $soapUser, 'ApplicationId' => $applicationId ) ); $user = ''; $password = ''; try { $result = $soap->__soapCall( 'GetThirdPartyCredencials', $params ); if ( isset( $result->GetThirdPartyCredencialsResult ) && isset( $result->GetThirdPartyCredencialsResult->LOVValue ) ) { $credentials = $result->GetThirdPartyCredencialsResult->LOVValue; if ( isset( $credentials->lovIDField ) ) { $user = $credentials->lovIDField; } else { self::redirectToErrorPage(); } if ( isset( $credentials->valueField ) ) { $password = $credentials->valueField; } else { self::redirectToErrorPage(); } } else { self::redirectToErrorPage(); } } catch ( SoapFault $f ) { self::redirectToErrorPage(); } $url = $merckIni->variable( 'MdConsultSettings', 'MdUrl' ); $searches = array( '<$md_user>', '<$md_password>' ); $replacements = array( $user, $password ); $url = str_replace( $searches, $replacements, $url ); return $url; }
/** * @param null $customerType * @param null $speciality * @param null $limit * @return array */ public static function fetchBanners($customerType = null, $speciality = null, $limit = null) { $user = MMUsers::getCurrentUserObject(); if($user) { $speciality = $user->attribute("user_speciality"); $customerType = $user->customerTypeId(); } $channels = self::fetchFeaturedByProfile($customerType, $speciality, $limit); $banners = array(); $environment = ContextTool::instance()->environment(); /** @var FeaturedChannel $channel */ foreach($channels as $channel) { $application = $channel->application(); if ($application == null) { continue; } $applicationLocalized = $application->applicationLocalized(); if (!$applicationLocalized || !($applicationLocalized->attribute('environment') & $environment)) { continue; } $channelConfiguration = ChannelConfiguration::getChannelConfigurationByApplicationLocalizedId($applicationLocalized->attribute("id")); $title = $channel->attribute("title"); $subtitle = $channel->attribute("subtitle"); if(!$title) { $title = $applicationLocalized->attribute("headline"); } if(!$subtitle) { $subtitle = $channelConfiguration->attribute("subtitle"); } $banners[] = array( "title" => $title, "subtitle" => $subtitle, "url" => "/".$applicationLocalized->attribute("url"), "cover" => $channel->getCoverPath($channelConfiguration), "icon_small" => $channel->getIconSmallPath($channelConfiguration), "new" => $channel->getNewImage($channelConfiguration), "color" => $channel->getColor($channelConfiguration), ); } return $banners; }
/** * @param string $remote_id * @param string $cluster_identifier * @param string $description * @param string $url * @param string $application * @param string $elearningStatus * @return int */ public static function addToMySelection( $remote_id, $cluster_identifier, $description, $url, $application, $elearningStatus = null ) { $currentMMUser = MMUsers::getCurrentUserObject(); if ( !($currentMMUser instanceof MMUsers) ) return 0; $uuid = $currentMMUser->attribute( 'uuid' ); $country = $currentMMUser->attribute( 'country' ); if( !self::isAlreadyInUserSelection( $remote_id, $cluster_identifier ) ) { if ( !$currentMMUser ) return self::countTotalFromUserSelection(); $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($application); $application = $applicationLocalized->applicationObject()->attribute('identifier'); $selection = new MMSelections(); $selection->setAttribute( 'uuid', $uuid ); $selection->setAttribute( 'country', $country ); $selection->setAttribute( 'url', $url ); $selection->setAttribute( 'remote_id', $remote_id ); $selection->setAttribute( 'cluster_identifier', $cluster_identifier ); $selection->setAttribute( 'description', $description ); $selection->setAttribute( 'add_date', time() ); $selection->setAttribute( 'application', $application ); $selection->store(); } elseif( $application == 'e-learning' ) { self::updateSelectionDescription( $remote_id, $cluster_identifier, $description, $elearningStatus ); } self::setCookie(); return self::countTotalFromUserSelection($uuid, $country); }
/** * @param int $parent * @param int $id * @return ApplicationObject */ public static function fetchByParent($parent, $id = null) { $cond = array('parent_id' => $parent); $isLoggedUser = MMUsers::getCurrentUserObject(); if( !$isLoggedUser ) { $restricted = array( 'restriction_level' => array( array( self::RESTRICTION_LEVEL_PUBLIC, self::RESTRICTION_LEVEL_RESTRICTED ) ) ); } else { $restricted = array( 'id' => array( CountryApplicationLibrary::fetchAuthorizedApplicationIds() ) ); } $cond = array_merge($cond, $restricted); $relatedApps = ApplicationLocalized::fetchApplicationList ( $cond ); if( $id ) { for( $i=0; $i<count($relatedApps); $i++ ) { if( $relatedApps[$i]->id == $id ) { unset($relatedApps[$i]); break; } } } $wantedChildApps = array(); $i = 0; foreach ($relatedApps as $relatedApp) { $passAppToView = true; $appLocalized = $relatedApp->applicationLocalized(); if ( $appLocalized instanceof ApplicationLocalized && !$isLoggedUser) { if ( !in_array( $appLocalized->restrictionLevel(), $restricted['restriction_level'][0] ) ) { $passAppToView = false; } } if ( $passAppToView ) { $wantedChildApps[$i] = $relatedApp; $i++; } } return $wantedChildApps; }
/** * @param bool $forAnonmyous * @param null $processedUserCustomerType * @return int[] */ public static function fetchAuthorizedApplicationIds( $forAnonmyous = false, $processedUserCustomerType = null ) { if( !$forAnonmyous && !is_null(self::$_authorizedApplications) ) return self::$_authorizedApplications; $db = MMDB::instance(); $customerType = null; $mainSpeciality = null; $whereString = sprintf( " cluster_identifier='%s' AND environment & %d", $db->escapeString(ClusterTool::clusterIdentifier()), ContextTool::instance()->environment() ); $user = $forAnonmyous ? false : MMUsers::getCurrentUserObject(); if( $user ) { /* @var $user MMUsers */ $user = MMUsers::getCurrentUserObject(); $customerType = $user->attribute('customer_type'); $mainSpeciality = $user->attribute('main_speciality'); if( $user->hasAttribute('prefered_language')) { $language = $user->attribute('prefered_language'); $whereString.= sprintf( " AND ( language = '%s' OR language IS NULL OR language = '0' )", $db->escapeString($language) ); } if( $user->hasAttribute('country')) { $country = $user->attribute('country'); $whereString.= sprintf( " AND ( country = '%s' OR country IS NULL OR country = '0' )", $db->escapeString($country) ); } } if (!$customerType && $processedUserCustomerType) { $customerType = $processedUserCustomerType; } $whereString .= is_null($customerType) ? ' AND customer_type IS NULL ' : sprintf( " AND ( customer_type IS NULL OR customer_type = '0' OR customer_type='%s') ", $db->escapeString($customerType) ); $whereString .= is_null($mainSpeciality) ? ' AND main_speciality IS NULL ' : sprintf( " AND ( main_speciality IS NULL OR main_speciality = '0' OR main_speciality='%s') ", $db->escapeString($mainSpeciality) ); $sql = "SELECT * FROM mm_country_application_library WHERE ".$whereString." ORDER BY country DESC, language DESC, customer_type DESC, main_speciality DESC"; $lastProfile = null; $excludedApps = array(); $applicationIds = array(); foreach( $db->arrayQuery($sql) as $row ) { $profile = serialize( array($row['customer_type'], $row['main_speciality']) ); if( !is_null($lastProfile) && $profile != $lastProfile ) break; $lastProfile = $profile; if( $user && $user->hasAttribute('state') && !is_null($user->attribute('state')) && $row['state'] === $user->attribute('state') ) { $excludedApps[] = (int)$row['application_id']; continue; } $applicationIds[] = (int) $row['application_id']; } if( !empty($excludedApps) ) { foreach ( $applicationIds as $k => $appId ) { if( in_array($appId, $excludedApps ) ) unset( $applicationIds[$k] ); } $applicationIds = array_values($applicationIds); } if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment')) { $applicationIds[] = ApplicationObject::fetchByIdentifier('learning-needs-assessment')->attribute('id'); } $applicationIds = array_unique( $applicationIds ); if( !$forAnonmyous ) self::$_authorizedApplications = $applicationIds; return $applicationIds; }
/** * @param bool $forceExternal * @return string */ public function applicationUrl( $forceExternal = false ) { $skipPage = (bool) $this->getCustomParameter( 'SkipExitPage' ) && ( is_object( MMUsers::getCurrentUserObject() ) ); // Direct redirect without exit page if( $this->getCustomParameter( 'DirectLinkOpen' ) == 1 ) { return $this->attribute( 'external_url' ); } $baseUrl = eZINI::instance()->variable( 'SiteAccessSettings', 'BaseUrl' ); $urlAlias = $this->attribute( 'url' ); if( !$urlAlias ) $urlAlias = $this->applicationObject()->attribute( 'url' ); // external if ( $forceExternal || ( $this->applicationObject->applicationType()->attribute('internal_type') == ApplicationObject::APPLICATION_TYPE_EXTERNAL ) ) { // Production //if(SolrSafeOperatorHelper::clusterIni("SocialSharing", "EntryExit", "merck.ini") == "enabled") if(SolrSafeOperatorHelper::featureIsActive("SocialSharing") && SolrSafeOperatorHelper::feature("SocialSharing", "EntryExit") && !$skipPage) return $baseUrl. $this->attribute( 'url' ); else return $baseUrl.'external/' . $this->attribute( 'url' ); /* Dev * return $baseUrl.'esibuild/main_view/app_content/' . $this->attribute( 'url' ); */ } return $baseUrl . $urlAlias; }
/** * @return int */ protected function userRating() { $remoteID = ( isset( $_POST['remoteID'] ) && filter_var($_POST['remoteID'], FILTER_VALIDATE_REGEXP, SecurityTool::$REMOTEID_REGEXP) ) ? $_POST['remoteID'] : null; $rating = ( isset( $_POST['rating'] ) && filter_var($_POST['rating'], FILTER_VALIDATE_INT) ) ? $_POST['rating'] : null; $clusterIdentifier = ( isset( $_POST['cluster_identifier'] ) && filter_var($_POST['cluster_identifier'], FILTER_VALIDATE_REGEXP, SecurityTool::$CLUSTER_IDENTIFIER_REGEXP) ) ? $_POST['cluster_identifier'] : null; $user = MMUsers::getCurrentUserObject(); if( !$user ) { $this->_inError = true; return false; } return $user->addRating( $remoteID, $rating*2, $clusterIdentifier ); }
eZExecution::cleanExit(); } if ($position < 0) { echo "Position must be > 1"; eZExecution::cleanExit(); } $application = ApplicationLocalized::getLocalizedApplicationByIdentifier($applicationIdentifier); if ($application == null || $application instanceof ApplicationLocalized === false) { header('Location: /error_40x'); eZExecution::cleanExit(); } $user = MMUsers::getCurrentUserObject(); if ($user === false) { $siteIni = eZINI::instance( 'site.ini' ); $loginUrl = preg_replace('#^https?//[^/]+#', '', $siteIni->variable('SiteSettings', 'LoginPage')); $redirectUrl = $loginUrl . '?context='. urlencode("/service/app/{$applicationIdentifier}/{$function}/{$position}"); header('Location: ' . $redirectUrl); eZExecution::cleanExit(); } //we need to shift position by 1 $position--; $appList = $user->getApplicationList(); $appId = $application->application_id;
/** * @param string $newGameName * @param int $applicationId * @return array */ static function createNewPlayer( $newGameName, $applicationId, $isLocalQuiz = true ) { $currentMMUser = MMUsers::getCurrentUserObject(); if( $currentMMUser ) { $clusterIdentifier = ($isLocalQuiz) ? ClusterTool::clusterIdentifier() : ''; $newPlayer = new QuizPlayerScoring(); // Setting up the global ranking of the new player $lowestGlobalScore = self::fetchBy( array( 'application_id' => $applicationId, 'cluster_identifier' => $clusterIdentifier ), array( 'global_ranking' => 'desc' ), array( 'length' => 1 ) ); if( $lowestGlobalScore ) $lgs = $lowestGlobalScore[0]->attribute( 'score' ) == 0 ? $lowestGlobalScore[0]->attribute( 'global_ranking' ) : ( $lowestGlobalScore[0]->attribute( 'global_ranking' ) + 1 ); else $lgs = 1; // Setting up the specialty ranking of the new player $userSpecialtyTranslations = FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' ); $userSpecialtyTaxonomyId = $userSpecialtyTranslations[$currentMMUser->attribute( 'user_speciality' )]['id']; $lowestSpecialtyScore = self::fetchBy( array( 'application_id' => $applicationId, 'user_specialty' => $userSpecialtyTaxonomyId ), array( 'specialty_ranking' => 'desc' ), array( 'length' => 1 ) ); if( $lowestSpecialtyScore ) $lss = $lowestSpecialtyScore[0]->attribute( 'score' ) == 0 ? $lowestSpecialtyScore[0]->attribute( 'specialty_ranking' ) : ( $lowestSpecialtyScore[0]->attribute( 'specialty_ranking' ) + 1 ); else $lss = 1; $newPlayer->setAttribute( 'game_name', $newGameName ); $newPlayer->setAttribute( 'uuid', $currentMMUser->attribute( 'uuid' ) ); $newPlayer->setAttribute( 'cluster_identifier', $clusterIdentifier); $newPlayer->setAttribute( 'application_id', $applicationId ); $newPlayer->setAttribute( 'score', 0 ); $newPlayer->setAttribute( 'user_specialty', Taxonomy::fetchObject( Taxonomy::definition(), null, array( 'code' => $currentMMUser->attribute( 'user_speciality' ) ), true)->attribute( 'id' ) ); $newPlayer->setAttribute( 'nb_correct', 0 ); $newPlayer->setAttribute( 'nb_wrong', 0 ); $newPlayer->setAttribute( 'global_ranking', $lgs ); $newPlayer->setAttribute( 'specialty_ranking', $lss ); $newPlayer->setAttribute( 'user_cluster', ClusterTool::clusterIdentifier() ); $newPlayer->store(); return array( 'lgs' => $lgs, 'lss' => $lss ); } return null; }
public function addInfo($campaignCode, $data) { if (MMUsers::getCurrentUserObject() instanceof MMUsers == false) { return null; } $userId = MMUsers::getCurrentUserId(); $data = array( 'data' => array( 'additionalInfo' => array( 'userId' => $userId, 'campaignCode' => $campaignCode, 'headers' => $data, ) ) ); // $data = json_encode($data); return $this->callWSHandler($this->getEsbInterface('addinfo'), $data); }
/** * @return array */ public function cmp() { $user = MMUsers::getCurrentUserObject(); if( $user instanceof MMUsers ) { $data = $user->setConsult(); MMUsers::setCookieUserPreferences(); return array( 'errorCode' => 0, 'date' => $data ); } else { return array( 'errorCode' => 9, 'date' => 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;
/** * @param int $quizId * @param int $applicationId * @return array */ static function getQuizData( $quizId, $applicationId, $isLocalQuiz = true ) { $quizData = self::fetchOneBy( array( 'quiz_id' => $quizId, 'application_id' => $applicationId ) ); if( !$quizData ) { // We don't have the quiz meta for the requested quiz, we try to create it (happens only once) $object =& eZContentObject::fetch( $quizId ); if( !$object ) return null; /* @type $dm eZContentObjectAttribute[] */ $dm = $object->DataMap(); $mc = $dm['media_content']->content(); if( isset( $mc['relation_list'][0]['node_id'] ) ) { $quiz =& eZContentObjectTreeNode::fetch( $mc['relation_list'][0]['node_id'] ); /* @type $quizDM eZContentObjectAttribute[] */ $quizDM = $quiz->DataMap(); self::add( $quizId, ClusterTool::clusterIdentifier(), $applicationId, (int)$quizDM['points']->content(), (int)$quizDM['correct_reply']->content() ); $quizData = self::fetchOneBy( array( 'quiz_id' => $quizId, 'application_id' => $applicationId ) ); } else { return null; } } $currentMMUser = MMUsers::getCurrentUserObject(); $currentUserResponse = false; $nbCorrect = (int)$quizData->attribute( 'nb_correct' ); $nbWrong = (int)$quizData->attribute( 'nb_wrong' ); if ( $currentMMUser ) { $responseFetchParams = array( 'quiz_id' => $quizId, 'uuid' => $currentMMUser->attribute( 'uuid' ), 'application_id' => $applicationId ); if (!$isLocalQuiz) { $responseFetchParams['cluster_identifier'] = null; } $currentUserResponse = QuizReply::fetchOneBy( $responseFetchParams ); } if( $currentUserResponse ) { $currentUserResponded = true; $answerWasCorrect = (bool)$currentUserResponse->attribute( 'is_correct' ); } else { $currentUserResponded = false; $answerWasCorrect = false; } $speRepliesResult = array( 'total' => 0, 'correct' => 0, 'wrong' => 0 ); $userSpecialtyTranslations = FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' ); if ( $currentMMUser ) { $userSpecialtyId = $userSpecialtyTranslations[$currentMMUser->attribute( 'user_speciality' )]['id']; $speReplies = QuizReply::fetchBySpecialtyInScoring( $currentMMUser->attribute( 'uuid' ), $quizId, $applicationId, $userSpecialtyId ); if( $speReplies ) { $speRepliesResult['total'] = count( $speReplies ); foreach( $speReplies as $reply ) { if( $reply['is_correct'] == 1 ) $speRepliesResult['correct']++; else $speRepliesResult['wrong']++; } } } $response = array( 'points' => (int)$quizData->attribute( 'points' ), 'correct_answer' => (int)$quizData->attribute( 'correct_answer' ), 'global_answers' => array( 'total' => ( $nbCorrect + $nbWrong ), 'correct' => $nbCorrect, 'wrong' => $nbWrong ), 'specialty_answers' => $speRepliesResult, 'current_user_responded' => $currentUserResponded, 'answer_was_correct' => $answerWasCorrect ); if( $currentUserResponded ) { /* @type $quizArticleDM eZContentObjectAttribute[] */ $quizArticleDM = eZContentObject::fetch( $quizId )->DataMap(); $mediaContent = $quizArticleDM["media_content"]->content(); $quizDM = eZContentObjectTreeNode::fetch( $mediaContent['relation_list'][0]['node_id'] )->DataMap(); $outputHandler = new eZXHTMLXMLOutput( $quizDM['commented_answer']->DataText, false ); $commentedAnswer = $outputHandler->outputText(); $response['commented_answer'] = $commentedAnswer; } return $response; }
public static function getAndStoreGPNotebookHS() { if(!self::featureIsActive("GPNotebook")) return null; $key = self::feature("GPNotebook", "key"); $iv = self::feature("GPNotebook", "iv"); $data = array(); $service = ESBFactory::getUserService(); $user = $service->form(); if ( $user && $user['data']['errorCode'] == 0 && !is_null($user['data']['profile']['userId']) ) { $data = array( "uump_id" => $user['data']['profile']['userId'], "salutations" => $user['data']['profile']['salutation'], "first_name" => $user['data']['profile']['firstName'], "last_name" => $user['data']['profile']['lastName'], "work_address_1" => $user['data']['profile']['addressLine1'], "work_address_2" => $user['data']['profile']['addressLine2'], "work_address_postcode" => $user['data']['profile']['postalCode'], "email_address" => $user['data']['profile']['emailAddress'], "job_title" => $user['data']['profile']['customerType'], "speciality" => $user['data']['profile']['userSpecialty'], "country" => $user['data']['profile']['countryOfRegistration'], "professional_registration_number" => $user['data']['profile']['licenseNumber'] ); } $gpNotebookHS = self::encodeGPNotebook( json_encode($data), $key, $iv ); if(MMUsers::getCurrentUserObject()) { MMUsers::getCurrentUserObject()->setGPNotebookHS($gpNotebookHS); MMUsers::getCurrentUserObject()->setCookieUserPreferences(); } return $gpNotebookHS; }
/** * @return bool */ protected function addToApplicationList() { if ( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) { $user = MMUsers::getCurrentUserObject(); if ( !$user ) { return false; } $applicationList = $user->getApplicationList(); if ( !is_array($applicationList) ) { $applicationList = array(); } $applicationList[] = $_REQUEST['id']; AppBarControl::instance()->store($applicationList); return true; } return false; }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl( &$node = null ) { $merckIni = ExternalLinkHandlerBase::iniMerck(); $user = MMUsers::getCurrentUserObject(); if ( !$user ) { self::redirectToErrorPage(); } $restUrl = $merckIni->variable( 'MdConsultSettings', 'RestUrl' ); eZLog::write( var_export( $restUrl, true ), 'md-consult.log' ); $apiKey = $merckIni->variable( 'MdConsultSettings', 'ApiKey' ); eZLog::write( var_export( $apiKey, true ), 'md-consult.log' ); $vendorKey = $merckIni->variable( 'MdConsultSettings', 'VendorKey' ); eZLog::write( var_export( $vendorKey, true ), 'md-consult.log' ); $params = array( "apikey" => $apiKey, "UserId" => $user->attribute( 'uuid' ), "VendorKey" => $vendorKey ); eZLog::write( var_export( $params, true ), 'md-consult.log' ); $curlRessource = curl_init( $restUrl ); $curlParams = array( CURLOPT_HEADER => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode( $params ), CURLOPT_HTTPHEADER => array( 'Content-type: application/json' ), CURLOPT_RETURNTRANSFER => true ); curl_setopt_array( $curlRessource, $curlParams ); $response = curl_exec( $curlRessource ); $out = json_decode( $response, true ); eZLog::write( var_export( $out, true ), 'md-consult.log' ); $validUser = isset( $out['errorCode'] ) && $out['errorCode'] == 0; $password = null; if ( $validUser ) { if ( isset( $out['userId'] ) ) { $user = $out['userId']; } else { self::redirectToErrorPage(); } if ( isset( $out['password'] ) ) { $password = $out['password']; } else { self::redirectToErrorPage(); } } else { self::redirectToErrorPage(); } $url = $merckIni->variable( 'MdConsultSettings', 'MdUrl' ); $searches = array( '<$md_user>', '<$md_password>' ); $replacements = array( $user, $password ); $url = str_replace( $searches, $replacements, $url ); return $url; }
/** * @param int $applicationId * @param int $season * @param bool $asObject * @return array|QuizPlayerScoring */ public static function fetchUserInSeason( $applicationId, $season, $asObject = true, $isLocalQuiz = true ) { $currentMMUser = MMUsers::getCurrentUserObject(); if( $currentMMUser ) { $params = array( 'uuid' => $currentMMUser->attribute( 'uuid' ), 'cluster_identifier' => ($isLocalQuiz) ? ClusterTool::clusterIdentifier() : '', 'application_id' => $applicationId, 'season' => $season, ); return self::fetchOneBy( $params, $asObject ); } return null; }
/** * @param boolean $alertBoxMessageReset * @return array */ public static function updateAlertBox($alertBoxMessageReset) { $user = MMUsers::getCurrentUserObject(); $result = array( 'Data' => array( 'Status' => 'Error' ) ); if ( !is_null( $alertBoxMessageReset ) ) { if ( $user instanceof MMUsers ) { $user->setPreference( 'alterboxMsgReset', (boolean) $alertBoxMessageReset ); } $result = array( 'Data' => array( 'Status' => 'OK' ) ); } return $result; }