/**
  * cancel action
  *
  * @return void
  */
 public function cancelAction()
 {
     if (!$this->div->isLoggedUserInGroup($this->settings['participantGroupId'])) {
         $this->addFlashMessage($this->div->translate('message.noParticipant', $this->extensionName), '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
         $this->redirect('list');
     }
     if ($this->request->hasArgument('offset')) {
         $offset = $this->request->getArgument('offset');
         if ($offset < 0) {
             $this->addFlashMessage($this->div->translate('message.pastEventError', $this->extensionName), '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
             $this->redirect('list', Null, Null, array('offset' => $offset));
         }
     }
     if (!$this->request->hasArgument('offset')) {
         $offset = 0;
     }
     $eventStartDate = $this->div->nextEventDate($offset);
     $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     if ($events->count() == 0) {
         $this->div->createEvent($eventStartDate);
         $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     }
     $eventParticipant = $this->participantRepository->findParticipant($events->getFirst()->getUid(), $this->div->getLoggedUserId());
     if ($eventParticipant->count() == 0) {
         $participant = new \PoiCom\PcEventScheduler\Domain\Model\Participant();
         $participant->setParticipantUserId($this->div->getLoggedUser());
         $participant->setAccept(FALSE);
         $events->getFirst()->addParticipant($participant);
         $this->eventRepository->update($events->getFirst());
     }
     if ($eventParticipant->count() > 0) {
         if ($eventParticipant->getFirst()->getAccept()) {
             $eventParticipant->getFirst()->setAccept(FALSE);
             $this->eventRepository->update($events->getFirst());
         }
     }
     $this->addFlashMessage($this->div->translate('message.canceledEvent', $this->extensionName), '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
     $this->redirect('list', Null, Null, array('offset' => $offset));
 }
 /**
  * Notifies participants for the next event
  *
  * @return void
  */
 public function notifyCommand()
 {
     $this->settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     $eventStartTime = $this->settings['eventStartTime'];
     $participantGroupId = $this->settings['participantGroupId'];
     $eventPageUid = $this->settings['eventPageUid'];
     $offset = 0;
     $eventStartDate = $this->div->nextEventDate($offset);
     $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     if ($events->count() == 0) {
         $this->div->createEvent($eventStartDate);
         $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     }
     if ($events->getFirst()->getActive()) {
         $this->initFrontend();
         $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
         $link = $cObj->typolink_URL(array('parameter' => "{$eventPageUid}", 'forceAbsoluteUrl' => 1));
         $acceptUrl = $link . "?&tx_pceventscheduler_pceventscheduler%5Baction%5D=accept";
         $cancelUrl = $link . "?&tx_pceventscheduler_pceventscheduler%5Baction%5D=cancel";
         $participantsUnknown = $this->participantRepository->findParticipantsUnknown($events->getFirst()->getUid(), $participantGroupId);
         if (isset($participantsUnknown)) {
             foreach ($participantsUnknown as $participantUnknown) {
                 $receiverEmail = $participantUnknown['email'];
                 $receiverName = $participantUnknown['name'];
                 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
                 $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                 $mail->setFrom($from);
                 $mail->setSubject($this->settings['notifyMailSubject']);
                 $mail->setTo($receiverEmail);
                 $mail->setBody(str_replace(array('###name###', '###eventdate###', '###eventtime###', '###eventlocation###', '###acceptlink###', '###cancellink###'), array($receiverName, $events->getFirst()->getStart()->format("d.m.Y"), $eventStartTime, $events->getFirst()->getLocation(), $acceptUrl, $cancelUrl), $this->settings['notifyMailBody']), 'text/html');
                 $mail->send();
             }
         }
     }
     return true;
 }
 /**
  * action delete
  *
  * @param \PoiCom\PcEventScheduler\Domain\Model\Participant $participant
  * @return void
  */
 public function deleteAction(\PoiCom\PcEventScheduler\Domain\Model\Participant $participant)
 {
     $this->addFlashMessage('The object was deleted. Please be aware that this action is publicly accessible unless you implement an access check. See http://wiki.typo3.org/T3Doc/Extension_Builder/Using_the_Extension_Builder#1._Model_the_domain', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
     $this->participantRepository->remove($participant);
     $this->redirect('list');
 }