* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- *
- * @todo move some functions into M Class Library
*/
require_once("share.inc");
* @param $ob (mod_roomReservationBooking) Booking to write to the database
* @return (int) The UID of the written booking
* @throws SQLException, AccessException
- * @todo document
*/
function write(mod_roomReservationBooking $ob) {
// protect access
* Delete a booking from the database
* @param $nUid (int) Unique ID of the booking
* @return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
- * @todo test
*/
public function delete($nUid) {
// Only administrators and owners are allowed to delete bookings
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- *
- * @todo move into M Class Library
*/
/**
* @author Roland Hieber (roland.hieber@wilhelm-gym.net)
* @date 28.12.2007
*
- * TODO: move into M Class Library
* Copyright © 2007 Roland Hieber
*
* Permission is hereby granted, free of charge, to any person obtaining
public function __construct(mod_roomReservationConfig &$oCfg) {
$this->oCfg = $oCfg;
}
-
- /**
- * Insert or update a room in the database
- * param $or (rsRoom) Room to store in the database
- * return (int) The UID of the booking, or <tt>-1</tt> in case of a failure.
- * Call getLastError() to get more information about the error.
- */
-/** public function write(rsRoom $or) {
- // Only administrators are allowed to create and alter rooms
- if(!$this->oCfg->userIsAdmin()) {
- // TODO throw exception
- setLastError(RS_ERROR_ACCESS_DENIED);
- return -1;
- }
-
- $strWhere = "";
- $strLog = "";
-
- // Update or insert?
- if($or->getUid() == null) {
- // No UID yet, insert new room
- $strLog = sprintf("Raum „%s“ angelegt", $or->getName());
- } else {
- $strWhere = "rsr_uid = ".qp(intval($or->getUid()));
- $strLog = sprintf("Raum „%s“ geändert", $or->getName());
- }
-
- $aPut["rsr_name"] = $or->getName();
- db_store("rooms", $aPut, $strWhere == "" ? null : $strWhere);
-
- $hQuery = db_query("SELECT currval('roomschedule_rooms_rsr_uid_seq') ".
- "FROM roomschedule_rooms;");
- $nNewUid = pg_fetch_result($hQuery, 0, "currval");
-
- rrInsertLog($strLog);
-
- // Return new UID
- return $nNewUid;
- }
- */
- /**
- * Delete a room from the database
- * param $nUid (int) Unique ID of the room
- * return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
- * Call getLastError() to get more information about the error.
- */
-/* public function delete($nUid) {
- // Only administrators are allowed to delete rooms
- if(!$this->oCfg->userIsAdmin()) {
- // TODO throw exception
- setLastError(RS_ERROR_ACCESS_DENIED);
- return false;
- }
- // Delete it from the database
- $strRoom = $this->getRoomName($nUid);
- if(!db_query("DELETE FROM roomschedule_rooms WHERE rsr_uid = $1;",
- intval($nUid))) {
- // TODO throw exception
- setLastError(RS_ERROR_SQL);
- return false;
- } else {
- rsInsertLog(sprintf("Raum „%s“ gelöscht", $strRoom));
- return true;
- }
- }
-*/
/**
* Get a room by its OID. Returns <tt>null</tt> if the room was not found.
-- Table with bookings
--
CREATE TABLE mod_roomreservation_bookings (
- rrb_uid SERIAL NOT NULL PRIMARY KEY, -- Unique ID
- rrb_room TEXT NOT NULL -- Name of the room
+ rrb_uid SERIAL NOT NULL -- Unique ID
+ PRIMARY KEY,
+ rrb_room TEXT NOT NULL -- Name of the room
REFERENCES rooms(name)
ON DELETE CASCADE
ON UPDATE CASCADE,
- rrb_date DATE NOT NULL, -- Date of the booking
- rrb_tsfirst SMALLINT NOT NULL, -- Number of the first timeslice
- rrb_tslast SMALLINT NOT NULL -- Number of the last timeslice
+ rrb_date DATE NOT NULL, -- Date of the booking
+ rrb_tsfirst SMALLINT NOT NULL, -- Number of the first timeslice
+ rrb_tslast SMALLINT NOT NULL -- Number of the last timeslice
CHECK(rrb_tsfirst <= rrb_tslast),
- rrb_act TEXT NOT NULL -- Owner of the booking
+ rrb_act TEXT NOT NULL -- Owner of the booking
REFERENCES users(Act)
ON DELETE CASCADE
ON UPDATE CASCADE,
- rrb_reason TEXT NOT NULL, -- Reason
- rrb_interval SMALLINT NOT NULL -- Interval in weeks for recurring bookings
- DEFAULT 0
+ rrb_reason TEXT NOT NULL, -- Reason
+ rrb_interval SMALLINT NOT NULL -- Interval in weeks for
+ DEFAULT 0 -- recurring bookings
);
--
-- Permissions
--
-GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webusr;
-GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webadm;
+GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings,
+ mod_roomreservation_bookings_rrb_uid_seq TO webusr;
+GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings,
+ mod_roomreservation_bookings_rrb_uid_seq TO webadm;
GRANT SELECT ON mod_roomreservation_roomswhitelist TO webusr;
-GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_roomswhitelist TO webadm;
+GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_roomswhitelist
+ TO webadm;
* THE SOFTWARE.
*/
-/** @todo document */
-
require_once("sec/admsecure.inc");
require_once("mod_room-reservation/globals.inc");
require_once("mod_room-reservation/mod_roomReservationConfigPage.inc");