/** * @test */ public function sendUserMessageReturnsFalseIfNoCustomMessageGiven() { $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event(); $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration(); $registration->setEmail('*****@*****.**'); $settings = array('notification' => array('senderEmail' => '*****@*****.**')); $result = $this->subject->sendUserMessage($event, $registration, $settings, MessageType::CUSTOM_NOTIFICATION, ''); $this->assertFalse($result); }
/** * 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); }
/** * Cancels 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 cancelRegistrationAction($reguid, $hmac) { /* @var $registration Registration */ list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkCancelRegistration($reguid, $hmac); if ($failed === false) { // Send notifications (must run before cancelling the registration) $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED); $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED); // First cancel depending registrations if ($registration->getAmountOfRegistrations() > 1) { $this->registrationService->cancelDependingRegistrations($registration); } // Finally cancel registration $this->registrationRepository->remove($registration); // Clear cache for configured pages $this->utilityService->clearCacheForConfiguredUids($this->settings); } $this->view->assign('messageKey', $messageKey); $this->view->assign('titleKey', $titleKey); }