Exemplo n.º 1
0
 /**
  * Attaches a registration to this event.
  *
  * @param tx_seminars_Model_Registration $registration
  *        the registration to attach
  *
  * @return void
  */
 public function attachRegistration(tx_seminars_Model_Registration $registration)
 {
     $registration->setEvent($this);
     $this->getRegistrations()->add($registration);
 }
 /**
  * Fills $registration with $formData (as submitted via the registration form).
  *
  * This function sets all necessary registration data except for three
  * things:
  * - event
  * - user
  * - whether the registration is on the queue
  *
  * Note: This functions does not check whether registration is possible at all.
  *
  * @param tx_seminars_Model_Registration $registration the registration to fill, must already have an event assigned
  * @param array $formData the raw data submitted via the form, may be empty
  *
  * @return void
  */
 protected function setRegistrationData(tx_seminars_Model_Registration $registration, array $formData)
 {
     $event = $registration->getEvent();
     $seats = isset($formData['seats']) ? (int) $formData['seats'] : 1;
     if ($seats < 1) {
         $seats = 1;
     }
     $registration->setSeats($seats);
     $registeredThemselves = isset($formData['registered_themselves']) ? (bool) $formData['registered_themselves'] : FALSE;
     $registration->setRegisteredThemselves($registeredThemselves);
     $availablePrices = $event->getAvailablePrices();
     if (isset($formData['price']) && isset($availablePrices[$formData['price']])) {
         $priceCode = $formData['price'];
     } else {
         reset($availablePrices);
         $priceCode = key($availablePrices);
     }
     $registration->setPrice($priceCode);
     $totalPrice = $availablePrices[$priceCode] * $seats;
     $registration->setTotalPrice($totalPrice);
     $attendeesNames = isset($formData['attendees_names']) ? strip_tags($formData['attendees_names']) : '';
     $registration->setAttendeesNames($attendeesNames);
     $kids = isset($formData['kids']) ? max(0, (int) $formData['kids']) : 0;
     $registration->setKids($kids);
     $paymentMethod = NULL;
     if ($totalPrice > 0) {
         $availablePaymentMethods = $event->getPaymentMethods();
         if (!$availablePaymentMethods->isEmpty()) {
             if ($availablePaymentMethods->count() == 1) {
                 $paymentMethod = $availablePaymentMethods->first();
             } else {
                 $paymentMethodUid = isset($formData['method_of_payment']) ? max(0, (int) $formData['method_of_payment']) : 0;
                 if ($paymentMethodUid > 0 && $availablePaymentMethods->hasUid($paymentMethodUid)) {
                     /** @var tx_seminars_Mapper_PaymentMethod $mapper */
                     $mapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_PaymentMethod');
                     /** @var tx_seminars_Model_PaymentMethod $paymentMethod */
                     $paymentMethod = $mapper->find($paymentMethodUid);
                 }
             }
         }
     }
     $registration->setPaymentMethod($paymentMethod);
     $accountNumber = isset($formData['account_number']) ? strip_tags($this->unifyWhitespace($formData['account_number'])) : '';
     $registration->setAccountNumber($accountNumber);
     $bankCode = isset($formData['bank_code']) ? strip_tags($this->unifyWhitespace($formData['bank_code'])) : '';
     $registration->setBankCode($bankCode);
     $bankName = isset($formData['bank_name']) ? strip_tags($this->unifyWhitespace($formData['bank_name'])) : '';
     $registration->setBankName($bankName);
     $accountOwner = isset($formData['account_owner']) ? strip_tags($this->unifyWhitespace($formData['account_owner'])) : '';
     $registration->setAccountOwner($accountOwner);
     $company = isset($formData['company']) ? strip_tags($formData['company']) : '';
     $registration->setCompany($company);
     $validGenderMale = (string) tx_oelib_Model_FrontEndUser::GENDER_MALE;
     $validGenderFemale = (string) tx_oelib_Model_FrontEndUser::GENDER_FEMALE;
     if (isset($formData['gender']) && ($formData['gender'] === $validGenderMale || $formData['gender'] === $validGenderFemale)) {
         $gender = (int) $formData['gender'];
     } else {
         $gender = tx_oelib_Model_FrontEndUser::GENDER_UNKNOWN;
     }
     $registration->setGender($gender);
     $name = isset($formData['name']) ? strip_tags($this->unifyWhitespace($formData['name'])) : '';
     $registration->setName($name);
     $address = isset($formData['address']) ? strip_tags($formData['address']) : '';
     $registration->setAddress($address);
     $zip = isset($formData['zip']) ? strip_tags($this->unifyWhitespace($formData['zip'])) : '';
     $registration->setZip($zip);
     $city = isset($formData['city']) ? strip_tags($this->unifyWhitespace($formData['city'])) : '';
     $registration->setCity($city);
     $country = isset($formData['country']) ? strip_tags($this->unifyWhitespace($formData['country'])) : '';
     $registration->setCountry($country);
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function setAdditionalPersonsSetsAdditionalPersons()
 {
     $additionalPersons = new tx_oelib_List();
     $this->fixture->setAdditionalPersons($additionalPersons);
     self::assertSame($additionalPersons, $this->fixture->getAdditionalPersons());
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function setRegistrationDataForMissingCountrySetsEmptyCountry()
 {
     $className = $this->createAccessibleProxyClass();
     /** @var tx_seminars_registrationmanager $fixture */
     $fixture = new $className();
     /** @var tx_seminars_Model_Event $event */
     $event = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_Event')->getLoadedTestingModel(array());
     $registration = new tx_seminars_Model_Registration();
     $registration->setEvent($event);
     $fixture->setRegistrationData($registration, array());
     self::assertSame('', $registration->getCountry());
 }
Exemplo n.º 5
0
 /**
  * Creates additional attendees as FE users and adds them to $registration.
  *
  * @param tx_seminars_Model_Registration $registration
  *
  * @return void
  */
 protected function createAdditionalAttendees(tx_seminars_Model_Registration $registration)
 {
     $allPersonsData = $this->getAdditionalRegisteredPersonsData();
     if (empty($allPersonsData)) {
         return;
     }
     /** @var $userMapper tx_seminars_Mapper_FrontEndUser */
     $userMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_FrontEndUser');
     $pageUid = $this->getConfValueInteger('sysFolderForAdditionalAttendeeUsersPID', 's_registration');
     /** @var $userGroupMapper tx_seminars_Mapper_FrontEndUserGroup */
     $userGroupMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_FrontEndUserGroup');
     /** @var  Tx_Oelib_List $userGroups */
     $userGroups = t3lib_div::makeInstance('Tx_Oelib_List');
     $userGroupUids = t3lib_div::intExplode(',', $this->getConfValueString('userGroupUidsForAdditionalAttendeesFrontEndUsers', 's_registration'), TRUE);
     foreach ($userGroupUids as $uid) {
         /** @var tx_seminars_Model_FrontEndUserGroup $userGroup */
         $userGroup = $userGroupMapper->find($uid);
         $userGroups->add($userGroup);
     }
     /** @var $additionalPersons Tx_Oelib_List */
     $additionalPersons = $registration->getAdditionalPersons();
     /** @var $personData array */
     foreach ($allPersonsData as $personData) {
         /** @var tx_seminars_Model_FrontEndUser $user */
         $user = t3lib_div::makeInstance('tx_seminars_Model_FrontEndUser');
         $user->setPageUid($pageUid);
         $user->setPassword(t3lib_div::getRandomHexString(8));
         $eMailAddress = $personData[3];
         $user->setEMailAddress($eMailAddress);
         $isUnique = FALSE;
         $suffixCounter = 0;
         do {
             $userName = $eMailAddress;
             if ($suffixCounter > 0) {
                 $userName .= '-' . $suffixCounter;
             }
             try {
                 $userMapper->findByUserName($userName);
             } catch (tx_oelib_Exception_NotFound $exception) {
                 $isUnique = TRUE;
             }
             $suffixCounter++;
         } while (!$isUnique);
         $user->setUserName($userName);
         $user->setUserGroups($userGroups);
         $user->setFirstName($personData[0]);
         $user->setLastName($personData[1]);
         $user->setName($personData[0] . ' ' . $personData[1]);
         $user->setJobTitle($personData[2]);
         $additionalPersons->add($user);
     }
     /** @var tx_seminars_Mapper_Registration $registrationMapper */
     $registrationMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_Registration');
     $registrationMapper->save($registration);
 }