00001 <?php
00002
00015
00016
00017 import('form.Form');
00018
00019 class RegistrationOptionForm extends Form {
00021 var $optionId;
00022
00024 var $validAccessOptions;
00025
00030 function RegistrationOptionForm($optionId = null) {
00031 $this->optionId = isset($optionId) ? (int) $optionId : null;
00032 $schedConf =& Request::getSchedConf();
00033
00034 parent::Form('registration/registrationOptionForm.tpl');
00035
00036
00037 $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'manager.registrationOptions.form.optionNameRequired'));
00038
00039
00040 $this->addCheck(new FormValidatorCustom($this, 'openDate', 'required', 'manager.registrationOptions.form.closeBeforeOpen',
00041 create_function('$openDate,$form',
00042 'return ($openDate < $form->getData(\'closeDate\'));'),
00043 array(&$this)));
00044
00045
00046 $this->addCheck(new FormValidatorInSet($this, 'notPublic', 'optional', 'manager.registrationOptions.form.notPublicValid', array('1')));
00047
00048 $this->addCheck(new FormValidatorPost($this));
00049 }
00050
00055 function getLocaleFieldNames() {
00056 $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
00057 return $registrationOptionDao->getLocaleFieldNames();
00058 }
00059
00063 function display() {
00064 $templateMgr =& TemplateManager::getManager();
00065 $templateMgr->assign('dateExtentFuture', REGISTRATION_OPTION_YEAR_OFFSET_FUTURE);
00066 $templateMgr->assign('optionId', $this->optionId);
00067 $templateMgr->assign('validAccessOptions', $this->validAccessOptions);
00068 $templateMgr->assign('helpTopicId', 'conference.currentConferences.registration');
00069
00070 parent::display();
00071 }
00072
00076 function initData() {
00077 if (isset($this->optionId)) {
00078 $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
00079 $registrationOption =& $registrationOptionDao->getRegistrationOption($this->optionId);
00080
00081 if ($registrationOption != null) {
00082 $this->_data = array(
00083 'name' => $registrationOption->getName(null),
00084 'description' => $registrationOption->getDescription(null),
00085 'openDate' => $registrationOption->getOpeningDate(),
00086 'closeDate' => $registrationOption->getClosingDate(),
00087 'notPublic' => $registrationOption->getPublic()?0:1,
00088 'code' => $registrationOption->getCode()
00089 );
00090
00091 } else {
00092 $this->optionId = null;
00093 }
00094 } else {
00095 $this->_data = array(
00096 'notPublic' => 0
00097 );
00098 }
00099 }
00100
00104 function readInputData() {
00105 $this->readUserVars(array('name', 'description', 'notPublic', 'code'));
00106 $this->_data['openDate'] = Request::getUserDateVar('openDate');
00107 $this->_data['closeDate'] = Request::getUserDateVar('closeDate');
00108 }
00109
00113 function execute() {
00114 $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
00115 $schedConf =& Request::getSchedConf();
00116
00117 if (isset($this->optionId)) {
00118 $registrationOption =& $registrationOptionDao->getRegistrationOption($this->optionId);
00119 }
00120
00121 if (!isset($registrationOption)) {
00122 $registrationOption = new RegistrationOption();
00123 }
00124
00125 $registrationOption->setSchedConfId($schedConf->getId());
00126 $registrationOption->setName($this->getData('name'), null);
00127 $registrationOption->setDescription($this->getData('description'), null);
00128 $registrationOption->setOpeningDate($this->getData('openDate'));
00129 $registrationOption->setClosingDate($this->getData('closeDate'));
00130 $registrationOption->setPublic($this->getData('notPublic')?0:1);
00131 $registrationOption->setCode($this->getData('code'));
00132
00133
00134 if ($registrationOption->getOptionId() != null) {
00135 $registrationOptionDao->updateRegistrationOption($registrationOption);
00136 } else {
00137 $registrationOption->setSequence(REALLY_BIG_NUMBER);
00138 $registrationOptionDao->insertRegistrationOption($registrationOption);
00139
00140
00141 $registrationOptionDao->resequenceRegistrationOptions($registrationOption->getSchedConfId());
00142 }
00143 }
00144 }
00145
00146 ?>