b091f8f36068c5d566df6cf07a80ac8966419c67
[iserv-mod-error-reporter.git] / src / detail.php
1 <?php
2 /**
3 * @file detail.php
4 * Page to edit an error report
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/init.inc");
30 require_once("sec/secure.inc");
31 require_once("js.inc");
32
33 PageBlue(_c("error-reporter:Change an error report"), "mod_error-reporter");
34
35 if(!$cfgErrors->userHasAccess()) {
36 printf("<p class='err'>%s</p>\n", ER_ERROR_ACCESS_DENIED);
37 _PageBlue();
38 die();
39 }
40
41 $getAction = @$_GET["action"];
42 $getUid = @intval($_GET["uid"]);
43 $postSubmit = @$_POST["submit"];
44
45 isset($getUid) or die();
46
47 // Check if the specified report exists
48 if(!is_object($doc->getErrorReportByID($getUid))) {
49 echo sprintf("<p class='err'>%s</p>",
50 _c("error-reporter:The specified error report does not exist!"));
51 _PageBlue();
52 die();
53 }
54
55 // Only admins or owners can view this page
56 if(!($cfgErrors->userIsAdmin() or $doc->userIsOwner($getUid))) {
57 echo sprintf("<p class='err'>%s</div>", _c("error-reporter:You are not ".
58 "allowed to edit this report."));
59 _PageBlue();
60 die();
61 }
62
63 // Load old dataset
64 $er = $doc->getErrorReportByID($getUid);
65 $strOldComment = $er->getComment();
66
67 // Probably we have to update an error report
68 echo "PostSubmit: $postSubmit";
69 if($getAction == "update" and $postSubmit == _("Change"))
70 {
71 if($cfgErrors->userIsAdmin()) {
72 $postComment = stripslashes(@$_POST["comment"]);
73 $postCommentOld = stripslashes(@$_POST["comment_old"]);
74 }
75
76 // change the fields of the old dataset
77 $er->setMachine(stripslashes(@$_POST["machine"]));
78 $er->setText(stripslashes(@$_POST["text"]));
79 $er->setVisibility(isset($_POST["hidden"]) ? true : false);
80
81 // Do we have to change the comment and his owner?
82 if($cfgErrors->userIsAdmin()) {
83 if(@$_POST["comment_old"] != @$_POST["comment"]) {
84 $er->setComment(stripslashes(@$_POST["comment"]), $_SESSION["act"]);
85 }
86 }
87
88 // write into database, reload parent and close window
89 if($doc->writeErrorReport($er) != -1) {
90 js_try("opener.location.href = 'index.php';");
91 js_close(500);
92 } else {
93 printLastError();
94 _PageBlue();
95 die();
96 }
97 }
98
99 // output form
100 $hidctrl = "input type='hidden'";
101 Title(_c("error-reporter:Change an error report"));
102 echo sprintf("<form action='?action=update&amp;uid=%d' method='post'>\n",
103 $getUid);
104 echo "<table>\n";
105 echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n",
106 _c("error-reporter:Reported by:"), q(erGetRealUserName($er->getOwner())));
107 echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n", _c("error-reporter:Date:"),
108 SmartDate($er->getDate()));
109 echo sprintf("<tr><td>%s</td><td><{$GLOBALS["stdedt"]} name='machine' ".
110 "value='%s' /></td></tr>\n", _c("error-reporter:Affected machine:"),
111 q($er->getMachine()));
112 echo sprintf("<tr><td>%s</td><td><textarea name='text' cols='40' rows='7'>%s".
113 "</textarea></td></tr>\n", _c("error-reporter:Text:"), $er->getText());
114 echo sprintf("<tr><td><label for='hidden'>%s</label></td><td>".
115 "<input type='checkbox' id='hidden' name='hidden' value='true'%s /></td>".
116 "</tr>\n", _c("error-reporter:Hidden:"), $er->isHidden() ?
117 " checked='checked'" : "");
118 if($cfgErrors->userIsAdmin()) {
119 echo sprintf("<tr><td>%s</td><td><textarea name='comment' cols='40' ".
120 "rows='3'>%s</textarea>", _c("error-reporter:Comment:"), $er->getComment());
121 if($er->getComment() != "") {
122 echo sprintf("<input type='hidden' name='comment_old' value='%s' /></td>".
123 "</tr>\n", $strOldComment);
124 echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n", _c("error-reporter:".
125 "Comment written by:"), erGetRealUserName($er->getCommentOwner()));
126 }
127 }
128 echo sprintf("<tr><td /><td><{$GLOBALS["smlbtn"]} name='submit' value='%s' ".
129 "/></td></tr>\n", _("Change"));
130 echo "</table></form><p />\n";
131 _PageBlue();
132 ?>
This page took 0.054865 seconds and 3 git commands to generate.