Added "whitelist" for rooms that can be booked, side effects: added new control mod_r...
authorrohieb <devnull@localhost>
Sat, 26 Jul 2008 02:14:58 +0000 (04:14 +0200)
committerrohieb <devnull@localhost>
Sat, 26 Jul 2008 02:14:58 +0000 (04:14 +0200)
doc/changelog.html [changed mode: 0644->0755]
includes/functions.inc
includes/mod_roomReservationBookingPage.inc
includes/mod_roomReservationBookingTable.inc
includes/mod_roomReservationBookingsManager.inc
includes/mod_roomReservationConfig.inc
includes/mod_roomReservationConfigPage.inc
includes/mod_roomReservationRoomWhitelistListBox.inc [new file with mode: 0644]
lang/mod_room-reservation.po
sql/mod_room-reservation.sql

old mode 100644 (file)
new mode 100755 (executable)
index 5a2c964..391d90c
@@ -16,8 +16,8 @@
   <li>Zugriffssteuerung über Sonderrechte (Gruppen-Verwaltung)<br />
     <b>Achtung:</b> Wenn eines der drei vom Raumbelegungsplan benutzten Sonderrechte keiner Gruppe
     zugewiesen wird, besitzen alle Benutzer dieses Portalservers das entsprechende Sonderrecht!</li>
-  <li>Räume werden in der Rechnerverwaltung angelegt <!--  FIXME und können in der Konfiguration zur
-    Buchung freigegeben werden --></li>
+  <li>Räume werden in der Rechnerverwaltung angelegt und können in der Konfiguration zur
+    Buchung freigegeben werden</li>
   <li>Komplette Neuentwicklung des Quellcodes auf Basis von PHP 5</li>
 </ul></li>
 <li>Alle Formulare werden innerhalb der Tabelle angezeigt, ebenso die
index 1416648..b174e88 100644 (file)
@@ -72,6 +72,9 @@ define("MOD_ROOM_RESERVATION_ERROR_CONFIG_NO_SUCH_TIMESLICE",
 /** There is no such account */
 define("MOD_ROOM_RESERVATION_ERROR_NO_SUCH_ACCOUNT", _c("room-reservation:".
   "The specified account does not exist."));
+/** The room is not available for booking */
+define("MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED",
+  _c("room-reservation:This room is not available for booking."));
 /**
  * @}
  */
index f17d447..219c7bd 100644 (file)
@@ -156,13 +156,6 @@ class mod_roomReservationBookingPage extends mod_roomReservationPage {
       die();
     }
     
-    if($this->oRm->getRooms() == array()) {
-      echo sprintf("<p>%s</p>\n", _c("room-reservation:No rooms have been ".
-       "configured yet."));
-      _PageBlue();
-      die();
-    }
-
     Title(_c("room-reservation:Book rooms"));
     
     // Form for room selection
@@ -171,19 +164,31 @@ class mod_roomReservationBookingPage extends mod_roomReservationPage {
       $_SERVER["PHP_SELF"]);
     echo sprintf("<input type='hidden' name='mod_roomReservationBookingTable".
       "[date]' value='%d' />\n", $this->getStart());
-    echo _c("room-reservation:Room:") . sprintf(" <select onchange=".
-      "'document.forms[\"room\"].submit()' width='250' ".
-       "name='mod_roomReservationBookingTable[room]'>\n", $this->getStart());
-    $aor = $this->oRm->getRooms();
-    foreach($aor as $or) {
-      // note to myself: no qu() here, seems this is being done automagically
-      echo sprintf("<option value='%s'%s>%s</option>\n", $or->getName(),
-        ($or->getName() == $this->getRoom()) ? " selected='selected'" : "",
-        $or->getName());
-    }
-    echo sprintf("</select>&nbsp;<%s value='%s' /></form><p />\n",
-      $GLOBALS["stdbtn"], _("Change"));
     
+    // Show rooms only if it is whitelisted
+    try {
+      $aor = $this->oCfg->getWhitelistedRooms();
+    } catch(SQLException $e) {
+      trigger_error($e->getMessage());
+    }
+    if(count($aor) > 0) {
+      echo _c("room-reservation:Room:") . sprintf(" <select onchange=".
+        "'document.forms[\"room\"].submit()' width='250' ".
+       "name='mod_roomReservationBookingTable[room]'>\n", $this->getStart());
+      foreach($aor as $or) {
+        // note to myself: no qu() here, seems this is being done automagically
+        echo sprintf("<option value='%s'%s>%s</option>\n", $or->getName(),
+          ($or->getName() == $this->getRoom()) ? " selected='selected'" : "",
+          $or->getName());
+      }
+      echo sprintf("</select>&nbsp;<%s value='%s' /></form><p />\n",
+        $GLOBALS["stdbtn"], _("Change"));
+    } else {
+      printf("<p>%s</p>\n", _c("room-reservation:No rooms have been ".
+       "configured yet."));
+      return;
+    }
+        
     // Print line with next 5 or so weeks
     $strSep = "&nbsp;| ";
     $strLink = sprintf("<a href='%s?mod_roomReservationBookingTable[date]=%%d".
index c672e52..706d757 100644 (file)
@@ -118,6 +118,8 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ {
   protected $strPostAccount;
   /** (int) recurrence interval, POST data */
   protected $nPostInterval;
+  /** (string) Array of error messages */
+  protected $asErrors = array();
   
   /***************************************************************************/
   /**
@@ -139,7 +141,11 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ {
     $this->oRm = $oRm;
     $this->oBm = $oBm;
    
-    $this->processRequestVariables();
+    try {
+      $this->processRequestVariables();
+    } catch(Exception $e) {
+      $this->asErrors[] = $e->getMessage();
+    }
     $this->addCSS();
   }
 
@@ -151,16 +157,19 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ {
    */
 
   /**
-   * Process the REQUEST variables and preset the some variables
+   * Process the REQUEST variables and preset the some variables. Throws an
+   * exception if the room provided by the GET data is not allowed for booking
    * @return void
+   * @throws Exception
    */
   protected function processRequestVariables() {
     
     // default values
-    $aoRooms = $this->oRm->getRooms();
-    if($aoRooms != array()) {
-      $or = $aoRooms[0];
-      $this->setRoom($or->getName());
+    $aoRooms = $this->oCfg->getWhitelistedRooms();
+    if(count($aoRooms) < 1) {
+      $this->setRoom("");
+    } else {
+      $this->setRoom($aoRooms[0]->getName());
     }
     $this->setDate(time());
     $this->setAction(MOD_ROOM_RESERVATION_BT_ACTION_SHOW);
@@ -179,8 +188,9 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ {
         MOD_ROOM_RESERVATION_BT_ACTION_SHOW)))));
       $this->setDate(isset($_GET["mod_roomReservationBookingTable"]["date"]) ?
         intval($_GET["mod_roomReservationBookingTable"]["date"]) : time());
-      $this->setRoom(isset($_GET["mod_roomReservationBookingTable"]["room"]) ?
-        $_GET["mod_roomReservationBookingTable"]["room"] : "");
+      if(isset($_GET["mod_roomReservationBookingTable"]["room"])) {
+        $this->setRoom($_GET["mod_roomReservationBookingTable"]["room"]);
+      }
       $this->setTsFirst(
         isset($_GET["mod_roomReservationBookingTable"]["tsfirst"]) ?
         intval($_GET["mod_roomReservationBookingTable"]["tsfirst"]) : 0);
@@ -295,10 +305,19 @@ class mod_roomReservationBookingsTable /* extends mclWidget */ {
  
   /**
    * Set the room of the requested booking or the room to be shown in the
-   * booking table
+   * booking table. Throws an Exception if the room is not allowed for booking.
    * @param $str (string)
+   * @throws Exception
    */
-  protected function setRoom($str) { $this->strRoom = $str; }
+  protected function setRoom($str) {
+    // only allow whitelisted rooms
+    if($this->oCfg->isRoomWhitelisted($str)) {
+      $this->strRoom = $str;
+    } else {
+      throw new Exception(_c("room-reservation:This room is not available ".
+       "for booking."));
+    }
+  }
  
   /**
    * Set the reason of the requested booking
@@ -424,7 +443,13 @@ CSS;
       throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
       return;
     }
-   
+    
+    // print error messages and return if there are any
+    if(count($this->asErrors) > 0) {
+      printf("<p class='err'>%s</p>", join("<br />\n", $this->asErrors));
+      return;
+    }
+    
     // Print the header with the days
     $ncTs = sizeof($this->oCfg->getTimeslices());
     $nDays = ($this->oCfg->isShowWeekend()) ? 7 : 5;
index 722c164..124068d 100644 (file)
@@ -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 = "";
 
index 9a2bf9c..bed261b 100644 (file)
  */
 
 require_once("sec/secure.inc");
+require_once("db.inc");
 require_once("mod_room-reservation/functions.inc");
 require_once("mod_room-reservation/mod_roomReservationTimeslice.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
 
 /**
  * Determines if a privilege has been assigned
@@ -166,6 +168,74 @@ class mod_roomReservationConfig {
    */
   public function flushTimeslices() { $this->aoTimeslices = array(); }
   
+  /**
+   * Add a room to the list of rooms who can be booked. Throws an SQLException
+   * in case of an error.
+   * @param $sRoom (string) The name of the room
+   * @throws SQLException, Exception
+   * @return void
+   */
+  public function whitelistRoom($sRoom) {
+    if(!$this->isRoomWhitelisted($sRoom)) {
+      $r = db_store("mod_roomreservation_roomswhitelist",
+        array("rrr_name" => $sRoom));
+      if(!$r) {
+        throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+      } else {
+        log_insert(sprintf("Raum „%s“ für Buchungen gesperrt", $sRoom));
+      }
+    }
+  }
+
+  /**
+   * Forbid bookings for a room. Throws an SQLException in case of an error.
+   * @param $sRoom The name of the room
+   * @throws SQLException
+   */
+  public function unWhitelistRoom($sRoom) {
+    $h = db_query("DELETE FROM mod_roomreservation_roomswhitelist WHERE ".
+       "rrr_name = $1;", $sRoom);
+    if(!$h) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+    } else {
+      log_insert(sprintf("Raum „%s“ für Buchungen zur Verfügung gestellt",
+        $sRoom));
+    }
+  }
+  
+  /**
+   * Determine if a room is allowed for booking. Throws an SQLException
+   * in case of an error.
+   * @param $sRoom (string) The name of the room
+   * @return bool
+   * @throws SQLException
+   */
+  public function isRoomWhitelisted($sRoom) {
+    $h = db_query("SELECT * FROM mod_roomreservation_roomswhitelist WHERE ".
+       "rrr_name=$1;", $sRoom);
+    if(!$h) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+    }
+    return (pg_num_rows($h) > 0);
+  }
+
+  /**
+   * Get all rooms that are allowed for booking. Throws an SQLException
+   * in case of an error. 
+   * @throws SQLException
+   * @return array of mod_roomReservationRoomsManager objects
+   */
+  public function getWhitelistedRooms() {
+    $aor = mod_roomReservationRoomsManager::getRooms();
+    $ar = array();
+    foreach($aor as $key => $or) {
+      if($this->isRoomWhitelisted($or->getName())) {
+        $ar[] = $or;
+      }
+    }
+    return $ar;
+  }
+
   /**
    * Show or hide the weekend
    * @param $b (bool)
index 55ee2eb..46ce45a 100644 (file)
@@ -29,6 +29,7 @@
 require_once("ctrl.inc");
 require_once("mod_room-reservation/mod_roomReservationPage.inc");
 require_once("mod_room-reservation/mod_roomReservationTimesliceListBox.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomWhitelistListBox.inc");
 
 /** @todo document */
 class mod_roomReservationConfigPage extends mod_roomReservationPage {
@@ -36,10 +37,13 @@ class mod_roomReservationConfigPage extends mod_roomReservationPage {
   protected $bPostShowWeekend;
   protected $bPostShowLessons;
   protected $asMessages = array();
+  protected $otlb;
+  protected $orwlb;
   
   public function __construct(mod_roomReservationConfig &$oCfg) {
     parent::__construct($oCfg);
-    
+    $this->otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
+    $this->orwlb = new mod_roomReservationRoomWhitelistListBox($this->oCfg);
     $this->setTitle(_c("room-reservation:Configuration"));
     $this->setIcon("mod_room-reservation_config");
   }
@@ -79,8 +83,17 @@ class mod_roomReservationConfigPage extends mod_roomReservationPage {
       printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
     }
     
+    // first column
     echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
-       "<td style='width:50%;'>\n"; // two rows
+       "<td style='width:50%;'>\n";
+    
+    GroupBox(_c("room-reservation:Available rooms"), "host");
+    printf("<p>%s</p>", _c("room-reservation:The following rooms are ".
+       "available for booking:"));
+    echo "<div style='margin:8px;'>";
+    $this->orwlb->show();
+    echo "</div>\n";
+    _GroupBox();
     
     GroupBox(_("Privileges"), "keys");
     $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
@@ -115,6 +128,18 @@ class mod_roomReservationConfigPage extends mod_roomReservationPage {
     echo "</tr></table></p>\n";
     _GroupBox();
 
+    // second column
+    echo "</td><td><!--second row-->\n";
+    
+    GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
+    printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
+       "periods where bookings can be undertaken. A booking period can ".
+       "e.&nbsp;g. correspond to a lesson."));
+    echo "<div style='margin:8px;'>";
+    $this->otlb->show();
+    echo "</div>\n";
+    _GroupBox();
+    
     GroupBox(_c("room-reservation:Further options"), "manage");
     printf("<div style='margin:8px;'><form action='%s' method='post'>".
        "<table><tr>\n", $_SERVER["PHP_SELF"]);
@@ -147,20 +172,7 @@ class mod_roomReservationConfigPage extends mod_roomReservationPage {
        "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
     echo "</tr></table></form></div>\n";
     _GroupBox();
-    
-    // second row
-    echo "</td><td><!--second row-->\n";
-    
-    GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
-    printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
-       "periods where bookings can be undertaken. A booking period can ".
-       "e.&nbsp;g. correspond to a lesson."));
-    echo "<div style='margin:8px;'>";
-    $otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
-    $otlb->show();
-    echo "</div>";
-    _GroupBox();
-    
+
     echo "</td></tr></table>\n";
   }
 }
diff --git a/includes/mod_roomReservationRoomWhitelistListBox.inc b/includes/mod_roomReservationRoomWhitelistListBox.inc
new file mode 100644 (file)
index 0000000..27bd6c2
--- /dev/null
@@ -0,0 +1,214 @@
+<?php
+/**\r
+ * @file mod_roomReservationRoomWhitelistListBox.inc\r
+ * List box that shows the rooms who can be booked\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 24.07.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+
+require_once("mod_roomReservationControl.inc");
+require_once("mod_roomReservationRoomsManager.inc");
+
+/*****************************************************************************/
+/**
+ * @page roomwhitelistlistbox_actions Actions of a 
+ * mod_roomReservationRoomWhitelistListBox instance
+ * @{
+ * The following constants describe the actions that a
+ * mod_roomReservationRoomWhitelistListBox instance can handle. They are used
+ * in processRequestVariables() to determine the action that should be done
+ * when the control is shown.
+ */
+/** Show the control (default action) */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW", 0);
+/** Show the addition form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_ADD", 1);
+/** Process the addition form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD", 2);
+/** Show the deletion form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE", 3);
+/** Process the deletion form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE", 4);
+/** @} */
+\r
+/** @todo document */
+class mod_roomReservationRoomWhitelistListBox 
+  extends mod_roomReservationControl {
+  /**
+   * (array of integers) OIDs of the rows in the rooms table that were 
+   * selected (POST data)
+   */
+  protected $anPostSelection = array();
+  /** (constant) Display mode, see @ref roomwhitelistlistbox_actions */
+  protected $cMode;
+  
+  protected function processRequestVariables() {
+    // default values
+    $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW;
+    
+    // POST data
+    if(isset($_POST["mod_roomReservationRoomWhitelistListBox"])) {
+      $aPost = $_POST["mod_roomReservationRoomWhitelistListBox"];
+      // mode
+      if(isset($aPost["action"])) {
+        if(isset($aPost["action"]["add"])) {
+          if($aPost["action"]["add"] == _("Add")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_ADD;
+          } elseif($aPost["action"]["add"] == _("OK")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD;
+          }
+        } elseif(isset($aPost["action"]["delete"])) {
+          if($aPost["action"]["delete"] == _("Delete")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE;
+          } elseif($aPost["action"]["delete"] == _("OK")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE;
+          }
+        }
+      }
+      // selection
+      if(isset($aPost["l"])) {
+        foreach($aPost["l"] as $nOid => $bChecked) {
+          if($bChecked) {
+            $this->anPostSelection[] = $nOid;
+          }
+        }
+      }
+    }
+    
+    // process the forms
+    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD) {
+      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+        qdb_arr($this->anPostSelection));
+      while($a = pg_fetch_array($h)) {
+        $this->oCfg->whitelistRoom($a["name"]);
+      }
+    }
+
+    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE) {
+      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+        qdb_arr($this->anPostSelection));
+      while($a = pg_fetch_array($h)) {
+        $this->oCfg->unWhitelistRoom($a["name"]);
+      }
+    }
+  }
+  
+  protected function doShow() {
+    echo "<form method='post'>";
+    TreeView(array(_("Room")));
+    switch($this->cMode) {
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE:
+        $this->showDeleteForm();
+        break;
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_ADD: $this->showAddForm(); break;
+      default:
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW: $this->showForm(); break;
+    }
+    _TreeView();
+    echo "</form>\n";
+  }
+
+  /**
+   * Print the form if not delete nor add was requested
+   * @return void
+   */
+  protected function showForm() {
+    $aoRooms = $this->oCfg->getWhitelistedRooms();
+    // only show add button if there are still some unlisted rooms
+    if(count(mod_roomReservationRoomsManager::getRooms()) > count($aoRooms)) {
+      TreeViewLine(sprintf("<%s name='mod_roomReservationRoomWhitelistListBox".
+        "[action][add]' value='%s' /></form>", $GLOBALS["stdbtn"], _("Add")));
+    }
+    $this->showList($aoRooms);
+    // toolbar
+    printf("<tr><td class='tbbtm' colspan='%d'>", $GLOBALS["treeview_cols"]);
+    CheckCombo();
+    printf("<%s name='mod_roomReservationRoomWhitelistListBox[action]".
+       "[delete]' value='%s' />", $GLOBALS["stdbtn"], _("Delete"));
+    echo "</td></tr>\n";
+  }
+  
+  /**
+   * Print the addition form
+   * @return void
+   */
+  protected function showAddForm() {
+    // only list rooms that are not already whitelisted
+    $aoRooms = array_diff(mod_roomReservationRoomsManager::getRooms(),
+      $this->oCfg->getWhitelistedRooms());
+    TreeViewSubtitle(_("Add"));
+    $this->showList($aoRooms);
+    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
+       "Box[action][add]' value='%s' /> <%s name='mod_roomReservationRoom".
+       "WhitelistListBox[action][add]' value='%s' /></p>", $GLOBALS["stdbtn"],
+       _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
+  }
+  
+  /**
+   * Show the deletion form
+   * @return void
+   */
+  protected function showDeleteForm() {
+    // list rooms in selection
+    $aoRooms = array();
+    $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+      qdb_arr($this->anPostSelection));
+    foreach($this->anPostSelection as $nOid) {
+      $aoRooms[] = mod_roomReservationRoomsManager::getRoomByOid($nOid);
+    }
+    TreeViewSubtitle(sprintf(_("Following %s will be deleted"),
+      _c("room-reservation:rooms")));
+    $this->showList($aoRooms, false);
+    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
+       "Box[action][delete]' value='%s' /> <%s name='mod_roomReservationRoom".
+       "WhitelistListBox[action][delete]' value='%s' /></p>",
+       $GLOBALS["stdbtn"], _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
+  }
+  
+  /**
+   * Show the list items
+   * @param $aoRooms (array of mod_roomReservationRoom objects) List items
+   * @param $bCheckboxes (bool) Whether to show checkboxes
+   */
+  protected function showList($aoRooms, $bCheckboxes = true) {
+    if(count($aoRooms) > 0) {
+      foreach($aoRooms as $o) {
+        // fetch oid from SQL table
+        $nOid = pg_fetch_result(db_query("SELECT oid FROM ".
+          "rooms WHERE name = $1", $o->getName()), 0, "oid");
+        $sBox = $bCheckboxes ? sprintf("<%s id='box%d' name='mod_room".
+               "ReservationRoomWhitelistListBox[l][%d]' value='1'%s /><label ".
+               "for='box%d'>%s%s</label>", $GLOBALS["smlchk"], $nOid, $nOid,
+          @$this->anPostSelection[$nOid] ? " checked='checked'" : "", $nOid,
+          icon("host"), $o->getName()) : 
+          sprintf("<input type='hidden' name='mod_roomReservationRoom".
+               "WhitelistListBox[l][%d]' value='1' />%s%s", $nOid, icon("host"),
+          $o->getName());
+        TreeViewLine($sBox);
+      }
+    } else {
+      TreeViewEmpty();
+    }
+  }
+}
+?>
\ No newline at end of file
index 2d1f0d5..6650b03 100644 (file)
@@ -38,6 +38,9 @@ msgid "Administration of the room reservation schedule"
 msgstr "Administration des Raumbelegungsplans"
 
 # Other things
+msgid "room-reservation:rooms"
+msgstr "room-reservation:Räume"
+
 msgid "room-reservation:Access denied."
 msgstr "room-reservation:Zugriff verweigert."
 
@@ -123,9 +126,15 @@ msgstr "room-reservation:Vor &gt;"
 msgid "room-reservation:%d# week"
 msgstr "room-reservation: %d. Woche"
 
+msgid "room-reservation:Available rooms"
+msgstr "room-reservation:Verfügbare Räume"
+
 msgid "room-reservation:No rooms have been configured yet."
 msgstr "room-reservation:Es wurden noch keine Räume eingerichtet."
 
+msgid "room-reservation:This room is not available for booking."
+msgstr "room-reservation:Dieser Raum steht nicht für Buchungen zu Verfügung."
+
 msgid "room-reservation:Schedule of room bookings"
 msgstr "room-reservation:Raumbelegungsplan"
 
@@ -179,6 +188,10 @@ msgstr "room-reservation:Es ist zu beachten, dass jede Gruppe mit Buchungs-"
   "Gruppe mit Administrations-Sonderrecht kann ebenso implizit Buchungen "
   "vornehmen und die Buchungstabelle einsehen."
 
+msgid "room-reservation:The following rooms are available for booking:"
+msgstr "room-reservation:Die folgenden Räume stehen für Buchungen zur "
+       "Verfügung:"
+
 msgid "room-reservation:Here you can fill in the periods where bookings can "
   "be undertaken. A booking period can e.&nbsp;g. correspond to a lesson."
 msgstr "room-reservation:Hier die Zeitstunden der Buchungszeiträume eingeben. "
index a4cf33f..b6bfd65 100644 (file)
@@ -1,5 +1,14 @@
 --\r
--- Table with bookings for module iserv-room-reservation\r
+-- Table with rooms allowed for booking\r
+-- \r
+CREATE TABLE mod_roomreservation_roomswhitelist (\r
+               rrr_name                         TEXT                    UNIQUE REFERENCES rooms(name)\r
+                             ON DELETE CASCADE\r
+                             ON UPDATE CASCADE\r
+);\r
+\r
+--\r
+-- Table with bookings\r
 --\r
 CREATE TABLE mod_roomreservation_bookings (\r
     rrb_uid        SERIAL    NOT NULL PRIMARY KEY, -- Unique ID \r
@@ -25,3 +34,5 @@ CREATE TABLE mod_roomreservation_bookings (
 --\r
 GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webusr;\r
 GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webadm;\r
+GRANT SELECT ON mod_roomreservation_roomswhitelist TO webusr;\r
+GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_roomswhitelist TO webadm;\r
This page took 0.078139 seconds and 4 git commands to generate.