X-Git-Url: https://git.rohieb.name/iserv-mod-room-reservation.git/blobdiff_plain/5760b2a8d146d7c186daab1743c84683d0d84cea..6cf98ccf46c1c6aae846b4c5f8ff66a527cd685b:/includes/mod_roomReservationBookingTable.inc diff --git a/includes/mod_roomReservationBookingTable.inc b/includes/mod_roomReservationBookingTable.inc old mode 100755 new mode 100644 index c325d88..8d017f5 --- a/includes/mod_roomReservationBookingTable.inc +++ b/includes/mod_roomReservationBookingTable.inc @@ -118,6 +118,8 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ { protected $strPostAccount; /** (int) recurrence interval, POST data */ protected $nPostInterval; + /** (string) Array of error messages */ + protected $asErrors = array(); /***************************************************************************/ /** @@ -139,7 +141,11 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ { $this->oRm = $oRm; $this->oBm = $oBm; - $this->processRequestVariables(); + try { + $this->processRequestVariables(); + } catch(Exception $e) { + $this->asErrors[] = $e->getMessage(); + } $this->addCSS(); } @@ -151,24 +157,26 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ { */ /** - * Process the REQUEST variables and preset the some variables + * Process the REQUEST variables and preset the some variables. Throws an + * exception if the room provided by the GET data is not allowed for booking * @return void + * @throws Exception */ protected function processRequestVariables() { - ######################## - # FIXME remove this - var_export($_GET); echo "
"; - var_export($_POST); echo ""; - ######################## - // default values - $aoRooms = $this->oRm->getRooms(); - if($aoRooms != array()) { - $or = $aoRooms[0]; - $this->setRoom($or->getName()); + $aoRooms = $this->oCfg->getWhitelistedRooms(); + if(count($aoRooms) < 1) { + $this->setRoom(""); + } else { + $this->setRoom($aoRooms[0]->getName()); + } + // if weekends are not shown, show the next week already on saturday + if(!$this->oCfg->isShowWeekend() and date("w") == 6) { + $this->setDate(strtotime("monday")); + } else { + $this->setDate(time()); } - $this->setDate(time()); $this->setAction(MOD_ROOM_RESERVATION_BT_ACTION_SHOW); $this->nPostInterval = 0; @@ -185,8 +193,9 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ { MOD_ROOM_RESERVATION_BT_ACTION_SHOW))))); $this->setDate(isset($_GET["mod_roomReservationBookingTable"]["date"]) ? intval($_GET["mod_roomReservationBookingTable"]["date"]) : time()); - $this->setRoom(isset($_GET["mod_roomReservationBookingTable"]["room"]) ? - $_GET["mod_roomReservationBookingTable"]["room"] : ""); + if(isset($_GET["mod_roomReservationBookingTable"]["room"])) { + $this->setRoom($_GET["mod_roomReservationBookingTable"]["room"]); + } $this->setTsFirst( isset($_GET["mod_roomReservationBookingTable"]["tsfirst"]) ? intval($_GET["mod_roomReservationBookingTable"]["tsfirst"]) : 0); @@ -265,16 +274,6 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ { $_POST["mod_roomReservationBookingTable"]["submitdelete"] : ""); } } - - ################ - /** FIXME remove this */ - echo sprintf("date: %s%s
", join("