Example #1
0
 /**
  * @test
  */
 public function removeSubscriberFromObjectStorageHoldingSubscribers()
 {
     $subscriber = new Tx_WoehrlSeminare_Domain_Model_Subscriber();
     $localObjectStorage = new Tx_Extbase_Persistence_ObjectStorage();
     $localObjectStorage->attach($subscriber);
     $localObjectStorage->detach($subscriber);
     $this->fixture->addSubscriber($subscriber);
     $this->fixture->removeSubscriber($subscriber);
     $this->assertEquals($localObjectStorage, $this->fixture->getSubscribers());
 }
 /**
  * action create
  * // gets validated automatically if name is like this: ...Tx_WoehrlSeminare_Domain_Validator_SubscriberValidator
  *
  * @param Tx_WoehrlSeminare_Domain_Model_Subscriber $newSubscriber
  * @param Tx_WoehrlSeminare_Domain_Model_Event $event
  * @param Tx_WoehrlSeminare_Domain_Model_Category $category
  * @validate $event Tx_WoehrlSeminare_Domain_Validator_EventSubscriptionAllowedValidator
  * @ignorevalidation $category
  * @return void
  */
 public function createAction(Tx_WoehrlSeminare_Domain_Model_Subscriber $newSubscriber, Tx_WoehrlSeminare_Domain_Model_Event $event, Tx_WoehrlSeminare_Domain_Model_Category $category = NULL)
 {
     // add subscriber to event
     $editcode = hash('sha256', rand() . $newSubscriber->getEmail() . time());
     $newSubscriber->setEditcode($editcode);
     //$return = $this->subscriberRepository->insertKostenstelleHaus($newSubscriber);
     $budget = new Tx_WoehrlSeminare_Domain_Model_Kostenstelle();
     $budget->setEditcode($newSubscriber->getEditcode());
     $budget->setPreis($newSubscriber->getEvent()->getPreis());
     $budget->setKostenstelle($newSubscriber->getKostenstelle());
     $budget->setHaus($newSubscriber->getHaus());
     $budget->setEmail($newSubscriber->getEmail());
     $budget->setVorname($newSubscriber->getVorname());
     $budget->setName($newSubscriber->getName());
     $budget->setEventtitle($newSubscriber->getEvent()->getTitle());
     // add
     $this->kostenstelleRepository->add($budget);
     //TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($budget);
     //$kostenstellen = $this->kostenstelleRepository->findAll();
     $persistenceManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
     $persistenceManager->persistAll();
     $event->addSubscriber($newSubscriber);
     // Genius Bar Specials:
     if ($event->getGeniusBar()) {
         $event->setTitle($category->getTitle());
         $event->setDescription($category->getDescription());
     }
     // send email(s)
     $helper['now'] = time();
     // rfc2445.txt: lines SHOULD NOT be longer than 75 octets --> line folding
     $helper['description'] = $this->foldline($this->html2rest($event->getDescription()));
     // location may be empty...
     if (is_object($event->getLocation())) {
         $helper['location'] = $event->getLocation()->getName();
         $helper['locationics'] = $this->foldline($event->getLocation()->getName());
     }
     $helper['nameto'] = strtolower(str_replace(array(',', ' '), array('', '-'), $newSubscriber->getName()));
     // startDateTime may never be empty
     $helper['start'] = $event->getStartDateTime()->getTimestamp();
     // endDateTime may be empty
     if ($event->getEndDateTime() instanceof DateTime && $event->getStartDateTime() != $event->getEndDateTime()) {
         $helper['end'] = $event->getEndDateTime()->getTimestamp();
     }
     if ($event->isAllDay()) {
         $helper['allDay'] = 1;
     }
     //TYPO3\CMS\Extbase\Utility\debuggerUtility::var_dump($this->settings['emailToContact']['sendEmailOnEveryBooking']);
     //die;
     // email to customer
     $this->sendTemplateEmail(array($newSubscriber->getEmail() => $newSubscriber->getName()), array($event->getContact()->getEmail() => $event->getContact()->getName()), 'Ihre Anmeldung: ' . $event->getTitle(), 'Subscribe', array('event' => $event, 'subscriber' => $newSubscriber, 'helper' => $helper, 'settings' => $this->settings, 'attachIcsInvitation' => TRUE));
     // send to contact, if maximum is reached and TS setting is present:
     if ($this->settings['emailToContact']['sendEmailOnMaximumReached'] && $this->subscriberRepository->countAllByEvent($event) + $newSubscriber->getNumber() == $event->getMaxSubscriber()) {
         $helper['nameto'] = strtolower(str_replace(array(',', ' '), array('', '-'), $event->getContact()->getName()));
         // email to event owner
         $this->sendTemplateEmail(array($event->getContact()->getEmail() => $event->getContact()->getName()), array($this->settings['senderEmailAddress'] => Tx_Extbase_Utility_Localization::translate('tx_woehrlseminare.be.eventmanagement', 'woehrl_seminare') . ' - noreply'), 'Veranstaltung ausgebucht: ' . $event->getTitle(), 'Maximumreached', array('event' => $event, 'subscribers' => $event->getSubscribers(), 'helper' => $helper, 'settings' => $this->settings, 'attachSubscriberAsCsv' => TRUE, 'attachIcsInvitation' => TRUE));
     } else {
         if ($this->settings['emailToContact']['sendEmailOnEveryBooking']) {
             $helper['nameto'] = strtolower(str_replace(array(',', ' '), array('', '-'), $event->getContact()->getName()));
             // email to event owner
             $this->sendTemplateEmail(array($event->getContact()->getEmail() => $event->getContact()->getName()), array($this->settings['senderEmailAddress'] => Tx_Extbase_Utility_Localization::translate('tx_woehrlseminare.be.eventmanagement', 'woehrl_seminare') . ' - noreply'), 'Veranstaltung gebucht: ' . $event->getTitle(), 'Newsubscriber', array('event' => $event, 'newsubscriber' => $newSubscriber, 'subscribers' => $event->getSubscribers(), 'helper' => $helper, 'settings' => $this->settings, 'attachSubscriberAsCsv' => FALSE, 'attachIcsInvitation' => FALSE));
         }
     }
     // reset session data
     $this->setSessionData('editcode', '');
     // we changed the event inside the repository and have to
     // update the repo manually as of TYPO3 6.1
     $this->eventRepository->update($event);
     // clear cache on all cached list pages
     $this->clearAllEventListCache($event->getGeniusBar());
     $this->view->assign('event', $event);
     $this->view->assign('category', $category);
     $this->view->assign('newSubscriber', $newSubscriber);
 }