00001 <?php
00002
00015
00016
00017 import('pages.manager.ManagerHandler');
00018
00019 class SchedulerHandler extends ManagerHandler {
00023 function SchedulerHandler() {
00024 parent::ManagerHandler();
00025 }
00026
00030 function scheduler() {
00031 $this->validate();
00032 $this->setupTemplate();
00033
00034 $templateMgr =& TemplateManager::getManager();
00035 $templateMgr->assign('helpTopicId', 'conference.currentConferences.scheduler');
00036 $templateMgr->display('manager/scheduler/index.tpl');
00037 }
00038
00042 function saveSchedulerSettings() {
00043 parent::validate();
00044 $enableTimeBlocks = Request::getUserVar('enableTimeBlocks');
00045 $schedConf =& Request::getSchedConf();
00046 $schedConf->updateSetting('enableTimeBlocks', $enableTimeBlocks);
00047 Request::redirect(null, null, 'manager', 'scheduler');
00048 }
00049
00053 function buildings() {
00054 $this->validate();
00055 $this->setupTemplate(true);
00056
00057 $schedConf =& Request::getSchedConf();
00058 $rangeInfo =& Handler::getRangeInfo('buildings', array());
00059 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00060 while (true) {
00061 $buildings =& $buildingDao->getBuildingsBySchedConfId($schedConf->getId(), $rangeInfo);
00062 if ($buildings->isInBounds()) break;
00063 unset($rangeInfo);
00064 $rangeInfo =& $buildings->getLastPageRangeInfo();
00065 unset($buildings);
00066 }
00067
00068 $templateMgr =& TemplateManager::getManager();
00069 $templateMgr->assign('buildings', $buildings);
00070 $templateMgr->assign('helpTopicId', 'conference.currentConferences.buildings');
00071 $templateMgr->display('manager/scheduler/buildings.tpl');
00072 }
00073
00078 function deleteBuilding($args) {
00079 $this->validate();
00080 $buildingId = (int) array_shift($args);
00081 $schedConf =& Request::getSchedConf();
00082 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00083
00084
00085 if ($buildingDao->getBuildingSchedConfId($buildingId) == $schedConf->getId()) {
00086 $buildingDao->deleteBuildingById($buildingId);
00087 }
00088
00089 Request::redirect(null, null, null, 'buildings');
00090 }
00091
00096 function editBuilding($args = array()) {
00097 $this->validate();
00098 $this->setupTemplate(true);
00099
00100 $schedConf =& Request::getSchedConf();
00101 $buildingId = !isset($args) || empty($args) ? null : (int) $args[0];
00102 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00103
00104
00105 if (($buildingId != null && $buildingDao->getBuildingSchedConfId($buildingId) == $schedConf->getId()) || ($buildingId == null)) {
00106 import('manager.form.scheduler.BuildingForm');
00107
00108 $templateMgr =& TemplateManager::getManager();
00109 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'buildings'), 'manager.scheduler.buildings'));
00110
00111 if ($buildingId == null) {
00112 $templateMgr->assign('buildingTitle', 'manager.scheduler.building.createBuildingShort');
00113 } else {
00114 $templateMgr->assign('buildingTitle', 'manager.scheduler.building.editBuildingShort');
00115 }
00116
00117 $buildingForm = new BuildingForm($buildingId);
00118 if ($buildingForm->isLocaleResubmit()) {
00119 $buildingForm->readInputData();
00120 } else {
00121 $buildingForm->initData();
00122 }
00123 $buildingForm->display();
00124
00125 } else {
00126 Request::redirect(null, null, null, 'buildings');
00127 }
00128 }
00129
00133 function createBuilding() {
00134 $this->editBuilding();
00135 }
00136
00140 function updateBuilding() {
00141 $this->validate();
00142 $this->setupTemplate(true);
00143
00144 import('manager.form.scheduler.BuildingForm');
00145
00146 $schedConf =& Request::getSchedConf();
00147 $buildingId = Request::getUserVar('buildingId') == null ? null : (int) Request::getUserVar('buildingId');
00148 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00149
00150 if (($buildingId != null && $buildingDao->getBuildingSchedConfId($buildingId) == $schedConf->getId()) || $buildingId == null) {
00151
00152 $buildingForm = new BuildingForm($buildingId);
00153 $buildingForm->readInputData();
00154
00155 if ($buildingForm->validate()) {
00156 $buildingForm->execute();
00157
00158 if (Request::getUserVar('createAnother')) {
00159 Request::redirect(null, null, null, 'createBuilding');
00160 } else {
00161 Request::redirect(null, null, null, 'buildings');
00162 }
00163
00164 } else {
00165 $templateMgr =& TemplateManager::getManager();
00166 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'buildings'), 'manager.scheduler.buildings'));
00167
00168 if ($buildingId == null) {
00169 $templateMgr->assign('buildingTitle', 'manager.scheduler.building.createBuilding');
00170 } else {
00171 $templateMgr->assign('buildingTitle', 'manager.scheduler.building.editBuilding');
00172 }
00173
00174 $buildingForm->display();
00175 }
00176
00177 } else {
00178 Request::redirect(null, null, null, 'buildings');
00179 }
00180 }
00181
00185 function rooms($args) {
00186 $schedConf =& Request::getSchedConf();
00187 $buildingId = (int) array_shift($args);
00188
00189 $this->validate();
00190 $this->setupTemplate(true);
00191
00192 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00193 $building =& $buildingDao->getBuilding($buildingId);
00194
00195 if (!$schedConf || !$building || $building->getSchedConfId() != $schedConf->getId()) {
00196 Request::redirect(null, null, null, 'scheduler');
00197 }
00198
00199 $rangeInfo =& Handler::getRangeInfo('rooms', array($buildingId));
00200 $roomDao =& DAORegistry::getDAO('RoomDAO');
00201 while (true) {
00202 $rooms =& $roomDao->getRoomsByBuildingId($buildingId, $rangeInfo);
00203 if ($rooms->isInBounds()) break;
00204 unset($rangeInfo);
00205 $rangeInfo =& $rooms->getLastPageRangeInfo();
00206 unset($rooms);
00207 }
00208
00209 $templateMgr =& TemplateManager::getManager();
00210 $templateMgr->assign('rooms', $rooms);
00211 $templateMgr->assign('buildingId', $buildingId);
00212 $templateMgr->assign('helpTopicId', 'conference.currentConferences.rooms');
00213 $templateMgr->display('manager/scheduler/rooms.tpl');
00214 }
00215
00220 function deleteRoom($args) {
00221 $this->validate();
00222 $roomId = (int) array_shift($args);
00223 $schedConf =& Request::getSchedConf();
00224
00225 $roomDao =& DAORegistry::getDAO('RoomDAO');
00226 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00227
00228
00229 $room =& $roomDao->getRoom($roomId);
00230 if ($room) $building =& $buildingDao->getBuilding($room->getBuildingId());
00231
00232 if ( $room && $building && $schedConf &&
00233 $room->getBuildingId() == $building->getId() &&
00234 $building->getSchedConfId() == $schedConf->getId()
00235 ) {
00236 $roomDao->deleteRoomById($roomId);
00237 }
00238
00239 if ($building) Request::redirect(null, null, null, 'rooms', array($building->getId()));
00240 else Request::redirect(null, null, null, 'scheduler');
00241 }
00242
00247 function editRoom($args) {
00248 $this->validate();
00249 $this->setupTemplate(true);
00250
00251 $schedConf =& Request::getSchedConf();
00252 $buildingId = (int) array_shift($args);
00253 $roomId = (int) array_shift($args);
00254
00255 $roomDao =& DAORegistry::getDAO('RoomDAO');
00256 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00257
00258 $room =& $roomDao->getRoom($roomId);
00259 $building =& $buildingDao->getBuilding($buildingId);
00260
00261
00262 if ( $building && $schedConf &&
00263 $building->getSchedConfId() == $schedConf->getId() &&
00264 ((
00265 !$room && $roomId == 0
00266 ) || (
00267 $room && $room->getBuildingId() == $building->getId()
00268 ))
00269 ) {
00270 import('manager.form.scheduler.RoomForm');
00271
00272 $templateMgr =& TemplateManager::getManager();
00273 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'rooms', array($building->getId())), 'manager.scheduler.rooms'));
00274
00275 if ($roomId == null) {
00276 $templateMgr->assign('roomTitle', 'manager.scheduler.room.createRoomShort');
00277 } else {
00278 $templateMgr->assign('roomTitle', 'manager.scheduler.room.editRoomShort');
00279 }
00280
00281 $roomForm = new RoomForm($roomId, $buildingId);
00282 if ($roomForm->isLocaleResubmit()) {
00283 $roomForm->readInputData();
00284 } else {
00285 $roomForm->initData();
00286 }
00287 $roomForm->display();
00288
00289 } else {
00290 Request::redirect(null, null, null, 'rooms', array($buildingId));
00291 }
00292 }
00293
00297 function createRoom($args) {
00298 $this->editRoom($args);
00299 }
00300
00304 function updateRoom() {
00305 $this->validate();
00306 $this->setupTemplate(true);
00307
00308 import('manager.form.scheduler.RoomForm');
00309
00310 $schedConf =& Request::getSchedConf();
00311 $roomId = Request::getUserVar('roomId') == null ? null : (int) Request::getUserVar('roomId');
00312 $buildingId = Request::getUserVar('buildingId') == null ? null : (int) Request::getUserVar('buildingId');
00313
00314 $roomDao =& DAORegistry::getDAO('RoomDAO');
00315 $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00316
00317 $building = $buildingDao->getBuilding($buildingId);
00318
00319
00320 if ( !$building || !$schedConf ||
00321 $schedConf->getId() != $building->getSchedConfId()
00322 ) {
00323 Request::redirect(null, null, null, 'scheduler');
00324 }
00325
00326 if (($roomId != null && $roomDao->getRoomBuildingId($roomId) == $buildingId) || $roomId == null) {
00327
00328 $roomForm = new RoomForm($roomId, $buildingId);
00329 $roomForm->readInputData();
00330
00331 if ($roomForm->validate()) {
00332 $roomForm->execute();
00333
00334 if (Request::getUserVar('createAnother')) {
00335 Request::redirect(null, null, null, 'createRoom', array($buildingId));
00336 } else {
00337 Request::redirect(null, null, null, 'rooms', array($buildingId));
00338 }
00339
00340 } else {
00341 $templateMgr =& TemplateManager::getManager();
00342 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'rooms', array($buildingId)), 'manager.scheduler.rooms'));
00343
00344 if ($roomId == null) {
00345 $templateMgr->assign('roomTitle', 'manager.scheduler.room.createRoom');
00346 } else {
00347 $templateMgr->assign('roomTitle', 'manager.scheduler.room.editRoom');
00348 }
00349
00350 $roomForm->display();
00351 }
00352
00353 } else {
00354 Request::redirect(null, null, null, 'rooms');
00355 }
00356 }
00357
00361 function specialEvents() {
00362 $this->validate();
00363 $this->setupTemplate(true);
00364
00365 $schedConf =& Request::getSchedConf();
00366 $rangeInfo =& Handler::getRangeInfo('specialEvents', array());
00367 $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00368 while (true) {
00369 $specialEvents =& $specialEventDao->getSpecialEventsBySchedConfId($schedConf->getId(), $rangeInfo);
00370 if ($specialEvents->isInBounds()) break;
00371 unset($rangeInfo);
00372 $rangeInfo =& $specialEvents->getLastPageRangeInfo();
00373 unset($specialEvents);
00374 }
00375
00376 $templateMgr =& TemplateManager::getManager();
00377 $templateMgr->assign('specialEvents', $specialEvents);
00378 $templateMgr->assign('helpTopicId', 'conference.currentConferences.specialEvents');
00379 $templateMgr->display('manager/scheduler/specialEvents.tpl');
00380 }
00381
00386 function deleteSpecialEvent($args) {
00387 $this->validate();
00388 $specialEventId = (int) array_shift($args);
00389 $schedConf =& Request::getSchedConf();
00390 $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00391
00392
00393 if ($specialEventDao->getSpecialEventSchedConfId($specialEventId) == $schedConf->getId()) {
00394 $specialEventDao->deleteSpecialEventById($specialEventId);
00395 }
00396
00397 Request::redirect(null, null, null, 'specialEvents');
00398 }
00399
00404 function editSpecialEvent($args = array()) {
00405 $this->validate();
00406 $this->setupTemplate(true);
00407
00408 $schedConf =& Request::getSchedConf();
00409 $specialEventId = !isset($args) || empty($args) ? null : (int) $args[0];
00410 $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00411
00412
00413 if (($specialEventId != null && $specialEventDao->getSpecialEventSchedConfId($specialEventId) == $schedConf->getId()) || ($specialEventId == null)) {
00414 import('manager.form.scheduler.SpecialEventForm');
00415
00416 $templateMgr =& TemplateManager::getManager();
00417 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'specialEvents'), 'manager.scheduler.specialEvents'));
00418
00419 if ($specialEventId == null) {
00420 $templateMgr->assign('specialEventTitle', 'manager.scheduler.specialEvent.createSpecialEventShort');
00421 } else {
00422 $templateMgr->assign('specialEventTitle', 'manager.scheduler.specialEvent.editSpecialEventShort');
00423 }
00424
00425 if (checkPhpVersion('5.0.0')) {
00426 $specialEventForm = new SpecialEventForm($specialEventId);
00427 } else {
00428 $specialEventForm =& new SpecialEventForm($specialEventId);
00429 }
00430 if ($specialEventForm->isLocaleResubmit()) {
00431 $specialEventForm->readInputData();
00432 } else {
00433 $specialEventForm->initData();
00434 }
00435 $specialEventForm->display();
00436
00437 } else {
00438 Request::redirect(null, null, null, 'specialEvents');
00439 }
00440 }
00441
00445 function createSpecialEvent() {
00446 $this->editSpecialEvent();
00447 }
00448
00452 function updateSpecialEvent() {
00453 $this->validate();
00454 $this->setupTemplate(true);
00455
00456 import('manager.form.scheduler.SpecialEventForm');
00457
00458 $schedConf =& Request::getSchedConf();
00459 $specialEventId = Request::getUserVar('specialEventId') == null ? null : (int) Request::getUserVar('specialEventId');
00460 $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00461
00462 if (($specialEventId != null && $specialEventDao->getSpecialEventSchedConfId($specialEventId) == $schedConf->getId()) || $specialEventId == null) {
00463
00464 if (checkPhpVersion('5.0.0')) {
00465 $specialEventForm = new SpecialEventForm($specialEventId);
00466 } else {
00467 $specialEventForm =& new SpecialEventForm($specialEventId);
00468 }
00469 $specialEventForm->readInputData();
00470
00471 if ($specialEventForm->validate()) {
00472 $specialEventForm->execute();
00473
00474 if (Request::getUserVar('createAnother')) {
00475 Request::redirect(null, null, null, 'createSpecialEvent');
00476 } else {
00477 Request::redirect(null, null, null, 'specialEvents');
00478 }
00479
00480 } else {
00481 $templateMgr =& TemplateManager::getManager();
00482 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'specialEvents'), 'manager.scheduler.specialEvents'));
00483
00484 if ($specialEventId == null) {
00485 $templateMgr->assign('specialEventTitle', 'manager.scheduler.specialEvent.createSpecialEvent');
00486 } else {
00487 $templateMgr->assign('specialEventTitle', 'manager.scheduler.specialEvent.editSpecialEvent');
00488 }
00489
00490 $specialEventForm->display();
00491 }
00492 } else {
00493 Request::redirect(null, null, null, 'specialEvents');
00494 }
00495 }
00496
00500 function schedule($args) {
00501 $this->validate();
00502 $this->setupTemplate(true);
00503
00504 $schedConf =& Request::getSchedConf();
00505
00506 import('manager.form.scheduler.ScheduleForm');
00507 $scheduleForm = new ScheduleForm();
00508
00509 $scheduleForm->initData();
00510 $scheduleForm->display();
00511 }
00512
00516 function saveSchedule() {
00517 $this->validate();
00518 $this->setupTemplate(true);
00519
00520 $schedConf =& Request::getSchedConf();
00521
00522 import('manager.form.scheduler.ScheduleForm');
00523 $scheduleForm = new ScheduleForm();
00524
00525 $scheduleForm->readInputData();
00526 if ($scheduleForm->validate()) {
00527 $scheduleForm->execute();
00528 Request::redirect(null, null, null, 'scheduler');
00529 } else {
00530 $scheduleForm->display();
00531 }
00532 }
00533
00537 function scheduleLayout($args) {
00538 $this->validate();
00539 $this->setupTemplate(true);
00540
00541 import('manager.form.scheduler.ScheduleLayoutForm');
00542 $scheduleLayoutForm = new ScheduleLayoutForm();
00543
00544 $scheduleLayoutForm->initData();
00545 $scheduleLayoutForm->display();
00546 }
00547
00551 function saveScheduleLayout() {
00552 $this->validate();
00553 $this->setupTemplate(true);
00554
00555 $schedConf =& Request::getSchedConf();
00556
00557 import('manager.form.scheduler.ScheduleLayoutForm');
00558 $scheduleLayoutForm = new ScheduleLayoutForm();
00559
00560 $scheduleLayoutForm->readInputData();
00561 if ($scheduleLayoutForm->validate()) {
00562 $scheduleLayoutForm->execute();
00563 Request::redirect(null, null, null, 'scheduler');
00564 } else {
00565 $scheduleLayoutForm->display();
00566 }
00567 }
00568
00572 function timeBlocks() {
00573 parent::validate();
00574 SchedulerHandler::setupTemplate(true);
00575
00576 $schedConf =& Request::getSchedConf();
00577 $rangeInfo =& Handler::getRangeInfo('timeBlocks', array());
00578 $timeBlockDao =& DAORegistry::getDAO('TimeBlockDAO');
00579 while (true) {
00580 $timeBlocks =& $timeBlockDao->getTimeBlocksBySchedConfId($schedConf->getId(), $rangeInfo);
00581 if ($timeBlocks->isInBounds()) break;
00582 unset($rangeInfo);
00583 $rangeInfo =& $timeBlocks->getLastPageRangeInfo();
00584 unset($timeBlocks);
00585 }
00586
00587 $templateMgr =& TemplateManager::getManager();
00588 $templateMgr->assign('timeBlocks', $timeBlocks);
00589 $templateMgr->assign('helpTopicId', 'conference.managementPages.timeBlocks');
00590 $templateMgr->display('manager/scheduler/timeBlocks.tpl');
00591 }
00592
00597 function deleteTimeBlock($args) {
00598 parent::validate();
00599 $timeBlockId = (int) array_shift($args);
00600 $schedConf =& Request::getSchedConf();
00601 $timeBlockDao =& DAORegistry::getDAO('TimeBlockDAO');
00602
00603
00604 if ($timeBlockDao->getTimeBlockSchedConfId($timeBlockId) == $schedConf->getId()) {
00605 $timeBlockDao->deleteTimeBlockById($timeBlockId);
00606 }
00607
00608 Request::redirect(null, null, null, 'timeBlocks');
00609 }
00610
00614 function createTimeBlock() {
00615 SchedulerHandler::editTimeBlock();
00616 }
00617
00622 function editTimeBlock($args = array()) {
00623 parent::validate();
00624 SchedulerHandler::setupTemplate(true);
00625
00626 $schedConf =& Request::getSchedConf();
00627 $timeBlockId = !isset($args) || empty($args) ? null : (int) $args[0];
00628 $timeBlockDao =& DAORegistry::getDAO('TimeBlockDAO');
00629
00630
00631 if (($timeBlockId != null && $timeBlockDao->getTimeBlockSchedConfId($timeBlockId) == $schedConf->getId()) || ($timeBlockId == null)) {
00632 import('manager.form.scheduler.TimeBlockForm');
00633
00634 $templateMgr =& TemplateManager::getManager();
00635 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'timeBlocks'), 'manager.scheduler.timeBlocks'));
00636
00637 if ($timeBlockId == null) {
00638 $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.createTimeBlockShort');
00639 } else {
00640 $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.editTimeBlockShort');
00641 }
00642
00643 if (checkPhpVersion('5.0.0')) {
00644 $timeBlockForm = new TimeBlockForm($timeBlockId);
00645 } else {
00646 $timeBlockForm =& new TimeBlockForm($timeBlockId);
00647 }
00648 if ($timeBlockForm->isLocaleResubmit()) {
00649 $timeBlockForm->readInputData();
00650 } else {
00651 $timeBlockForm->initData();
00652 }
00653 $timeBlockForm->display();
00654
00655 } else {
00656 Request::redirect(null, null, null, 'timeBlocks');
00657 }
00658 }
00659
00663 function updateTimeBlock() {
00664 parent::validate();
00665 SchedulerHandler::setupTemplate(true);
00666
00667 import('manager.form.scheduler.TimeBlockForm');
00668
00669 $schedConf =& Request::getSchedConf();
00670 $timeBlockId = Request::getUserVar('timeBlockId') == null ? null : (int) Request::getUserVar('timeBlockId');
00671 $timeBlockDao =& DAORegistry::getDAO('TimeBlockDAO');
00672
00673 if (($timeBlockId != null && $timeBlockDao->getTimeBlockSchedConfId($timeBlockId) == $schedConf->getId()) || $timeBlockId == null) {
00674
00675 if (checkPhpVersion('5.0.0')) {
00676 $timeBlockForm = new TimeBlockForm($timeBlockId);
00677 } else {
00678 $timeBlockForm =& new TimeBlockForm($timeBlockId);
00679 }
00680 $timeBlockForm->readInputData();
00681
00682 if ($timeBlockForm->validate()) {
00683 $timeBlockForm->execute();
00684
00685 if (Request::getUserVar('createAnother')) {
00686
00687 return $timeBlockForm->display();
00688 } else {
00689 Request::redirect(null, null, null, 'timeBlocks');
00690 }
00691
00692 } else {
00693 $templateMgr =& TemplateManager::getManager();
00694 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'timeBlocks'), 'manager.scheduler.timeBlocks'));
00695
00696 if ($timeBlockId == null) {
00697 $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.createTimeBlock');
00698 } else {
00699 $templateMgr->assign('timeBlockTitle', 'manager.scheduler.timeBlock.editTimeBlock');
00700 }
00701
00702 $timeBlockForm->display();
00703 }
00704
00705 } else {
00706 Request::redirect(null, null, null, 'timeBlocks');
00707 }
00708 }
00709
00716 function setupTemplate($subclass = false) {
00717 parent::setupTemplate(true);
00718 if ($subclass) {
00719 $templateMgr =& TemplateManager::getManager();
00720 $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'scheduler'), 'manager.scheduler'));
00721 }
00722 }
00723 }
00724
00725 ?>