2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2002-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2002 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 $fetchtemplates = array(
18 require_once('./global.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'])
32 $message->error('alert: bad bug');
35 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
37 $message->error_permission();
40 if ($bug['hidden'] AND !can_perform('canviewhidden'))
42 $message->error_permission();
46 require_once('./includes/class_history.php');
48 $log->bugid
= $bug['bugid'];
50 // ###################################################################
52 if (empty($_REQUEST['do']))
54 $_REQUEST['do'] = 'edit';
57 // ###################################################################
59 if ($_POST['do'] == 'update')
61 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
63 if (!$bugsys->in
['summary'])
65 $message->error('you need to enter a summary');
69 $message->error('invalid product/component/version');
72 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
73 $hist2[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
75 process_custom_fields($bug['bugid']);
78 UPDATE " . TABLE_PREFIX
. "bug
79 SET summary = '" . $bugsys->in
['summary'] . "',
80 priority = " . intval($bugsys->in
['priority']) . ",
81 status = " . intval($bugsys->in
['status']) . ",
82 severity = " . intval($bugsys->in
['severity']) . ",
83 resolution = " . intval($bugsys->in
['resolution']) . ",
84 assignedto = " . intval($bugsys->in
['assignedto']) . ",
85 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
86 productid = " . $pcv['product'] . ",
87 componentid = " . $pcv['component'] . ",
88 versionid = " . $pcv['version'] . ",
89 hidden = " . intval($bugsys->in
['hidden']) . "
90 WHERE bugid = $bug[bugid]"
93 // -------------------------------------------------------------------
96 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
97 $hist2[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
99 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
100 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
102 $lookupindex = array(
103 'status' => 'status',
104 'severity' => 'severity',
105 'priority' => 'priority',
106 'versionid' => 'version',
107 'assignedto' => 'assignto',
108 'resolution' => 'resolution',
109 'productid' => 'product',
110 'componentid' => 'product'
113 $log->language
= 'log_update_bug';
115 foreach ($diff AS $num => $diffs)
117 foreach ($diffs AS $key => $value)
119 if (!isset($lookupindex["$key"]))
124 $ref = $lookupindex["$key"];
125 $temp =& $bugsys->datastore
["$ref"]["$value"];
126 $thevalue = $temp["$ref"];
127 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
129 if ($key == 'assignedto')
131 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
134 else if ($key == 'productid' OR $key == 'componentid')
137 $thevalue = $temp['title'];
140 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
144 foreach ($diff[1] AS $key => $value)
146 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
149 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
150 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
152 foreach ($diff2[1] AS $key => $value)
154 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
157 // -------------------------------------------------------------------
158 // process comment stuff
160 if (!$bugsys->in
['firstcomment'])
162 $message->error('you need to enter some text in the first comment');
165 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
167 if (!$bugsys->options
['allowhtml'])
169 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
172 // we could pass this as a GET param, but that's unsafe
173 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
176 UPDATE " . TABLE_PREFIX
. "comment
177 SET comment = '" . $bugsys->in
['firstcomment'] . "',
178 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
179 WHERE commentid = $firstcomment[commentid]"
182 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
185 // ###################################################################
187 if ($_REQUEST['do'] == 'edit')
189 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
191 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
192 if (can_perform('canchangestatus'))
194 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
195 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
196 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
199 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
200 if (can_perform('canassign'))
202 foreach ($bugsys->datastore
['assignto'] AS $dev)
204 $value = $dev['userid'];
205 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
206 $label = construct_user_display($dev, false
);
207 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
211 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
213 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
215 $customfields = construct_custom_fields($bug);
217 if ($bug['duplicateof'])
219 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
222 eval('$template->flush("' . $template->fetch('editreport') . '");');
225 /*=====================================================================*\
226 || ###################################################################
229 || ###################################################################
230 \*=====================================================================*/