Added tag REL_3.0 for changeset 2f7a0ec28e849e3eeb2b530714458f9c0ef6ed56
[iserv-mod-room-reservation.git] / includes / mod_roomReservationRoomsManager.inc
index 8271a04..edce221 100644 (file)
@@ -113,11 +113,45 @@ class mod_roomReservationRoomsManager {
   }
 */
 
+  /**
+   * Get a room by its OID. Returns <tt>null</tt> if the room was not found.
+   * @param $nOid (integer) The OID of the room
+   * @return mod_roomReservationRoom
+   */
+  static function getRoomByOid($nOid) {
+    $o = null;
+    $h = db_query("SELECT * FROM rooms WHERE oid = $1;", $nOid);
+    if(pg_num_rows($h) > 0) {
+      $arResult = pg_fetch_array($h);
+      $o = new mod_roomReservationRoom($arResult["name"], 
+        $arResult["room_no"], $arResult["floor"], $arResult["building"],
+        $arResult["location"]);
+    }
+    return $o;
+  }
+  
+  /**
+   * Get a room by its name. Returns <tt>null</tt> if the room was not found.
+   * @param $sName (string) The name of the room
+   * @return mod_roomReservationRoom
+   */
+  static function getRoomByName($sName) {
+    $o = null;
+    $h = db_query("SELECT * FROM rooms WHERE name = $1;", $sName);
+    if(pg_num_rows($h) > 0) {
+      $arResult = pg_fetch_array($h);
+      $o = new mod_roomReservationRoom($arResult["name"], 
+        $arResult["room_no"], $arResult["floor"], $arResult["building"],
+        $arResult["location"]);
+    }
+    return $o;
+  }
+  
   /**
    * Get all rooms from the database
    * @return array of mod_roomReservationRoom
    */
-  function getRooms() {
+  static function getRooms() {
     $aoReturn = array();
     $hQuery = db_query("SELECT * FROM rooms ORDER BY name;");
     while($arResult = pg_fetch_array($hQuery)) {
This page took 0.022824 seconds and 4 git commands to generate.