3 * @file mod_roomReservationConfigPage.inc
4 * The configuration page
5 * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
8 * Copyright © 2007 Roland Hieber
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:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
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
29 require_once("ctrl.inc");
30 require_once("mod_room-reservation/mod_roomReservationPage.inc");
31 require_once("mod_room-reservation/mod_roomReservationTimesliceListBox.inc");
34 class mod_roomReservationConfigPage extends mod_roomReservationPage {
36 protected $bPostShowWeekend;
37 protected $bPostShowLessons;
38 protected $asMessages = array();
40 public function __construct(mod_roomReservationConfig &$oCfg) {
41 parent::__construct($oCfg);
43 $this->setTitle(_c("room-reservation:Configuration"));
44 $this->setIcon("mod_room-reservation_config");
47 public function processRequestVariables() {
49 $this->bPostShowWeekend = $this->oCfg->isShowWeekend();
50 $this->bPostShowLessons = $this->oCfg->isShowLessons();
52 if(isset($_POST["mod_roomReservationConfigPage"])) {
53 if(isset($_POST["mod_roomReservationConfigPage"]["showweekend"])) {
54 $this->bPostShowWeekend =
55 ($_POST["mod_roomReservationConfigPage"]["showweekend"] == true);
58 echo "bPostShowWeekend is ".($this->bPostShowWeekend?"true ":"false ");
61 if(isset($_POST["mod_roomReservationConfigPage"]["showlessons"])) {
62 $this->bPostShowLessons =
63 ($_POST["mod_roomReservationConfigPage"]["showlessons"] == true);
66 echo "bPostShowLessons is ".($this->bPostShowLessons?"true ":"false ");
69 // process the request
70 if(isset($_POST["mod_roomReservationConfigPage"]["submit"])) {
71 $this->oCfg->setShowWeekend($this->bPostShowWeekend);
72 $this->oCfg->setShowLessons($this->bPostShowLessons);
74 $this->oCfg->writeConfig();
75 } catch(Exception $e) {
76 $this->asMessages[] = $e->getMessage();
82 public function doShow() {
84 if(count($this->asMessages) > 0) {
85 printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
88 echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
89 "<td style='width:50%;'>\n"; // two rows
91 GroupBox(_("Privileges"), "keys");
92 $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
93 $asBookGroups = rrPrivilegedGroups("mod_roomreservation_book");
94 $asViewGroups = rrPrivilegedGroups("mod_roomreservation_view");
95 echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("room-reservation:This is ".
96 "a short summary of the privileges related to the room reservation ".
97 "schedulde and the groups which have them assigned."),
98 sprintf(_c("room-reservation:If one of these privileges is not assigned to ".
99 "any group, all users on this server are allowed to perform the specified ".
100 "action. Please use the %sgroup administration%s to assign and revoke ".
101 "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
102 _c("room-reservation:Please note that every group with the booking ".
103 "privilege can also implicitly view the booking table and every group with ".
104 "the administration privilege can also implicitly book and view the ".
106 echo "<p><table style='width:100%'><tr>\n";
107 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
108 _("View the booking table").":", $asViewGroups == array() ?
109 _c("room-reservation:all users") : icon("act-group") . join(", ",
110 array_map("getGroupName", $asViewGroups)));
112 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
113 _("Book rooms").":", $asBookGroups == array() ?
114 _c("room-reservation:all users") : icon("act-group") . join(", ",
115 array_map("getGroupName", $asBookGroups)));
117 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
118 _("Administration of the room reservation schedule"),
119 $asAdminGroups == array() ? _c("room-reservation:all users") :
120 icon("act-group") . join(", ", array_map("getGroupName", $asAdminGroups)));
121 echo "</tr></table></p>\n";
124 GroupBox(_c("room-reservation:Further options"), "manage");
125 printf("<div style='margin:8px;'><form action='%s' method='post'>".
126 "<table><tr>\n", $_SERVER["PHP_SELF"]);
128 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
129 "[showweekend]' value='0' /><%s name='mod_roomReservationConfigPage".
130 "[showweekend]' id='mod_roomReservationConfigPageShowWeekend' ".
131 "value='1' %s /></td><td><label for='".
132 "mod_roomReservationConfigPageShowWeekend'><b>%s</b></label><br />".
133 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
134 $GLOBALS["smlchk"], $this->bPostShowWeekend ? "checked='checked' " : "",
135 _c("room-reservation:Show weekend"), _c("room-reservation:If ".
136 "selected, the weekdays saturday and sunday are also shown in the ".
140 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
141 "[showlessons]' value='0' /><%s name='mod_roomReservationConfigPage".
142 "[showlessons]' id='mod_roomReservationConfigPageShowLessons' ".
143 "value='1'%s /></td><td><label for='".
144 "mod_roomReservationConfigPageShowLessons'><b>%s</b></label><br />".
145 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
146 $GLOBALS["smlchk"], $this->bPostShowLessons ? "checked='checked' " : "",
147 _c("room-reservation:Show „lesson” texts"),
148 _c("room-reservation:Check this box to show texts like ".
149 "„<i>n</i>th lesson&rdquo in the booking page. If this box is ".
150 "unchecked, none of these texts are shown."));
152 printf("</tr><tr><td colspan='2'><%s name='mod_roomReservationConfigPage".
153 "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
154 echo "</tr></table></form></div>\n";
158 echo "</td><td><!--second row-->\n";
160 GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
161 printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
162 "periods where bookings can be undertaken. A booking period can ".
163 "e. g. correspond to a lesson."));
164 echo "<div style='margin:8px;'>";
165 $otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
170 echo "</td></tr></table>\n";