00001 <?php
00002
00015
00016
00017 import('form.Form');
00018
00019 class RoomForm extends Form {
00021 var $roomId;
00022
00024 var $buildingId;
00025
00030 function RoomForm($roomId, $buildingId) {
00031 $this->roomId = isset($roomId) ? (int) $roomId : null;
00032 $this->buildingId = (int) $buildingId;
00033 $schedConf =& Request::getSchedConf();
00034
00035 parent::Form('manager/scheduler/roomForm.tpl');
00036
00037
00038 $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'manager.scheduler.room.form.nameRequired'));
00039
00040
00041 $this->addCheck(new FormValidatorCustom($this, 'buildingId', 'required', 'manager.scheduler.room.form.buildingIdValid', create_function('$buildingId, $schedConfId', '$buildingDao =& DAORegistry::getDAO(\'BuildingDAO\'); return $buildingDao->buildingExistsForSchedConf($buildingId, $schedConfId);'), array($schedConf->getId())));
00042
00043 $this->addCheck(new FormValidatorPost($this));
00044 }
00045
00050 function getLocaleFieldNames() {
00051 $roomDao =& DAORegistry::getDAO('RoomDAO');
00052 return $roomDao->getLocaleFieldNames();
00053 }
00054
00058 function display() {
00059 $templateMgr =& TemplateManager::getManager();
00060 $templateMgr->assign('roomId', $this->roomId);
00061 $templateMgr->assign('buildingId', $this->buildingId);
00062 $templateMgr->assign('helpTopicId', 'conference.currentConferences.rooms');
00063
00064 parent::display();
00065 }
00066
00070 function initData() {
00071 if (isset($this->roomId)) {
00072 $roomDao =& DAORegistry::getDAO('RoomDAO');
00073 $room =& $roomDao->getRoom($this->roomId);
00074
00075 if ($room != null) {
00076 $this->_data = array(
00077 'name' => $room->getName(null),
00078 'abbrev' => $room->getAbbrev(null),
00079 'description' => $room->getDescription(null)
00080 );
00081
00082 } else {
00083 $this->roomId = null;
00084 }
00085 }
00086 }
00087
00091 function readInputData() {
00092 $this->readUserVars(array('name', 'buildingId', 'description', 'abbrev'));
00093
00094 }
00095
00099 function execute() {
00100 $roomDao =& DAORegistry::getDAO('RoomDAO');
00101 $schedConf =& Request::getSchedConf();
00102
00103 if (isset($this->roomId)) {
00104 $room =& $roomDao->getRoom($this->roomId);
00105 }
00106
00107 if (!isset($room)) {
00108 $room = new Room();
00109 }
00110
00111 $room->setBuildingId($this->buildingId);
00112 $room->setName($this->getData('name'), null);
00113 $room->setAbbrev($this->getData('abbrev'), null);
00114 $room->setDescription($this->getData('description'), null);
00115
00116
00117 if ($room->getId() != null) {
00118 $roomDao->updateRoom($room);
00119 } else {
00120 $roomDao->insertRoom($room);
00121 }
00122 }
00123 }
00124
00125 ?>