/**
  * Notify action
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param string $customNotification CustomNotification
  *
  * @return void
  */
 public function notifyAction(Event $event, $customNotification)
 {
     $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
     $result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings);
     $this->notificationService->createCustomNotificationLogentry($event, $customNotifications[$customNotification], $result);
     $this->redirect('list', 'Administration', 'SfEventMgt', array('demand' => NULL, 'messageId' => 2));
 }
 /**
  * @test
  * @return void
  */
 public function createCustomNotificationLogentryCreatesLog()
 {
     $mockLogRepo = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\CustomNotificationRepository', array('add'), array(), '', FALSE);
     $mockLogRepo->expects($this->once())->method('add');
     $this->inject($this->subject, 'customNotificationLogRepository', $mockLogRepo);
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $this->subject->createCustomNotificationLogentry($event, 'A description', 1);
 }
 /**
  * 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);
 }