uninstall: removed separator lines
[iserv-mod-room-reservation.git] / includes / 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
33 /** @todo document */
34 class mod_roomReservationConfigPage extends mod_roomReservationPage {
35
36 protected $bPostShowWeekend;
37 protected $bPostShowLessons;
38 protected $asMessages = array();
39
40 public function __construct(mod_roomReservationConfig &$oCfg) {
41 parent::__construct($oCfg);
42
43 $this->setTitle(_c("room-reservation:Configuration"));
44 $this->setIcon("mod_room-reservation_config");
45 }
46
47 public function processRequestVariables() {
48 // default values
49 $this->bPostShowWeekend = $this->oCfg->isShowWeekend();
50 $this->bPostShowLessons = $this->oCfg->isShowLessons();
51
52 if(isset($_POST["mod_roomReservationConfigPage"])) {
53 if(isset($_POST["mod_roomReservationConfigPage"]["showweekend"])) {
54 $this->bPostShowWeekend =
55 ($_POST["mod_roomReservationConfigPage"]["showweekend"] == true);
56 }
57
58 if(isset($_POST["mod_roomReservationConfigPage"]["showlessons"])) {
59 $this->bPostShowLessons =
60 ($_POST["mod_roomReservationConfigPage"]["showlessons"] == true);
61 }
62
63 // process the request
64 if(isset($_POST["mod_roomReservationConfigPage"]["submit"])) {
65 $this->oCfg->setShowWeekend($this->bPostShowWeekend);
66 $this->oCfg->setShowLessons($this->bPostShowLessons);
67 try {
68 $this->oCfg->writeConfig();
69 } catch(Exception $e) {
70 $this->asMessages[] = $e->getMessage();
71 }
72 }
73 }
74 }
75
76 public function doShow() {
77 // error messages
78 if(count($this->asMessages) > 0) {
79 printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
80 }
81
82 echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
83 "<td style='width:50%;'>\n"; // two rows
84
85 GroupBox(_("Privileges"), "keys");
86 $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
87 $asBookGroups = rrPrivilegedGroups("mod_roomreservation_book");
88 $asViewGroups = rrPrivilegedGroups("mod_roomreservation_view");
89 echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("room-reservation:This is ".
90 "a short summary of the privileges related to the room reservation ".
91 "schedulde and the groups which have them assigned."),
92 sprintf(_c("room-reservation:If one of these privileges is not assigned to ".
93 "any group, all users on this server are allowed to perform the specified ".
94 "action. Please use the %sgroup administration%s to assign and revoke ".
95 "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
96 _c("room-reservation:Please note that every group with the booking ".
97 "privilege can also implicitly view the booking table and every group with ".
98 "the administration privilege can also implicitly book and view the ".
99 "booking table."));
100 echo "<p><table style='width:100%'><tr>\n";
101 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
102 _("View the booking table").":", $asViewGroups == array() ?
103 _c("room-reservation:all users") : icon("act-group") . join(", ",
104 array_map("getGroupName", $asViewGroups)));
105 echo "</tr><tr>\n";
106 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
107 _("Book rooms").":", $asBookGroups == array() ?
108 _c("room-reservation:all users") : icon("act-group") . join(", ",
109 array_map("getGroupName", $asBookGroups)));
110 echo "</tr><tr>\n";
111 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
112 _("Administration of the room reservation schedule"),
113 $asAdminGroups == array() ? _c("room-reservation:all users") :
114 icon("act-group") . join(", ", array_map("getGroupName", $asAdminGroups)));
115 echo "</tr></table></p>\n";
116 _GroupBox();
117
118 GroupBox(_c("room-reservation:Further options"), "manage");
119 printf("<div style='margin:8px;'><form action='%s' method='post'>".
120 "<table><tr>\n", $_SERVER["PHP_SELF"]);
121
122 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
123 "[showweekend]' value='0' /><%s name='mod_roomReservationConfigPage".
124 "[showweekend]' id='mod_roomReservationConfigPageShowWeekend' ".
125 "value='1' %s /></td><td><label for='".
126 "mod_roomReservationConfigPageShowWeekend'><b>%s</b></label><br />".
127 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
128 $GLOBALS["smlchk"], $this->bPostShowWeekend ? "checked='checked' " : "",
129 _c("room-reservation:Show weekend"), _c("room-reservation:If ".
130 "selected, the weekdays saturday and sunday are also shown in the ".
131 "booking table."));
132
133 echo "</tr><tr>\n";
134 printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
135 "[showlessons]' value='0' /><%s name='mod_roomReservationConfigPage".
136 "[showlessons]' id='mod_roomReservationConfigPageShowLessons' ".
137 "value='1'%s /></td><td><label for='".
138 "mod_roomReservationConfigPageShowLessons'><b>%s</b></label><br />".
139 "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
140 $GLOBALS["smlchk"], $this->bPostShowLessons ? "checked='checked' " : "",
141 _c("room-reservation:Show &bdquo;lesson&rdquo; texts"),
142 _c("room-reservation:Check this box to show texts like ".
143 "&bdquo;<i>n</i>th lesson&rdquo in the booking page. If this box is ".
144 "unchecked, none of these texts are shown."));
145
146 printf("</tr><tr><td colspan='2'><%s name='mod_roomReservationConfigPage".
147 "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
148 echo "</tr></table></form></div>\n";
149 _GroupBox();
150
151 // second row
152 echo "</td><td><!--second row-->\n";
153
154 GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
155 printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
156 "periods where bookings can be undertaken. A booking period can ".
157 "e.&nbsp;g. correspond to a lesson."));
158 echo "<div style='margin:8px;'>";
159 $otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
160 $otlb->show();
161 echo "</div>";
162 _GroupBox();
163
164 echo "</td></tr></table>\n";
165 }
166 }
167 ?>
This page took 0.056698 seconds and 5 git commands to generate.