* @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.