make fails if shell is not bash -- I will fix bashisms somewhere in the future
[iserv-mod-error-reporter.git] / src / config.php
1 <?php
2 /**
3 * @file config.php
4 * Configuration page
5 * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
6 * @date 22.10.2007
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("mod_error-reporter/class_erConfig.inc");
30 require_once("mod_error-reporter/functions.inc");
31 require_once("share.inc");
32 require_once("ctrl.inc");
33 require_once("db.inc");
34 require_once("sec/admsecure.inc");
35
36 html_header("<style type='text/css'>
37 td.errors-cfg-field {
38 padding: 1em;
39 width: 50%;
40 vertical-align: top;
41 }
42 td.errors-cfg-field input {
43 margin: 0;
44 }
45 .errors-cfg-field-heading {
46 font-weight: bold;
47 }
48 </style>");
49
50 $cfgErrors = new erConfig();
51 require_once("mod_error-reporter/config.inc");
52
53 PageBlue(_c("error-reporter-cfg:Error Report Wizard – Configuration"),
54 "mod_error-reporter");
55
56 if(@$_POST["submit"] == _("Save")) {
57 $bMailNotify = (@$_POST["mailnotify"] == "true");
58 $strMailNotifyAddr = @$_POST["mailnotifyaddr"];
59 $bLog = (@$_POST["log"] == "true");
60
61 if($bMailNotify != $cfgErrors->isMailNotify()) {
62 $cfgErrors->setMailNotify($bMailNotify);
63 echo sprintf("<p>%s</p>\n", _c("error-reporter-cfg:Set mail ".
64 "notification."));
65 }
66 if($strMailNotifyAddr != $cfgErrors->getMailNotifyAddr()) {
67 if(!erIsMailAddress($strMailNotifyAddr)) {
68 echo sprintf("<p class='err'>%s</p>", _c("error-reporter-cfg:The ".
69 "specified string is not a valid e-mail address!"));
70 } else {
71 $cfgErrors->setMailNotifyAddr($strMailNotifyAddr);
72 echo sprintf("<p>%s</p>\n", _c("error-reporter-cfg:Set mail ".
73 "notification address."));
74 }
75 }
76 $cfgErrors->writeConfig();
77 }
78
79 // two columns
80 echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
81 "<td width='50%'>\n";
82
83 // Mail notification
84 GroupBox(_c("error-reporter-cfg:Mail notification"), "mail");
85 echo "<form method='post'>\n";
86 echo "<table class='errors-cfg-table'>\n";
87 echo sprintf("<tr><td class='errors-cfg-field'><label for='mailnotify' ".
88 "class='errors-cfg-field-heading'>%s</label><br />%s</td><td ".
89 "class='errors-cfg-field'><input type='checkbox' name='mailnotify' ".
90 "id='mailnotify' value='true'%s /></td></tr>",
91 _c("error-reporter-cfg:Enable mail notification"),
92 _c("error-reporter-cfg:If this option is enabled, everytime an error report ".
93 "is submitted, an e-mail with information about the report will be sent to ".
94 "the address specified below."), $cfgErrors->isMailNotify() ?
95 " checked='checked'" : "");
96 echo sprintf("<tr><td class='errors-cfg-field'><label for='mailnotifyaddr'".
97 "class='errors-cfg-field-heading'>%s</label><br />%s</td>".
98 "<td class='errors-cfg-field'><input type='text' name='mailnotifyaddr' ".
99 "id='mailnotifyaddr' size='30' value='%s' /></td></tr>",
100 _c("error-reporter-cfg:Mail address to send the notification mail to"),
101 _c("error-reporter-cfg:If mail notifications are enabled, any notification ".
102 "mails are sent to the address specified here. You can give more than one ".
103 "address by separating them with a comma."),
104 q($cfgErrors->getMailNotifyAddr()));
105 echo sprintf("<tr><td class='errors-cfg-field'><$stdbtn name='submit' ".
106 "value='%s' /></td></tr>\n", _("Save"));
107 echo "</table>\n</form>\n";
108 _GroupBox();
109
110 echo "</td><td>\n";
111
112 // Privileges
113 GroupBox(_("Privileges"), "keys");
114 $asAccessGroups = erPrivilegedGroups("mod_errorreporter_access");
115 $asAdminGroups = erPrivilegedGroups("mod_errorreporter_admin");
116 echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("error-reporter:This is ".
117 "a short summary of the privileges related to the error report assistant ".
118 "and the groups which have them assigned."),
119 sprintf(_c("error-reporter:If one of these privileges is not assigned to ".
120 "any group, all users on this server are allowed to perform the specified ".
121 "action. Please use the %sgroup administration%s to assign and revoke ".
122 "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
123 _c("error-reporter:Please note that every group with the administration ".
124 "privilege can also implicitly report errors and see the reported ".
125 "messages."));
126 echo "<p><table style='width:100%'><tr>\n";
127 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
128 _("View error reports and report errors").":", $asAccessGroups == array() ?
129 _c("error-reporter:all users") : icon("act-group") . join(", ",
130 array_map("erGetGroupName", $asAccessGroups)));
131 echo "</tr><tr>\n";
132 echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
133 _("Administration of the error report wizard"),
134 $asAdminGroups == array() ? _c("error-reporter:no users") :
135 icon("act-group") . join(", ", array_map("erGetGroupName", $asAdminGroups)));
136 echo "</tr></table></p>\n";
137 _GroupBox();
138
139 echo "</td></tr></table>\n";
140
141 _PageBlue();
142 ?>
This page took 0.056488 seconds and 5 git commands to generate.