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 #*# do these later once we have delete permissions figured out
60 if ($_REQUEST['do'] == 'kill')
62 // run code to remove item in database
65 // ###################################################################
67 if ($_REQUEST['do'] == 'delete')
69 // display delete confirmation message
72 // ###################################################################
74 if ($_POST['do'] == 'update')
76 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
78 if (!$bugsys->in
['summary'])
80 $message->error('you need to enter a summary');
84 $message->error('invalid product/component/version');
87 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
88 $hist2[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
90 process_custom_fields($bug['bugid']);
93 UPDATE " . TABLE_PREFIX
. "bug
94 SET summary = '" . $bugsys->in
['summary'] . "',
95 priority = " . intval($bugsys->in
['priority']) . ",
96 status = " . intval($bugsys->in
['status']) . ",
97 severity = " . intval($bugsys->in
['severity']) . ",
98 resolution = " . intval($bugsys->in
['resolution']) . ",
99 assignedto = " . intval($bugsys->in
['assignedto']) . ",
100 productid = " . $pcv['product'] . ",
101 componentid = " . $pcv['component'] . ",
102 versionid = " . $pcv['version'] . ",
103 hidden = " . intval($bugsys->in
['hidden']) . "
104 WHERE bugid = $bug[bugid]"
107 // -------------------------------------------------------------------
110 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
111 $hist2[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
113 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
114 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
116 $lookupindex = array(
117 'status' => 'status',
118 'severity' => 'severity',
119 'priority' => 'priority',
120 'versionid' => 'version',
121 'assignedto' => 'assignto',
122 'resolution' => 'resolution',
123 'productid' => 'product',
124 'componentid' => 'product'
127 $log->language
= 'log_update_bug';
129 foreach ($diff AS $num => $diffs)
131 foreach ($diffs AS $key => $value)
133 if (!isset($lookupindex["$key"]))
138 $ref = $lookupindex["$key"];
139 $temp =& $bugsys->datastore
["$ref"]["$value"];
140 $thevalue = $temp["$ref"];
141 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
143 if ($key == 'assignedto')
145 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
148 else if ($key == 'productid' OR $key == 'componentid')
151 $thevalue = $temp['title'];
154 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
158 foreach ($diff[1] AS $key => $value)
160 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
163 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
164 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
166 foreach ($diff2[1] AS $key => $value)
168 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
171 // -------------------------------------------------------------------
172 // process comment stuff
174 if (!$bugsys->in
['firstcomment'])
176 $message->error('you need to enter some text in the first comment');
179 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
181 if (!$bugsys->options
['allowhtml'])
183 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
186 // we could pass this as a GET param, but that's unsafe
187 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
190 UPDATE " . TABLE_PREFIX
. "comment
191 SET comment = '" . $bugsys->in
['firstcomment'] . "',
192 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
193 WHERE commentid = $firstcomment[commentid]"
196 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
199 // ###################################################################
201 if ($_REQUEST['do'] == 'edit')
203 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
205 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
206 if (can_perform('canchangestatus'))
208 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
209 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
210 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
213 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
214 if (can_perform('canassign'))
216 foreach ($bugsys->datastore
['assignto'] AS $dev)
218 $value = $dev['userid'];
219 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
220 $label = construct_user_display($dev, false
);
221 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
225 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
227 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
229 $customfields = construct_custom_fields($bug);
231 eval('$template->flush("' . $template->fetch('editreport') . '");');
234 /*=====================================================================*\
235 || ###################################################################
238 || ###################################################################
239 \*=====================================================================*/