X-Git-Url: https://git.rohieb.name/iserv-mod-room-reservation.git/blobdiff_plain/5760b2a8d146d7c186daab1743c84683d0d84cea..ada3bd52df2712a6c6ead81aa646d5ec47aeeca2:/includes/mod_roomReservationBookingsManager.inc diff --git a/includes/mod_roomReservationBookingsManager.inc b/includes/mod_roomReservationBookingsManager.inc old mode 100755 new mode 100644 index 573f340..124068d --- a/includes/mod_roomReservationBookingsManager.inc +++ b/includes/mod_roomReservationBookingsManager.inc @@ -144,7 +144,12 @@ class mod_roomReservationBookingsManager { ($ob->getUid() == null and !$this->oCfg->userCanBook())) { throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED); } - + + // test if room is whitelisted + if(!$this->oCfg->isRoomWhitelisted($ob->getRoom())) { + throw new Exception(MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED); + } + $strWhere = null; $strLog = ""; @@ -170,22 +175,26 @@ class mod_roomReservationBookingsManager { return false; } - // @todo Show real times in log, take it from config + // Show real times in log, but don't use the user's locale! + $oTsB = $this->oCfg->getTimesliceBeginnings(false); + $oTsE = $this->oCfg->getTimesliceEndings(false); // Update or insert? if($ob->getUid() == null) { // No UID yet, insert new booking - $strLog = sprintf("Raum „%s“ am %s von %s bis %s gebucht", - $ob->getRoom(), date("d\.m\.Y", $ob->getDate()), - intval($ob->getTsFirst()), intval($ob->getTsLast())); + // @todo write interval and user if interval > 0 + $strLog = sprintf("Raum „%s“ am %s von %s bis %s gebucht ". + "(Begründung: %s)", $ob->getRoom(), date("d\.m\.Y", $ob->getDate()), + gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i", + $oTsE[$ob->getTsLast()]), $ob->getReason()); } else { // Update an existing booking // @todo write old and new times into log $strWhere = "rs_uid = ".qdb(intval($ob->getUid())); $strLog = sprintf("Buchung im Raum „%s“ auf %s von %s bis %s ". "geändert (Begründung: „%s“)", $ob->getRoom(), date("d\.m\.Y", - $ob->getDate()), intval($ob->getTsFirst()), - intval($ob->getTsLast()), $ob->getReason()); + $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i", + $oTsE[$ob->getTsLast()]), $ob->getReason()); } $aPut["rrb_room"] = $ob->getRoom(); $aPut["rrb_date"] = date("Y\-m\-d", $ob->getDate()); @@ -199,8 +208,7 @@ class mod_roomReservationBookingsManager { // message if neccessary db_store("mod_roomreservation_bookings", $aPut, $strWhere); - $hQuery = db_query("SELECT currval('mod_roomreservation_bookings_rrb_uid_seq') ". - "FROM mod_roomreservation_bookings;"); + $hQuery = db_query("SELECT currval('mod_roomreservation_bookings_rrb_uid_seq');"); $nNewUid = pg_fetch_result($hQuery, 0, "currval"); rrInsertLog($strLog); @@ -222,11 +230,14 @@ class mod_roomReservationBookingsManager { return false; } - // @todo: Show real times in log, take it from config + // Don't use the user's locale! + $oTsB = $this->oCfg->getTimesliceBeginnings(false); + $oTsE = $this->oCfg->getTimesliceEndings(false); $ob = $this->getBookingByUid($nUid); $strLog = sprintf("Buchung in Raum „%s“ am %s von %s bis %s ". - "gelöscht", $ob->getRoom(), date("d\.m\.Y", $ob->getDate()), - $ob->getTsFirst(), $ob->getTsLast()); + "gelöscht (Begründung war: %s)", $ob->getRoom(), date("d\.m\.Y", + $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i", + $oTsE[$ob->getTsLast()]), $ob->getReason()); // Delete it from the database if(!db_query("DELETE FROM mod_roomreservation_bookings WHERE ". "rrb_uid = $1;", $nUid)) {