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 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 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
30 $message->error('alert: bad bug');
33 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
35 $message->error_permission();
39 require_once('./includes/class_history.php');
41 $log->bugid
= $bug['bugid'];
43 // ###################################################################
45 if (empty($_REQUEST['do']))
47 $_REQUEST['do'] = 'edit';
50 // ###################################################################
52 #*# do these later once we have delete permissions figured out
53 if ($_REQUEST['do'] == 'kill')
55 // run code to remove item in database
58 // ###################################################################
60 if ($_REQUEST['do'] == 'delete')
62 // display delete confirmation message
65 // ###################################################################
67 if ($_POST['do'] == 'update')
69 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
71 if (!$bugsys->in
['summary'])
73 $message->error('you need to enter a summary');
77 $message->error('invalid product/component/version');
80 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
83 UPDATE " . TABLE_PREFIX
. "bug
84 SET summary = '" . $bugsys->in
['summary'] . "',
85 priority = " . intval($bugsys->in
['priority']) . ",
86 status = " . intval($bugsys->in
['status']) . ",
87 severity = " . intval($bugsys->in
['severity']) . ",
88 resolution = " . intval($bugsys->in
['resolution']) . ",
89 assignedto = " . intval($bugsys->in
['assignedto']) . ",
90 productid = " . $pcv['product'] . ",
91 componentid = " . $pcv['component'] . ",
92 versionid = " . $pcv['version'] . "
93 WHERE bugid = $bug[bugid]"
96 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
98 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
99 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
101 $lookupindex = array(
102 'status' => 'status',
103 'severity' => 'severity',
104 'priority' => 'priority',
105 'versionid' => 'version',
106 'assignedto' => 'assignto',
107 'resolution' => 'resolution',
108 'productid' => 'product',
109 'componentid' => 'product'
112 $log->language
= 'log_update_bug';
114 foreach ($diff AS $num => $diffs)
116 foreach ($diffs AS $key => $value)
118 if (!isset($lookupindex["$key"]))
123 $ref = $lookupindex["$key"];
124 $temp =& $bugsys->datastore
["$ref"]["$value"];
125 $thevalue = $temp["$ref"];
126 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
128 if ($key == 'assignedto')
130 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
133 else if ($key == 'productid' OR $key == 'componentid')
136 $thevalue = $temp['title'];
139 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
143 foreach ($diff[1] AS $key => $value)
145 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
148 if (!$bugsys->in
['firstcomment'])
150 $message->error('you need to enter some text in the first comment');
153 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
155 if (!$bugsys->options
['allowhtml'])
157 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
160 // we could pass this as a GET param, but that's unsafe
161 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
164 UPDATE " . TABLE_PREFIX
. "comment
165 SET comment = '" . $bugsys->in
['firstcomment'] . "',
166 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
167 WHERE commentid = $firstcomment[commentid]"
170 if ($bugsys->in
['changeproduct'])
172 $_REQUEST['do'] = 'editproduct';
176 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
180 // ###################################################################
182 if ($_REQUEST['do'] == 'edit')
184 foreach ($bugsys->datastore
['severity'] AS $severity)
186 $value = $severity['severityid'];
187 $selected = (($severity['severityid'] == $bug['severity']) ? true
: false
);
188 $label = $severity['severity'];
189 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
192 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
193 if (can_perform('canchangestatus'))
195 foreach ($bugsys->datastore
['priority'] AS $priority)
197 $value = $priority['priorityid'];
198 $selected = (($priority['priorityid'] == $bug['priority']) ? true
: false
);
199 $label = $priority['priority'];
200 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
203 foreach ($bugsys->datastore
['status'] AS $status)
205 $value = $status['statusid'];
206 $selected = (($status['statusid'] == $bug['status']) ? true
: false
);
207 $label = $status['status'];
208 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
211 foreach ($bugsys->datastore
['resolution'] AS $resolution)
213 $value = $resolution['resolutionid'];
214 $selected = (($resolution['resolutionid'] == $bug['resolution']) ? true
: false
);
215 $label = $resolution['resolution'];
216 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
220 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
221 if (can_perform('canassign'))
223 foreach ($bugsys->datastore
['assignto'] AS $dev)
225 $value = $dev['userid'];
226 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
227 $label = construct_user_display($dev, false
);
228 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
232 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
234 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
236 eval('$template->flush("' . $template->fetch('editreport') . '");');
239 /*=====================================================================*\
240 || ###################################################################
243 || ###################################################################
244 \*=====================================================================*/