administration: link to the computer administration page for management of rooms
[iserv-mod-room-reservation.git] / inc / mod_roomReservationConfigPage.inc
1 <?php
2 /**
3 * @file mod_roomReservationConfigPage.inc
4 * The configuration page
5 * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
6 * @date 24.06.2008
7 *
8 * Copyright © 2007 Roland Hieber
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 * THE SOFTWARE.
27 */
28
29 require_once("ctrl.inc");
30 require_once("mod_room-reservation/mod_roomReservationPage.inc");
31 require_once("mod_room-reservation/mod_roomReservationTimesliceListBox.inc");
32 require_once("mod_room-reservation/mod_roomReservationRoomWhitelistListBox.inc");
33
34 /** @todo document */
35 class mod_roomReservationConfigPage extends mod_roomReservationPage {
36
37 protected $bPostShowWeekend;
38 protected $bPostShowLessons;
39 protected $asMessages = array();
40 protected $otlb;
41 protected $orwlb;
42
43 public function __construct(mod_roomReservationConfig &$oCfg) {
44 parent::__construct($oCfg);
45 $this->otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
46 $this->orwlb = new mod_roomReservationRoomWhitelistListBox($this->oCfg);
47 $this->setTitle(_c("room-reservation:Configuration"));
48 $this->setIcon("mod_room-reservation_config");
49 }
50
51 public function processRequestVariables() {
52 // default values
53 $this->bPostShowWeekend = $this->oCfg->isShowWeekend();
54 $this->bPostShowLessons = $this->oCfg->isShowLessons();
55
56 if(isset($_POST["mod_roomReservationConfigPage"])) {
57 if(isset($_POST["mod_roomReservationConfigPage"]["showweekend"])) {
58 $this->bPostShowWeekend =
59 ($_POST["mod_roomReservationConfigPage"]["showweekend"] == true);
60 }
61
62 if(isset($_POST["mod_roomReservationConfigPage"]["showlessons"])) {
63 $this->bPostShowLessons =
64 ($_POST["mod_roomReservationConfigPage"]["showlessons"] == true);
65 }
66
67 // process the request
68 if(isset($_POST["mod_roomReservationConfigPage"]["submit"])) {
69 $this->oCfg->setShowWeekend($this->bPostShowWeekend);
70 $this->oCfg->setShowLessons($this->bPostShowLessons);
71 try {
72 $this->oCfg->writeConfig();
73 } catch(Exception $e) {
74 $this->asMessages[] = $e->getMessage();
75 }
76 }
77 }
78 }
79
80 public function doShow() {
81 // error messages
82 if(count($this->asMessages) > 0) {
83 printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
84 }
85
86 // first column
87 echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
88 "<td style='width:50%;'>\n";
89
90 GroupBox(_c("room-reservation:Available rooms"), "host");
91 printf("<p>%s</p>", sprintf(_c("room-reservation:The following rooms are ".
92 "available for booking (you can add and delete rooms on the <a href='".
93 "/idesk/inet/admin/'>computer administration page</a>):")));
94 echo "<div style='margin:8px;'>";
95 $this->orwlb->show();
96 echo "</div>\n";
97 _GroupBox();
98
99 GroupBox(_("Privileges"), "keys");
100 $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
101 $asBookGroups = rrPrivilegedGroups("mod_roomreservation_book");
102 $asViewGroups = rrPrivilegedGroups("mod_roomreservation_view");
103 echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("room-reservation:This is ".
104 "a short summary of the privileges related to the room reservation ".
105 "schedulde and the groups which have them assigned."),
106 sprintf(_c("room-reservation:If one of these privileges is not assigned to ".
107 "any group, all users on this server are allowed to perform the specified ".
108 "action. Please use the %sgroup administration%s to assign and revoke ".
109 "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
110 _c("room-reservation:Please note that every group with the booking ".
111 "privilege can also implicitly view the booking table and every group with ".
112 "the administration privilege can also implicitly book and view the ".
113 "booking table."));
114 echo "<p><table style='width:100%'><tr>\n";
115 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
116 _("View the booking table").":", $asViewGroups == array() ?
117 _c("room-reservation:all users") : icon("act-group") . join(", ",
118 array_map("getGroupName", $asViewGroups)));
119 echo "</tr><tr>\n";
120 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
121 _("Book rooms").":", $asBookGroups == array() ?
122 _c("room-reservation:all users") : icon("act-group") . join(", ",
123 array_map("getGroupName", $asBookGroups)));
124 echo "</tr><tr>\n";
125 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
126 _("Administration of the room reservation schedule"),
127 $asAdminGroups == array() ? _c("room-reservation:no users") :
128 icon("act-group") . join(", ", array_map("getGroupName", $asAdminGroups)));
129 echo "</tr></table></p>\n";
130 _GroupBox();
131
132 // second column
133 echo "</td><td><!--second row-->\n";
134
135 GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
136 printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
137 "periods where bookings can be undertaken. A booking period can ".
138 "e.&nbsp;g. correspond to a lesson."));
139 echo "<div style='margin:8px;'>";
140 $this->otlb->show();
141 echo "</div>\n";
142 _GroupBox();
143
144 GroupBox(_c("room-reservation:Further options"), "manage");
145 printf("<div style='margin:8px;'><form action='%s' method='post'>".
146 "<table><tr>\n", $_SERVER["PHP_SELF"]);
147
148 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
149 "[showweekend]' value='0' /><%s name='mod_roomReservationConfigPage".
150 "[showweekend]' id='mod_roomReservationConfigPageShowWeekend' ".
151 "value='1' %s /></td><td><label for='".
152 "mod_roomReservationConfigPageShowWeekend'><b>%s</b></label><br />".
153 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
154 $GLOBALS["smlchk"], $this->bPostShowWeekend ? "checked='checked' " : "",
155 _c("room-reservation:Show weekend"), _c("room-reservation:If ".
156 "selected, the weekdays saturday and sunday are also shown in the ".
157 "booking table."));
158
159 echo "</tr><tr>\n";
160 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
161 "[showlessons]' value='0' /><%s name='mod_roomReservationConfigPage".
162 "[showlessons]' id='mod_roomReservationConfigPageShowLessons' ".
163 "value='1'%s /></td><td><label for='".
164 "mod_roomReservationConfigPageShowLessons'><b>%s</b></label><br />".
165 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
166 $GLOBALS["smlchk"], $this->bPostShowLessons ? "checked='checked' " : "",
167 _c("room-reservation:Show &bdquo;lesson&rdquo; texts"),
168 _c("room-reservation:Check this box to show texts like ".
169 "&bdquo;<i>n</i>th lesson&rdquo in the booking page. If this box is ".
170 "unchecked, none of these texts are shown."));
171
172 printf("</tr><tr><td colspan='2'><%s name='mod_roomReservationConfigPage".
173 "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
174 echo "</tr></table></form></div>\n";
175 _GroupBox();
176
177 echo "</td></tr></table>\n";
178 }
179 }
180 ?>
This page took 0.054113 seconds and 5 git commands to generate.