roomId = isset($roomId) ? (int) $roomId : null; $this->buildingId = (int) $buildingId; $schedConf =& Request::getSchedConf(); parent::Form('manager/scheduler/roomForm.tpl'); // Type name is provided $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'manager.scheduler.room.form.nameRequired')); // If provided, building ID is valid $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->getSchedConfId()))); $this->addCheck(new FormValidatorPost($this)); } /** * Get a list of localized field names for this form * @return array */ function getLocaleFieldNames() { $roomDao =& DAORegistry::getDAO('RoomDAO'); return $roomDao->getLocaleFieldNames(); } /** * Display the form. */ function display() { $templateMgr = &TemplateManager::getManager(); $templateMgr->assign('roomId', $this->roomId); $templateMgr->assign('buildingId', $this->buildingId); $templateMgr->assign('helpTopicId', 'conference.managementPages.rooms'); parent::display(); } /** * Initialize form data from current room. */ function initData() { if (isset($this->roomId)) { $roomDao = &DAORegistry::getDAO('RoomDAO'); $room = &$roomDao->getRoom($this->roomId); if ($room != null) { $this->_data = array( 'name' => $room->getName(null), // Localized 'abbrev' => $room->getAbbrev(null), // Localized 'description' => $room->getDescription(null) // Localized ); } else { $this->roomId = null; } } } /** * Assign form data to user-submitted data. */ function readInputData() { $this->readUserVars(array('name', 'buildingId', 'description', 'abbrev')); } /** * Save room. */ function execute() { $roomDao =& DAORegistry::getDAO('RoomDAO'); $schedConf =& Request::getSchedConf(); if (isset($this->roomId)) { $room = &$roomDao->getRoom($this->roomId); } if (!isset($room)) { $room = &new Room(); } $room->setBuildingId($this->buildingId); $room->setName($this->getData('name'), null); // Localized $room->setAbbrev($this->getData('abbrev'), null); // Localized $room->setDescription($this->getData('description'), null); // Localized // Update or insert room if ($room->getRoomId() != null) { $roomDao->updateRoom($room); } else { $roomDao->insertRoom($room); } } } ?>