2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 define('SVN', '$Id$');
15 $focus['showreport
'] = 'focus
';
17 require_once('./global.php
');
18 require_once('./includes
/functions_product
.php
');
20 $bug = $db->query_first("
21 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
22 FROM " . TABLE_PREFIX . "bug AS bug
23 LEFT JOIN " . TABLE_PREFIX . "user AS user
24 ON (bug.userid = user.userid)
25 LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill
26 ON (bug.bugid = bugvaluefill.bugid)
27 WHERE bug.bugid = " . intval($bugsys->in['bugid
'])
30 if (!((can_perform('caneditown
', $bug['productid
']) AND $bugsys->userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['productid
']) AND $bugsys->userinfo['userid
'] != $bug['userid
'])) AND !can_perform('canpostcomments
', $bug['productid
']))
32 $message->error_permission();
37 $message->error($lang->getlex('error_invalid_id
'));
40 if ($bug['hidden
'] AND !can_perform('canviewhidden
', $bug['productid
']))
42 $message->error_permission();
46 require_once('./includes
/class_history
.php
');
48 $log->bugid = $bug['bugid
'];
50 // ###################################################################
52 if ($_POST['do'] == 'update
')
54 // -------------------------------------------------------------------
55 // process comment stuff
56 if (!((can_perform('caneditown
', $bug['productid
']) AND $bugsys->userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['productid
']) AND $bugsys->userinfo['userid
'] != $bug['userid
'])))
58 $hascomment = (!empty($bugsys->in['comment
'])) ? true : false;
60 if ($hascomment OR $autoaction['comment
'])
62 if ($hascomment AND $autoaction['comment
'])
64 $bugsys->in['comment
'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE
---------------') . "\n" . $autoaction['comment
'];
66 else if (!$hascomment AND $autoaction['comment
'])
68 $bugsys->in['comment
'] = $autoaction['comment
'];
71 $bugsys->in['comment_parsed
'] = $bugsys->in['comment
'];
73 if (!$bugsys->options['allowhtml
'])
75 $bugsys->in['comment_parsed
'] = $bugsys->sanitize($bugsys->in['comment_parsed
']);
81 INSERT INTO " . TABLE_PREFIX . "comment
82 (bugid, userid, dateline, comment, comment_parsed)
84 (" . intval($bugsys->in['bugid
']) . ", " . $bugsys->userinfo['userid
'] . ",
85 $time, '" . $bugsys->in['comment'] . "',
86 '" . nl2br($bugsys->in['comment_parsed']) . "'
90 $commentid = $db->insert_id();
93 UPDATE " . TABLE_PREFIX . "bug
94 SET lastposttime = $time,
95 lastpostby = " . $bugsys->userinfo['userid
'] . ",
96 hiddenlastposttime = $time,
97 hiddenlastpostby = " . $bugsys->userinfo['userid
'] . "
98 WHERE bugid = " . intval($bugsys->in['bugid
'])
103 $log->arguments = array($commentid);
108 $message->redirect($lang->string('Your reply has been added to the comment
list.'), "showreport.php?bugid=$bug[bugid]");
111 // -------------------------------------------------------------------
113 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
115 if (!$bugsys->in['summary
'])
117 $message->error($lang->string('You need to enter a summary
for this bug
.'));
121 $message->error($lang->string('Invalid product
/component
/version selected
.'));
124 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]");
125 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
127 // -------------------------------------------------------------------
131 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['autoaction
']));
134 $autoaction['fields
'] = unserialize($autoaction['fieldchanges
']);
136 foreach ($autoaction['fields
']['builtin
'] AS $field => $value)
138 $bugsys->in["$field"] = $value;
141 foreach ($autoaction['fields
']['custom
'] AS $field => $value)
143 $bugsys->in["field$field"] = $value;
147 process_custom_fields($bug['bugid
']);
149 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
150 $dependencies = ((count($dependencies) < 1) ? '' : implode(', ', $dependencies));
153 UPDATE " . TABLE_PREFIX
. "bug
154 SET summary = '" . $bugsys->in
['summary'] . "',
155 severity = " . intval($bugsys->in
['severity']) . "," .
156 (can_perform('canchangestatus', $bug['productid']) ? "
157 priority = " . intval($bugsys->in
['priority']) . ",
158 status = " . intval($bugsys->in
['status']) . ",
159 resolution = " . intval($bugsys->in
['resolution']) . ","
161 " . (can_perform('canassign', $bug['productid']) ? "assignedto = " . intval($bugsys->in
['assignedto']) . "," : '') . "
162 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
163 dependency = '$dependencies',
164 productid = " . $pcv['product'] . ",
165 componentid = " . $pcv['component'] . ",
166 versionid = " . $pcv['version'] . ",
167 hidden = " . intval($bugsys->in
['hidden']) . "
168 WHERE bugid = $bug[bugid]"
171 // -------------------------------------------------------------------
174 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
175 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
177 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
178 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
180 $lookupindex = array(
181 'status' => 'status',
182 'severity' => 'severity',
183 'priority' => 'priority',
184 'versionid' => 'version',
185 'assignedto' => 'assignto',
186 'resolution' => 'resolution',
187 'productid' => 'product',
188 'componentid' => 'product'
191 foreach ($diff AS $num => $diffs)
193 foreach ($diffs AS $key => $value)
195 if (!isset($lookupindex["$key"]))
200 $ref = $lookupindex["$key"];
201 $temp =& $bugsys->datastore
["$ref"]["$value"];
202 $thevalue = $temp["$ref"];
203 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
205 if ($key == 'assignedto')
207 $thevalue = (($temp['userid']) ? construct_user_display($temp) : '');
210 else if ($key == 'productid' OR $key == 'componentid')
213 $thevalue = $temp['title'];
216 $diff["$num"]["$key"] = (($thevalue) ? $thevalue . $idbit : '');
220 foreach ($diff[1] AS $key => $value)
222 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
225 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
226 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
228 if ($noinitialcustom === false)
230 $canallowempty = true;
231 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
232 while ($box = $db->fetch_array($checkbox))
234 $boxlist[] = 'field' . $box['fieldid'];
238 foreach ($diff2[1] AS $key => $value)
240 if (in_array($key, $boxlist) AND $canallowempty)
242 $log->allowempty
= true;
246 $log->allowempty
= false;
254 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
257 $log->allowempty
= false;
259 // -------------------------------------------------------------------
261 $hascomment = (!empty($bugsys->in
['comment'])) ? true : false;
263 if ($hascomment OR $autoaction['comment'])
265 if ($hascomment AND $autoaction['comment'])
267 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
269 else if (!$hascomment AND $autoaction['comment'])
271 $bugsys->in
['comment'] = $autoaction['comment'];
274 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
276 if (!$bugsys->options
['allowhtml'])
278 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
284 INSERT INTO " . TABLE_PREFIX
. "comment
285 (bugid, userid, dateline, comment, comment_parsed)
287 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
288 $time, '" . $bugsys->in
['comment'] . "',
289 '" . nl2br($bugsys->in
['comment_parsed']) . "'
293 $commentid = $db->insert_id();
296 UPDATE " . TABLE_PREFIX
. "bug
297 SET lastposttime = $time,
298 lastpostby = " . $bugsys->userinfo
['userid'] . ",
299 hiddenlastposttime = $time,
300 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
301 WHERE bugid = " . intval($bugsys->in
['bugid'])
306 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
309 /*=====================================================================*\
310 || ###################################################################
313 || ###################################################################
314 \*=====================================================================*/