/** * Validation of given Params * * @param $params * @return bool */ public function isValid($params) { $gp = t3lib_div::_GP('tx_powermail_pi1'); $formUid = $gp['form']; $form = $this->formsRepository->findByUid($formUid); if (!method_exists($form, 'getPages')) { return $this->isValid; } foreach ($form->getPages() as $page) { // every page in current form foreach ($page->getFields() as $field) { // every field in current page // if not a mandatory field if (!$field->getMandatory()) { continue; } // set error if (is_array($params[$field->getUid()])) { $empty = 1; foreach ($params[$field->getUid()] as $value) { if (strlen($value)) { $empty = 0; break; } } if ($empty) { $this->addError('mandatory', $field->getUid()); $this->isValid = false; } } else { if (!strlen($params[$field->getUid()])) { $this->addError('mandatory', $field->getUid()); $this->isValid = false; } } } } return $this->isValid; }
public function checkEvent($params, $obj) { $this->initializeAction(); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'woehrlSeminare', 'Eventlist'); //~ t3lib_utility_Debug::debug($params, 'addInformation: params: '); $gp = t3lib_div::_GP('tx_powermail_pi1'); $formUid = $gp['form']; $form = $this->formsRepository->findByUid($formUid); if (!method_exists($form, 'getPages')) { return $this->isValid = FALSE; } foreach ($form->getPages() as $page) { // every page in current form foreach ($page->getFields() as $field) { // every field in current page switch ($field->getMarker()) { case 'action': $action = $params[$field->getUid()]; break; case 'editcode': $editcode = $params[$field->getUid()]; break; case 'event': $formIdEvent = $field->getUid(); $eventId = $params[$formIdEvent]; break; case 'eventtitle': $formIdEventtitle = $field->getUid(); break; } } } //~ t3lib_utility_Debug::debug($editcode, 'checkEvent: editcode... '); switch ($action) { case 'delete': //~ $subscriber = $this->subscriberRepository->findAllByFeuser($frameworkConfiguration['persistence']['storagePid'])->getFirst(); $subscriber = $this->subscriberRepository->findAllByEditcode($editcode, $frameworkConfiguration['persistence']['storagePid'])->getFirst(); if (empty($subscriber)) { t3lib_utility_Debug::debug($subscriber, 'checkEvent: NO subscriber found... '); $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } //~ t3lib_utility_Debug::debug($subscriber, 'saveSubscription: delete... '); $event = $this->eventRepository->findByUid($eventId); if (empty($event)) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } $event->removeSubscriber($subscriber); break; case 'new': if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } break; default: return; } return; //~ t3lib_utility_Debug::debug($eventId , 'checkEvent: eventId'); if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } return; }