Esempio n. 1
0
 /**
  * Save registration type. 
  */
 function execute()
 {
     $schedConf =& Request::getSchedConf();
     if (isset($this->typeId)) {
         $registrationType =& $this->registrationTypeDao->getRegistrationType($this->typeId);
     }
     if (!isset($registrationType)) {
         $registrationType = new RegistrationType();
     }
     $registrationType->setSchedConfId($schedConf->getId());
     $registrationType->setName($this->getData('name'), null);
     // Localized
     $registrationType->setDescription($this->getData('description'), null);
     // Localized
     $registrationType->setCost(round($this->getData('cost'), 2));
     $registrationType->setCurrencyCodeAlpha($this->getData('currency'));
     $registrationType->setOpeningDate($this->getData('openDate'));
     $registrationType->setClosingDate($this->getData('closeDate'));
     $registrationType->setExpiryDate($this->getData('expiryDate'));
     $registrationType->setAccess($this->getData('access'));
     $registrationType->setInstitutional($this->getData('institutional') ? 1 : 0);
     $registrationType->setMembership($this->getData('membership') ? 1 : 0);
     $registrationType->setPublic($this->getData('notPublic') ? 0 : 1);
     $registrationType->setCode($this->getData('code'));
     // Update or insert registration type
     if ($registrationType->getTypeId() != null) {
         $this->registrationTypeDao->updateRegistrationType($registrationType);
         $this->registrationTypeDao->deleteRegistrationOptionCosts($registrationType->getTypeId());
     } else {
         $registrationType->setSequence(REALLY_BIG_NUMBER);
         $this->registrationTypeDao->insertRegistrationType($registrationType);
         // Re-order the registration types so the new one is at the end of the list.
         $this->registrationTypeDao->resequenceRegistrationTypes($registrationType->getSchedConfId());
     }
     $registrationOptionCosts = (array) $this->getData('registrationOptionCosts');
     foreach ($registrationOptionCosts as $optionId => $cost) {
         $this->registrationTypeDao->insertRegistrationOptionCost($registrationType->getTypeId(), $optionId, $cost);
     }
 }