/**
  * @test
  */
 public function confirmDependingRegistrationsConfirmsDependingRegistrations()
 {
     $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $foundRegistration1 = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $foundRegistration1->expects($this->any())->method('setConfirmed');
     $foundRegistration2 = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $foundRegistration2->expects($this->any())->method('setConfirmed');
     /** @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrations */
     $registrations = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     $registrations->attach($foundRegistration1);
     $registrations->attach($foundRegistration2);
     $registrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('findByMainRegistration', 'update'), array(), '', FALSE);
     $registrationRepository->expects($this->once())->method('findByMainRegistration')->will($this->returnValue($registrations));
     $registrationRepository->expects($this->exactly(2))->method('update');
     $this->inject($this->subject, 'registrationRepository', $registrationRepository);
     $this->subject->confirmDependingRegistrations($mockRegistration);
 }
 /**
  * Confirms the registration if possible and sends e-mails to admin and user
  *
  * @param int $reguid UID of registration
  * @param string $hmac HMAC for parameters
  *
  * @return void
  */
 public function confirmRegistrationAction($reguid, $hmac)
 {
     /* @var $registration Registration */
     list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkConfirmRegistration($reguid, $hmac);
     if ($failed === false) {
         $registration->setConfirmed(true);
         $this->registrationRepository->update($registration);
         $messageType = MessageType::REGISTRATION_CONFIRMED;
         if ($registration->getWaitlist()) {
             $messageType = MessageType::REGISTRATION_WAITLIST_CONFIRMED;
         }
         // Send notifications to user and admin
         $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, $messageType);
         $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, $messageType);
         // Confirm registrations depending on main registration if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->confirmDependingRegistrations($registration);
         }
     }
     // Redirect to payment provider if payment/redirect is enabled
     $paymentPid = (int) $this->settings['paymentPid'];
     if (!$failed && $paymentPid > 0 && $this->registrationService->redirectPaymentEnabled($registration)) {
         $this->uriBuilder->reset()->setTargetPageUid($paymentPid)->setUseCacheHash(false);
         $uri = $this->uriBuilder->uriFor('redirect', ['registration' => $registration, 'hmac' => $this->hashService->generateHmac('redirectAction-' . $registration->getUid())], 'Payment', 'sfeventmgt', 'Pipayment');
         $this->redirectToUri($uri);
     }
     $this->view->assign('messageKey', $messageKey);
     $this->view->assign('titleKey', $titleKey);
 }
 /**
  * Confirms the registration if possible and sends e-mails to admin and user
  *
  * @param int $reguid UID of registration
  * @param string $hmac HMAC for parameters
  *
  * @return void
  */
 public function confirmRegistrationAction($reguid, $hmac)
 {
     /* @var $registration Registration */
     list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkConfirmRegistration($reguid, $hmac);
     if ($failed === FALSE) {
         $registration->setConfirmed(TRUE);
         $this->registrationRepository->update($registration);
         // Send notifications to user and admin
         $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         // Confirm registrations depending on main registration if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->confirmDependingRegistrations($registration);
         }
     }
     $this->view->assign('messageKey', $messageKey);
     $this->view->assign('titleKey', $titleKey);
 }
 /**
  * Confirms the registration if possible and sends e-mails to admin and user
  *
  * @param int $reguid UID of registration
  * @param string $hmac HMAC for parameters
  *
  * @return void
  */
 public function confirmRegistrationAction($reguid, $hmac)
 {
     /* @var $registration Registration */
     $registration = NULL;
     $failed = FALSE;
     $messageKey = 'event.message.confirmation_successful';
     $titleKey = 'confirmRegistration.title.successful';
     if (!$this->hashService->validateHmac('reg-' . $reguid, $hmac)) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_wrong_hmac';
         $titleKey = 'confirmRegistration.title.failed';
     } else {
         $registration = $this->registrationRepository->findByUid($reguid);
     }
     if (!$failed && is_null($registration)) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_registration_not_found';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if (!$failed && $registration->getConfirmationUntil() < new \DateTime()) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_confirmation_until_expired';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if (!$failed && $registration->getConfirmed() === TRUE) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_already_confirmed';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if ($failed === FALSE) {
         $registration->setConfirmed(TRUE);
         $this->registrationRepository->update($registration);
         // Send notifications to user and admin
         $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         // Confirm registrations depending on main registration if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->confirmDependingRegistrations($registration);
         }
     }
     $this->view->assign('messageKey', $messageKey);
     $this->view->assign('titleKey', $titleKey);
 }