00001 <?php
00002
00015
00016
00017 import('form.Form');
00018
00019 class BuildingForm extends Form {
00021 var $buildingId;
00022
00027 function BuildingForm($buildingId = null) {
00028 $this->buildingId = isset($buildingId) ? (int) $buildingId : null;
00029
00030 parent::Form('manager/scheduler/buildingForm.tpl');
00031
00032
00033 $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'manager.scheduler.building.form.nameRequired'));
00034 $this->addCheck(new FormValidatorLocale($this, 'abbrev', 'required', 'manager.scheduler.building.form.abbrevRequired'));
00035
00036 $this->addCheck(new FormValidatorPost($this));
00037 }
00038
00043 function getLocaleFieldNames() {
00044 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00045 return $buildingDao->getLocaleFieldNames();
00046 }
00047
00051 function display() {
00052 $templateMgr =& TemplateManager::getManager();
00053 $templateMgr->assign('buildingId', $this->buildingId);
00054 $templateMgr->assign('helpTopicId', 'conference.currentConferences.buildings');
00055
00056 parent::display();
00057 }
00058
00062 function initData() {
00063 if (isset($this->buildingId)) {
00064 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00065 $building =& $buildingDao->getBuilding($this->buildingId);
00066
00067 if ($building != null) {
00068 $this->_data = array(
00069 'name' => $building->getName(null),
00070 'description' => $building->getDescription(null),
00071 'abbrev' => $building->getAbbrev(null)
00072 );
00073
00074 } else {
00075 $this->buildingId = null;
00076 }
00077 }
00078 }
00079
00083 function readInputData() {
00084 $this->readUserVars(array('name', 'abbrev', 'description'));
00085
00086 }
00087
00091 function execute() {
00092 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00093 $schedConf =& Request::getSchedConf();
00094
00095 if (isset($this->buildingId)) {
00096 $building =& $buildingDao->getBuilding($this->buildingId);
00097 }
00098
00099 if (!isset($building)) {
00100 $building = new Building();
00101 }
00102
00103 $building->setSchedConfId($schedConf->getId());
00104 $building->setName($this->getData('name'), null);
00105 $building->setAbbrev($this->getData('abbrev'), null);
00106 $building->setDescription($this->getData('description'), null);
00107
00108
00109 if ($building->getId() != null) {
00110 $buildingDao->updateBuilding($building);
00111 } else {
00112 $buildingDao->insertBuilding($building);
00113 }
00114 }
00115 }
00116
00117 ?>