/**
  * Create Email Body
  *
  * @param array $email Array with all needed mail information
  * @return bool
  */
 protected function createEmailBody($email)
 {
     $standaloneView = TemplateUtility::getDefaultStandAloneView();
     $standaloneView->getRequest()->setControllerName('Form');
     $standaloneView->setTemplatePathAndFilename(TemplateUtility::getTemplatePath($email['template'] . '.html'));
     $standaloneView->setLayoutRootPaths(TemplateUtility::getTemplateFolders('layout'));
     $standaloneView->setPartialRootPaths(TemplateUtility::getTemplateFolders('partial'));
     // variables
     $variablesWithMarkers = $this->mailRepository->getVariablesWithMarkersFromMail($this->mail);
     $standaloneView->assignMultiple($variablesWithMarkers);
     $standaloneView->assignMultiple($this->mailRepository->getLabelsWithMarkersFromMail($this->mail));
     $standaloneView->assignMultiple(array('variablesWithMarkers' => ArrayUtility::htmlspecialcharsOnArray($variablesWithMarkers), 'powermail_all' => TemplateUtility::powermailAll($this->mail, 'mail', $this->settings, $this->type), 'powermail_rte' => $email['rteBody'], 'marketingInfos' => SessionUtility::getMarketingInfos(), 'mail' => $this->mail, 'email' => $email, 'settings' => $this->settings));
     if (!empty($email['variables'])) {
         $standaloneView->assignMultiple($email['variables']);
     }
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRender', array($standaloneView, $email, $this->mail, $this->settings));
     $body = $standaloneView->render();
     $this->mail->setBody($body);
     return $body;
 }
 /**
  * Get value from session if defined in TypoScript
  *
  * @return string
  */
 protected function getFromSession()
 {
     $value = '';
     $sessionValues = SessionUtility::getSessionValuesForPrefill($this->settings);
     if (!empty($sessionValues) && count($sessionValues)) {
         foreach ($sessionValues as $marker => $valueInSession) {
             if ($this->getMarker() === $marker) {
                 return $valueInSession;
             }
         }
     }
     return $value;
 }
Exemple #3
0
 /**
  * Marketing Tracking Action
  *
  * @param string $referer Referer
  * @param int $language Frontend Language Uid
  * @param int $pid Page Id
  * @param int $mobileDevice Is mobile device?
  * @return void
  */
 public function marketingAction($referer = null, $language = 0, $pid = 0, $mobileDevice = 0)
 {
     SessionUtility::storeMarketingInformation($referer, $language, $pid, $mobileDevice);
 }
 /**
  * setPathAndFilename Test
  *
  * @param string $code Given from input field (should be a string)
  * @param string $codeInSession (string or empty)
  * @param bool $expectedResult
  * @dataProvider validCodeReturnsBoolDataProvider
  * @test
  */
 public function validCodeReturnsBool($code, $codeInSession, $expectedResult)
 {
     $this->initializeTsfe();
     $field = new Field();
     $field->_setProperty('uid', 123);
     SessionUtility::setCaptchaSession($codeInSession, 123);
     $this->assertSame($expectedResult, $this->generalValidatorMock->_call('validCode', $code, $field, false));
 }
 /**
  * action create
  *
  * @param \S3b0\ProjectRegistration\Domain\Model\Dto\ProjectPersonsDto $dto
  * @ignorevalidation $dto
  *
  * @dontverifyrequesthash
  *
  * @return void
  */
 public function createAction(Model\Dto\ProjectPersonsDto $dto)
 {
     // Add endUser to personRepository
     $this->personRepository->add($dto->getEndUser());
     // Add registrant to personRepository (if not existing feUser reference)
     if ($dto->getRegistrant()->getFeUser() instanceof \Ecom\EcomToolbox\Domain\Model\User) {
         $registrant = $this->personRepository->findOneByFeUser($dto->getRegistrant()->getFeUser());
         if ($registrant instanceof Model\Person) {
             $this->updateRegistrantIfFeUserRecordDiffers($registrant);
             $dto->setRegistrant($registrant);
         } else {
             $dto->setRegistrant(new Model\Person($dto->getRegistrant()->getFeUser()));
             $this->personRepository->add($dto->getRegistrant());
         }
     } else {
         if ($registrant = $this->personRepository->findOneByMandatoryFields($dto->getRegistrant())) {
             $dto->setRegistrant($registrant);
         } else {
             $this->personRepository->add($dto->getRegistrant());
         }
     }
     /**
      * Persist Persons in order to get corresponding uid to link to in Project
      *
      * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager $persistenceManager
      */
     $persistenceManager = CoreUtility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
     $persistenceManager->persistAll();
     // Add property values
     $propertyValues = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     if (is_array($dto->getPropertyValues()) && count($dto->getPropertyValues())) {
         foreach ($dto->getPropertyValues() as $propertyValue) {
             if (($value = $this->productPropertyValueRepository->findByUid($propertyValue)) instanceof Model\ProductPropertyValue) {
                 $propertyValues->attach($value);
             }
         }
     }
     $project = $dto->getProject();
     $project->setDateOfExpiry();
     $project->setRegistrant($dto->getRegistrant());
     $project->setEndUser($dto->getEndUser());
     $project->setPropertyValues($propertyValues);
     // Persist Project to get the uid to use as Project# in emails
     $this->projectRepository->add($project);
     $persistenceManager->persistAll();
     $noReply = null;
     if ($this->settings['mail']['noReplyEmail'] && CoreUtility\GeneralUtility::validEmail($this->settings['mail']['noReplyEmail'])) {
         $noReply = [$this->settings['mail']['noReplyEmail'] => $this->settings['mail']['noReplyName'] ?: $this->settings['mail']['senderName']];
     }
     $addressees = $this->getAddressees(true, $project->getAddressee()) ?: CoreUtility\MailUtility::getSystemFrom();
     $carbonCopyReceivers = [];
     if ($this->settings['mail']['carbonCopy']) {
         foreach (explode(',', $this->settings['mail']['carbonCopy']) as $carbonCopyReceiver) {
             $tokens = CoreUtility\GeneralUtility::trimExplode(' ', $carbonCopyReceiver, true, 2);
             if (CoreUtility\GeneralUtility::validEmail($tokens[0])) {
                 $carbonCopyReceivers[$tokens[0]] = $tokens[1];
             }
         }
     }
     /** @var \TYPO3\CMS\Core\Mail\MailMessage $mailToSender */
     $mailToSender = CoreUtility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
     $mailToSender->setContentType('text/html');
     /**
      * Email to sender
      */
     $mailToSender->setFrom($noReply ?: CoreUtility\MailUtility::getSystemFrom())->setTo([$dto->getRegistrant()->getEmail() => $dto->getRegistrant()->getName()])->setSubject($this->settings['mail']['projectRegisteredConfirmationSubject'] ?: (Lang::translate('mail_project_registered_confirmation_subject', $this->extensionName) ?: 'Your project registration request'))->setBody($this->getStandAloneTemplate(CoreUtility\ExtensionManagementUtility::siteRelPath(CoreUtility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName)) . 'Resources/Private/Templates/Email/ProjectRegisteredConfirmation.html', ['settings' => $this->settings, 'submitted' => $dto, 'addressees' => $this->getAddressees()]))->send();
     /** @var \TYPO3\CMS\Core\Mail\MailMessage $mailToSender */
     $mailToReceiver = CoreUtility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
     $mailToReceiver->setContentType('text/html');
     /**
      * Email to receiver (notification mail)
      */
     if ($this->settings['mail']['noReplyEmail'] && CoreUtility\GeneralUtility::validEmail($this->settings['mail']['noReplyEmail'])) {
         $from = [$this->settings['mail']['noReplyEmail'] => ($this->settings['mail']['noReplyName'] ?: $this->settings['mail']['senderName']) . ' - project registration'];
     } else {
         $from = ['*****@*****.**' => 'ecom instruments GmbH - project registration'];
     }
     $mailToReceiver->setTo($addressees)->setCc($carbonCopyReceivers)->setFrom($from)->setSubject(($this->settings['mail']['projectRegisteredInfoSubject'] ?: (Lang::translate('mail_project_registered_info_subject', $this->extensionName) ?: 'New project registration submitted')) . ($dto->getRegistrant()->getFeUserGroups() && in_array($this->settings['certifiedUsersUserGroup'], $dto->getRegistrant()->getFeUserGroups()) ? ' » ' . Lang::translate('user_certified', $this->extensionName) : ' » ' . Lang::translate('user_default', $this->extensionName)) . " #{$project->getUid()}")->setBody($this->getStandAloneTemplate(CoreUtility\ExtensionManagementUtility::siteRelPath(CoreUtility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName)) . 'Resources/Private/Templates/Email/ProjectRegisteredInfo.html', ['settings' => $this->settings, 'submitted' => $dto, 'addressees' => $this->getAddressees(), 'marketingInformation' => SessionUtility::getMarketingInfos()]))->send();
     $this->internalRedirect('submitted', ['project' => $dto->getProject()]);
 }
 /**
  * Check if given code is correct
  *
  * @param string $code String to compare
  * @param Field $field String to compare
  * @param bool $clearSession
  * @return boolean
  */
 public function validCode($code, $field, $clearSession = true)
 {
     if ((int) $code === SessionUtility::getCaptchaSession($field->getUid()) && !empty($code)) {
         if ($clearSession) {
             SessionUtility::setCaptchaSession('', $field->getUid());
         }
         return true;
     }
     return false;
 }
 /**
  * Start different checks to increase spam indicator
  *
  * @param Mail $mail
  * @return void
  */
 protected function runSpamPreventationMethods($mail)
 {
     $settingsSpamShieldIndicator = $this->settings['spamshield.']['indicator.'];
     $this->honeypodCheck($settingsSpamShieldIndicator['honeypod']);
     $this->linkCheck($mail, $settingsSpamShieldIndicator['link'], $settingsSpamShieldIndicator['linkLimit']);
     $this->nameCheck($mail, $settingsSpamShieldIndicator['name']);
     $this->sessionCheck($settingsSpamShieldIndicator['session'], SessionUtility::getFormStartFromSession($mail->getForm()->getUid(), $this->settings));
     $this->uniqueCheck($mail, $settingsSpamShieldIndicator['unique']);
     $this->blacklistStringCheck($mail, $settingsSpamShieldIndicator['blacklistString']);
     $this->blacklistIpCheck($settingsSpamShieldIndicator['blacklistIp'], GeneralUtility::getIndpEnv('REMOTE_ADDR'));
 }
 /**
  * Get value from session if defined in TypoScript
  *
  * @return string
  */
 protected function getFromSession()
 {
     $selected = false;
     $sessionValues = SessionUtility::getSessionValuesForPrefill($this->settings);
     if (!empty($sessionValues) && count($sessionValues)) {
         foreach ($sessionValues as $marker => $valueInSession) {
             if ($this->getMarker() === $marker) {
                 if ($valueInSession === $this->options[$this->index]['value'] || $valueInSession === $this->options[$this->index]['label']) {
                     $selected = true;
                 }
             }
         }
     }
     return $selected;
 }