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();
41 require_once('./includes/class_history.php');
43 $log->bugid
= $bug['bugid'];
45 // ###################################################################
47 if (empty($_REQUEST['do']))
49 $_REQUEST['do'] = 'edit';
52 // ###################################################################
54 #*# do these later once we have delete permissions figured out
55 if ($_REQUEST['do'] == 'kill')
57 // run code to remove item in database
60 // ###################################################################
62 if ($_REQUEST['do'] == 'delete')
64 // display delete confirmation message
67 // ###################################################################
69 if ($_POST['do'] == 'update')
71 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
73 if (!$bugsys->in
['summary'])
75 $message->error('you need to enter a summary');
79 $message->error('invalid product/component/version');
82 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
83 $hist2[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
85 process_custom_fields($bug['bugid']);
88 UPDATE " . TABLE_PREFIX
. "bug
89 SET summary = '" . $bugsys->in
['summary'] . "',
90 priority = " . intval($bugsys->in
['priority']) . ",
91 status = " . intval($bugsys->in
['status']) . ",
92 severity = " . intval($bugsys->in
['severity']) . ",
93 resolution = " . intval($bugsys->in
['resolution']) . ",
94 assignedto = " . intval($bugsys->in
['assignedto']) . ",
95 productid = " . $pcv['product'] . ",
96 componentid = " . $pcv['component'] . ",
97 versionid = " . $pcv['version'] . "
98 WHERE bugid = $bug[bugid]"
101 // -------------------------------------------------------------------
104 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
105 $hist2[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
107 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
108 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
110 $lookupindex = array(
111 'status' => 'status',
112 'severity' => 'severity',
113 'priority' => 'priority',
114 'versionid' => 'version',
115 'assignedto' => 'assignto',
116 'resolution' => 'resolution',
117 'productid' => 'product',
118 'componentid' => 'product'
121 $log->language
= 'log_update_bug';
123 foreach ($diff AS $num => $diffs)
125 foreach ($diffs AS $key => $value)
127 if (!isset($lookupindex["$key"]))
132 $ref = $lookupindex["$key"];
133 $temp =& $bugsys->datastore
["$ref"]["$value"];
134 $thevalue = $temp["$ref"];
135 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
137 if ($key == 'assignedto')
139 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
142 else if ($key == 'productid' OR $key == 'componentid')
145 $thevalue = $temp['title'];
148 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
152 foreach ($diff[1] AS $key => $value)
154 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
157 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
158 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
160 foreach ($diff2[1] AS $key => $value)
162 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
165 // -------------------------------------------------------------------
166 // process comment stuff
168 if (!$bugsys->in
['firstcomment'])
170 $message->error('you need to enter some text in the first comment');
173 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
175 if (!$bugsys->options
['allowhtml'])
177 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
180 // we could pass this as a GET param, but that's unsafe
181 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
184 UPDATE " . TABLE_PREFIX
. "comment
185 SET comment = '" . $bugsys->in
['firstcomment'] . "',
186 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
187 WHERE commentid = $firstcomment[commentid]"
190 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
193 // ###################################################################
195 if ($_REQUEST['do'] == 'edit')
197 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
199 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
200 if (can_perform('canchangestatus'))
202 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
203 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
204 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
207 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
208 if (can_perform('canassign'))
210 foreach ($bugsys->datastore
['assignto'] AS $dev)
212 $value = $dev['userid'];
213 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
214 $label = construct_user_display($dev, false
);
215 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
219 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
221 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
223 $customfields = construct_custom_fields($bug);
225 eval('$template->flush("' . $template->fetch('editreport') . '");');
228 /*=====================================================================*\
229 || ###################################################################
232 || ###################################################################
233 \*=====================================================================*/