Ejemplo n.º 1
0
 /**
  * Validation of given Params
  *
  * @param Tx_WoehrlSeminare_Domain_Model_Subscriber $newSubscriber
  * @return bool
  */
 public function isValid($newSubscriber)
 {
     if (strlen($newSubscriber->getName()) < 3) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_name', 1000);
         $this->result->forProperty('name')->addError($error);
         // usually $this->addError is enough but this doesn't set the CSS errorClass in the form-viewhelper :-(
         //			$this->addError('val_name', 1000);
         $this->isValid = FALSE;
     }
     if (!t3lib_div::validEmail($newSubscriber->getEmail())) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_email', 1100);
         $this->result->forProperty('email')->addError($error);
         //			$this->addError('val_email', 1100);
         $this->isValid = FALSE;
     }
     if (strlen($newSubscriber->getCustomerid()) > 0 && filter_var($newSubscriber->getCustomerid(), FILTER_VALIDATE_INT) === FALSE) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_customerid', 1110);
         $this->result->forProperty('customerid')->addError($error);
         //			$this->addError('val_customerid', 1110);
         $this->isValid = FALSE;
     }
     if (strlen($newSubscriber->getNumber()) == 0 || filter_var($newSubscriber->getNumber(), FILTER_VALIDATE_INT) === FALSE || $newSubscriber->getNumber() < 1) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_number', 1120);
         $this->result->forProperty('number')->addError($error);
         //			$this->addError('val_number', 1120);
         $this->isValid = FALSE;
     } else {
         $event = $newSubscriber->getEvent();
         // limit reached already --> overbooked
         if ($this->subscriberRepository->countAllByEvent($event) + $newSubscriber->getNumber() > $event->getMaxSubscriber()) {
             $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_number', 1130);
             $this->result->forProperty('number')->addError($error);
             //			    $this->addError('val_number', 1130);
             $this->isValid = FALSE;
         }
     }
     if ($newSubscriber->getEditcode() != $this->getSessionData('editcode')) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_editcode', 1140);
         $this->result->forProperty('editcode')->addError($error);
         //			$this->addError('val_editcode', 1140);
         $this->isValid = FALSE;
     }
     return $this->isValid;
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function setEmailForStringSetsEmail()
 {
     $this->fixture->setEmail('Conceived at T3CON10');
     $this->assertSame('Conceived at T3CON10', $this->fixture->getEmail());
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }