cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW; // POST data if(isset($_POST["mod_roomReservationRoomWhitelistListBox"])) { $aPost = $_POST["mod_roomReservationRoomWhitelistListBox"]; // mode if(isset($aPost["action"])) { if(isset($aPost["action"]["add"])) { if($aPost["action"]["add"] == _("Add")) { $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_ADD; } elseif($aPost["action"]["add"] == _("OK")) { $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD; } } elseif(isset($aPost["action"]["delete"])) { if($aPost["action"]["delete"] == _("Delete")) { $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE; } elseif($aPost["action"]["delete"] == _("OK")) { $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE; } } } // selection if(isset($aPost["l"])) { foreach($aPost["l"] as $nOid => $bChecked) { if($bChecked) { $this->anPostSelection[] = $nOid; } } } } // process the forms if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD) { $h = db_query("SELECT name FROM rooms WHERE oid IN ". qdb_arr($this->anPostSelection)); while($a = pg_fetch_array($h)) { $this->oCfg->whitelistRoom($a["name"]); } } if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE) { $h = db_query("SELECT name FROM rooms WHERE oid IN ". qdb_arr($this->anPostSelection)); while($a = pg_fetch_array($h)) { $this->oCfg->unWhitelistRoom($a["name"]); } } } protected function doShow() { echo "
\n"; } /** * Print the form if not delete nor add was requested * @return void */ protected function showForm() { $aoRooms = $this->oCfg->getWhitelistedRooms(); // only show add button if there are still some unlisted rooms if(count(mod_roomReservationRoomsManager::getRooms()) > count($aoRooms)) { TreeViewLine(sprintf("<%s name='mod_roomReservationRoomWhitelistListBox". "[action][add]' value='%s' />", $GLOBALS["stdbtn"], _("Add"))); } $this->showList($aoRooms); // toolbar printf("<%s name='mod_roomReservationRoomWhitelistList". "Box[action][add]' value='%s' /> <%s name='mod_roomReservationRoom". "WhitelistListBox[action][add]' value='%s' />
", $GLOBALS["stdbtn"], _("OK"), $GLOBALS["stdbtn"], _("Cancel"))); } /** * Show the deletion form * @return void */ protected function showDeleteForm() { // list rooms in selection $aoRooms = array(); $h = db_query("SELECT name FROM rooms WHERE oid IN ". qdb_arr($this->anPostSelection)); foreach($this->anPostSelection as $nOid) { $aoRooms[] = mod_roomReservationRoomsManager::getRoomByOid($nOid); } TreeViewSubtitle(sprintf(_("Following %s will be deleted"), _c("room-reservation:rooms"))); $this->showList($aoRooms, false); TreeViewLine(sprintf("<%s name='mod_roomReservationRoomWhitelistList". "Box[action][delete]' value='%s' /> <%s name='mod_roomReservationRoom". "WhitelistListBox[action][delete]' value='%s' />
", $GLOBALS["stdbtn"], _("OK"), $GLOBALS["stdbtn"], _("Cancel"))); } /** * Show the list items * @param $aoRooms (array of mod_roomReservationRoom objects) List items * @param $bCheckboxes (bool) Whether to show checkboxes */ protected function showList($aoRooms, $bCheckboxes = true) { if(count($aoRooms) > 0) { foreach($aoRooms as $o) { // fetch oid from SQL table $nOid = pg_fetch_result(db_query("SELECT oid FROM ". "rooms WHERE name = $1", $o->getName()), 0, "oid"); $sBox = $bCheckboxes ? sprintf("<%s id='box%d' name='mod_room". "ReservationRoomWhitelistListBox[l][%d]' value='1'%s />", $GLOBALS["smlchk"], $nOid, $nOid, @$this->anPostSelection[$nOid] ? " checked='checked'" : "", $nOid, icon("host"), $o->getName()) : sprintf("%s%s", $nOid, icon("host"), $o->getName()); TreeViewLine($sBox); } } else { TreeViewEmpty(); } } } ?>