includes/config.inc
debian/files
.buildpath
+
+syntax: regexp
+^\.cache$
+syntax: regexp
+^\.cache$
+syntax: regexp
+^\.settings$
+syntax: regexp
+^\.buildpath$
\ No newline at end of file
-iserv-mod-room-reservation (9.10.22-0) unstable; urgency=low
+iserv-mod-room-reservation (9.10.23-1) unstable; urgency=low
- * FIX: since postgresql-8.3, sequences are not allowed to have INSERT and DELETE
- rights, results in warning
+ * FIX: since postgresql-8.3, sequences are not allowed to have INSERT and
+ DELETE rights, results in warning
* debian/control: added fields for IServ "app store"
-- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net> Thu, 22 Oct 2009 21:41:40 +0200
* 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");
}
/**
- * Get the real user name for an account name
+ * Get the real user name for an account name. If the function fails, it throws
+ * an Exception.
* @param $strAct (string) Account name of the user to look up
- * @return (string) The real name of the user. If the function fails, it returns <tt>null</tt>.
- * Call getLastError() to get more information about the error.
+ * @return (string) The real name of the user.
+ * @throws Exception
*/
function getRealUserName($strAct) {
- $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct);
+ $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;",
+ $strAct);
if(!is_resource($hQuery)) {
- // TODO throw exception
- setLastError(RS_ERROR_SQL);
- return null;
+ throw new Exception(RS_ERROR_SQL);
}
if(pg_num_rows($hQuery) == 0) {
return $strAct; // User not found in database, return account name
}
/**
- * Determine if a specified group exists
+ * Determine if a specified group exists. If the function fails, it throws an
+ * Exception.
* @param $strAct (string) Account name of the group
- * @return (bool / null) If the function fails, it returns <tt>null</tt>. Call getLastError() to
- * get more information about the error.
+ * @return bool
+ * @throws Exception
*/
function isGroup($strAct) {
$hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
if(!is_resource($hQuery)) {
- // TODO throw exception
- setLastError(RS_ERROR_SQL);
- return null;
+ throw new Exception(RS_ERROR_SQL);
}
return (pg_num_rows($hQuery) > 0);
}
/**
- * Look up the name of a group
+ * Look up the name of a group. If the function fails, it throws an Exception.
* @param $strAct (string) Account name of the group
- * @return (string) The name of the group. If the function fails, it returns <tt>null</tt>.
- * Call getLastError() to get more information about the error.
+ * @return (string) The name of the group.
*/
function getGroupName($strAct) {
$hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
if(!is_resource($hQuery)) {
- // TODO throw exception
- setLastError(RS_ERROR_SQL);
- return null;
+ throw new Exception(RS_ERROR_SQL);
}
if(pg_num_rows($hQuery) == 0) {
return $strAct; // Group not found in database, return account name
}
/**
- * Create a link to write a mail to the specified account name.
- * This function returns a link if the specified account exists, otherwise it returns the
- * account name.
+ * Create a link to write a mail to the specified account name. Returns a link
+ * if the specified account exists, otherwise it returns the account name.
* @param $strAct (string) Account name
* @param $strColor (string) Background color for icon()
* @param $strParams (string) additional URL parameters
* @return string
*/
function isMailAddress($strAddr) {
- return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0)
- and (preg_match("/(\s*,\s*)$/", $strAddr) == 0));
+ return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/",
+ $strAddr) > 0) && (preg_match("/(\s*,\s*)$/", $strAddr) == 0));
}
/**
- * Module-specific logging function.
- * Prefixes the log message with a module-specific string and writes it to the logs.
+ * Module-specific logging function. Prefixes the log message with a
+ * module-specific string and writes it to the logs.
* @param $strLog (string) Log message
* @return void
*/
* Get all bookings in database which overlap with the given booking.
* @param $ob (mod_roomReservationBooking) New booking that should be tested
* if it overlaps
+ * @param $bUnblocks (bool) If true, consider $ob as a unblock of a specific
+ * booking. In this case, you have to specify the Unique ID of the original
+ * booking in $ob->
* @return array with elements of type mod_roomReservationBooking
*/
public static function getOverlappingBookings(
- mod_roomReservationBooking $ob) {
+ mod_roomReservationBooking $ob, $bUnblocks = false) {
// TODO: Test for bookings that only take place every n.th week (modulo n)
// Two bookings overlap, when they are on the same day and if
* @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
return true;
}
}
+
+ /**
+ * Unblocks a booking for a specific time. Useful to release a room for a
+ * specific time if it has been blocked by a recurring booking
+ * @param $nUid Unique ID of the booking to be unblocked
+ * @param $tsStart The timestamp when the unblock starts
+ * @param $tsEnd The timestamp when the unblock ends
+ * @return bool
+ * @todo implement this
+ */
+ function unblock($nUid, $tsStart, $tsEnd) {
+ // unblocking only allowed to owners and admins
+ if(!$this->userIsOwner($nUid) || !$this->cfg->userIsAdmin()) {
+ throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+ }
+ return false;
+ }
+
+ /**
+ * Re-blocks a booking that has been unblocked by unblock().
+ * @param $nUid Unique ID of the booking to be unblocked
+ * @return bool
+ * @todo implement this
+ */
+ function reblock($nUid, $tsStart, $tsEnd) {
+ // re-blocking only allowed to owners and admins
+ if(!$this->userIsOwner($nUid) || !$this->cfg->userIsAdmin()) {
+ throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+ }
+ return false;
+ }
/**
* Determine if the current user is the owner of a specified error report.
/*****************************************************************************/
/**
* Handling of the configuration file
- * @todo document
*/
class mod_roomReservationConfig {
/**
* Determine if the current user has admin rights. This function tests
* if the user is in a group which has the privilege of admin rights.
- * @todo test
* @return bool
*/
public function userIsAdmin() {
* Determine if the current user can book rooms. This function tests
* if the user is in a group which has the privilege to book rooms.
* If no group has this privilege, all users can book.
- * @todo test
* @return bool
*/
public function userCanBook() {
* if the user is in a group which has been configured as a group who
* can view bookings. If no groups are configured, any user can view the
* bookings table.
- * @todo test
* @return bool
*/
public function userCanView() {
* 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.
--
CREATE TABLE mod_roomreservation_bookings (
rrb_uid SERIAL NOT NULL PRIMARY KEY, -- Unique ID
- rrb_room TEXT NOT NULL -- Name of the room
+ 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
+ rrb_reason TEXT NOT NULL, -- Reason
+ rrb_interval SMALLINT NOT NULL -- Interval in weeks for recurring
+ -- bookings
DEFAULT 0
);
--
-- Permissions
--
-GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings TO webusr, webadm;
-GRANT SELECT, UPDATE ON mod_roomreservation_bookings_rrb_uid_seq TO webusr, webadm;
+GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings TO webusr,
+ webadm;
+GRANT SELECT, UPDATE ON mod_roomreservation_bookings_rrb_uid_seq TO webusr,
+ 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");