/**
  * Returns an array of filenames to attach to notifications
  *
  * Attachments must be configured as following (example for "registrationNew"):
  *
  *  registrationNew {
  *    attachments {
  *      user {
  *        fromFiles {
  *          1 = fileadmin/path-to-attachment.pdf
  *        }
  *        fromEventProperty {
  *          1 = files
  *          2 = image
  *        }
  *        fromRegistrationProperty {
  *          1 = propertyOfRegistration
  *        }
  *      }
  *      admin {
  *        fromFiles =
  *        fromEventProperty =
  *        fromRegistrationProperty =
  *      }
  *   }
  * }
  *
  * @param array $settings
  * @param Registration $registration
  * @param int $messageType
  * @param string $messageRecipient
  *
  * @return array Array with absolute filenames to attachments
  */
 public function getAttachments($settings, $registration, $messageType, $messageRecipient)
 {
     $attachments = [];
     $settingPath = '';
     switch ($messageType) {
         case MessageType::REGISTRATION_NEW:
             $settingPath = 'registrationNew';
             break;
         case MessageType::REGISTRATION_WAITLIST_NEW:
             $settingPath = 'registrationWaitlistNew';
             break;
         case MessageType::REGISTRATION_CONFIRMED:
             $settingPath = 'registrationConfirmed';
             break;
         case MessageType::REGISTRATION_WAITLIST_CONFIRMED:
             $settingPath = 'registrationWaitlistConfirmed';
             break;
     }
     if (isset($settings['notification'][$settingPath]['attachments'][$messageRecipient])) {
         // Attachments globally from TypoScript
         $config = $settings['notification'][$settingPath]['attachments'][$messageRecipient];
         $attachments = $this->getFileAttachments($config);
         // Attachments from Event properties
         $eventAttachments = $this->getObjectAttachments($config['fromEventProperty'], $registration->getEvent());
         $attachments = array_merge($attachments, $eventAttachments);
         // Attachments from Registration properties
         $registrationAttachments = $this->getObjectAttachments($config['fromRegistrationProperty'], $registration);
         $attachments = array_merge($attachments, $registrationAttachments);
     }
     return $attachments;
 }
 /**
  * Returns the hmac for the given registration in order to cancel the registration
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  *
  * @return array
  */
 public function render($registration)
 {
     $result = '';
     if ($registration) {
         $result = $this->hashService->generateHmac('reg-' . $registration->getUid());
     }
     return $result;
 }
 /**
  * Duplicates (all public accessable properties) the given registration the
  * amount of times configured in amountOfRegistrations
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  *
  * @return void
  */
 public function createDependingRegistrations($registration)
 {
     $registrations = $registration->getAmountOfRegistrations();
     for ($i = 1; $i <= $registrations - 1; $i++) {
         /** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $newReg */
         $newReg = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration');
         $properties = ObjectAccess::getGettableProperties($registration);
         foreach ($properties as $propertyName => $propertyValue) {
             ObjectAccess::setProperty($newReg, $propertyName, $propertyValue);
         }
         $newReg->setMainRegistration($registration);
         $newReg->setAmountOfRegistrations(1);
         $newReg->setIgnoreNotifications(TRUE);
         $this->registrationRepository->add($newReg);
     }
 }
 /**
  * Validates the given registration according to required fields set in plugin
  * settings. For boolean fields, the booleanValidator is used and it is assumed,
  * that boolean fields must have the value "TRUE" (for checkboxes)
  *
  * @param Registration $value Registration
  *
  * @return bool
  */
 protected function isValid($value)
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'SfEventMgt', 'Pievent');
     // If no required fields are set, then the registration is valid
     if ($settings['registration']['requiredFields'] === '' || !isset($settings['registration']['requiredFields'])) {
         return TRUE;
     }
     $requiredFields = array_map('trim', explode(',', $settings['registration']['requiredFields']));
     $result = TRUE;
     foreach ($requiredFields as $requiredField) {
         if ($value->_hasProperty($requiredField)) {
             $validator = $this->getValidator(gettype($value->_getProperty($requiredField)));
             /** @var \TYPO3\CMS\Extbase\Error\Result $validationResult */
             $validationResult = $validator->validate($value->_getProperty($requiredField));
             if ($validationResult->hasErrors()) {
                 $result = FALSE;
                 foreach ($validationResult->getErrors() as $error) {
                     $this->result->forProperty($requiredField)->addError($error);
                 }
             }
         }
     }
     return $result;
 }
Example #5
0
 /**
  * @test
  */
 public function getRegistrationPossibleReturnsFalseIfEventMaxParticipantsReached()
 {
     $registration = new Registration();
     $registration->setFirstname('John');
     $registration->setLastname('Doe');
     $startdate = new \DateTime();
     $startdate->add(\DateInterval::createFromDateString('tomorrow'));
     $this->subject->setStartdate($startdate);
     $this->subject->setMaxParticipants(1);
     $this->subject->addRegistration($registration);
     $this->assertFalse($this->subject->getRegistrationPossible());
 }
 /**
  * Returns the rendered HTML for the given template
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param string $template Template
  * @param array $settings Settings
  *
  * @return string
  */
 protected function getNotificationBody($event, $registration, $template, $settings)
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
     $emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $emailView->setFormat('html');
     $layoutRootPaths = $this->fluidStandaloneService->getTemplateFolders('layout');
     $partialRootPaths = $this->fluidStandaloneService->getTemplateFolders('partial');
     if (TYPO3_MODE === 'BE' && $registration->getLanguage() !== '') {
         // Temporary set Language of current BE user to given language
         $GLOBALS['BE_USER']->uc['lang'] = $registration->getLanguage();
         $emailView->getRequest()->setControllerExtensionName('SfEventMgt');
     }
     $emailView->setLayoutRootPaths($layoutRootPaths);
     $emailView->setPartialRootPaths($partialRootPaths);
     $emailView->setTemplatePathAndFilename($this->fluidStandaloneService->getTemplatePath($template));
     $emailView->assignMultiple(['event' => $event, 'registration' => $registration, 'settings' => $settings, 'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid()), 'reghmac' => $this->hashService->appendHmac((string) $registration->getUid())]);
     $emailBody = $emailView->render();
     return $emailBody;
 }
 /**
  * Checks, if the registration can successfully be created. Note, that
  * $result is passed by reference!
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param RegistrationResult $result Result
  *
  * @return bool
  */
 protected function checkRegistrationSuccess(Event $event, Registration $registration, &$result)
 {
     $success = TRUE;
     if ($event->getEnableRegistration() === FALSE) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_NOT_ENABLED;
     } elseif ($event->getRegistrationDeadline() != NULL && $event->getRegistrationDeadline() < new \DateTime()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED;
     } elseif ($event->getStartdate() < new \DateTime()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED;
     } elseif ($event->getRegistration()->count() >= $event->getMaxParticipants() && $event->getMaxParticipants() > 0) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS;
     } elseif ($event->getFreePlaces() < $registration->getAmountOfRegistrations() && $event->getMaxParticipants() > 0) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES;
     } elseif ($event->getMaxRegistrationsPerUser() < $registration->getAmountOfRegistrations()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED;
     }
     return $success;
 }
 /**
  * Returns the payment Uri for the given action and registration
  *
  * @param string $action
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationException
  */
 protected function getPaymentUriForAction($action, $registration)
 {
     $this->uriBuilder->setCreateAbsoluteUri(true)->setUseCacheHash(false);
     return $this->uriBuilder->uriFor($action, ['registration' => $registration, 'hmac' => $this->hashService->generateHmac($action . 'Action-' . $registration->getUid())], 'Payment', 'sfeventmgt', 'Pipayment');
 }
 /**
  * Returns the rendered HTML for the given template
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param string $template Template
  * @param array $settings Settings
  *
  * @return string
  */
 protected function getNotificationBody($event, $registration, $template, $settings)
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
     $emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $emailView->setFormat('html');
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $templateRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['templateRootPath']);
     $layoutRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['layoutRootPath']);
     $partialRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['partialRootPath']);
     $emailView->setLayoutRootPath($layoutRootPath);
     $emailView->setPartialRootPath($partialRootPath);
     $emailView->setTemplatePathAndFilename($templateRootPath . $template);
     $emailView->assignMultiple(array('event' => $event, 'registration' => $registration, 'settings' => $settings, 'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid()), 'reghmac' => $this->hashService->appendHmac((string) $registration->getUid())));
     $emailBody = $emailView->render();
     return $emailBody;
 }
Example #10
0
 /**
  * Returns the requested field from the given registration. If the field is a DateTime object,
  * a formatted date string is returned
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration
  * @param string $field
  * @return string
  */
 protected function getFieldValue($registration, $field)
 {
     $value = $registration->_getCleanProperty($field);
     if ($value instanceof \DateTime) {
         $value = $value->format('d.m.Y');
     }
     return $value;
 }
 /**
  * Returns, if payment redirect for the payment method is enabled
  *
  * @param Registration $registration
  * @return bool
  */
 public function redirectPaymentEnabled($registration)
 {
     if ($registration->getEvent()->getEnablePayment() === false) {
         return false;
     }
     /** @var AbstractPayment $paymentInstance */
     $paymentInstance = $this->paymentService->getPaymentInstance($registration->getPaymentmethod());
     if ($paymentInstance !== null && $paymentInstance->isRedirectEnabled()) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * @test
  * @return void
  */
 public function setPaymentReferenceSetsPaymentmethod()
 {
     $this->subject->setPaymentReference('paid-1234567890');
     $this->assertEquals('paid-1234567890', $this->subject->getPaymentReference());
 }
 /**
  * @test
  * @return void
  */
 public function ignoreNotificationsCanBeSet()
 {
     $this->subject->setIgnoreNotifications(TRUE);
     $this->assertTrue($this->subject->getIgnoreNotifications());
 }