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 echo 'alert: bad bug';
34 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
40 // ###################################################################
42 if (empty($_REQUEST['do']))
44 $_REQUEST['do'] = 'edit';
47 // ###################################################################
49 #*# do these later once we have delete permissions figured out
50 if ($_REQUEST['do'] == 'kill')
52 // run code to remove item in database
55 // ###################################################################
57 if ($_REQUEST['do'] == 'delete')
59 // display delete confirmation message
62 // ###################################################################
64 if ($_POST['do'] == 'update')
66 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
68 if (!$bugsys->in
['summary'])
70 echo 'you need to enter a summary';
75 echo 'invalid product/component/version';
79 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
82 UPDATE " . TABLE_PREFIX
. "bug
83 SET summary = '" . $bugsys->in
['summary'] . "',
84 priority = " . intval($bugsys->in
['priority']) . ",
85 status = " . intval($bugsys->in
['status']) . ",
86 severity = " . intval($bugsys->in
['severity']) . ",
87 resolution = " . intval($bugsys->in
['resolution']) . ",
88 assignedto = " . intval($bugsys->in
['assignedto']) . ",
89 productid = " . $pcv['product'] . ",
90 componentid = " . $pcv['component'] . ",
91 versionid = " . $pcv['version'] . "
92 WHERE bugid = $bug[bugid]"
95 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
97 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
98 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
100 $lookupindex = array(
101 'status' => 'status',
102 'severity' => 'severity',
103 'priority' => 'priority',
104 'versionid' => 'version',
105 'assignedto' => 'assignto',
106 'resolution' => 'resolution',
107 'productid' => 'product',
108 'componentid' => 'product'
111 foreach ($diff AS $num => $diffs)
113 foreach ($diffs AS $key => $value)
115 $ref = $lookupindex["$key"];
116 $temp =& $bugsys->datastore
["$ref"]["$value"];
117 $thevalue = $temp["$ref"];
118 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
120 if ($key == 'assignedto')
122 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
125 else if ($key == 'productid' OR $key == 'componentid')
128 $thevalue = $temp['title'];
131 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
133 log_action($bug['bugid'], 'log_update_bug', array(), false
, $key, $diff["$num"]["$key"], $diff["$num"]["$key"]);
137 //log_action($bug['bugid'], 'log_update_bug', array(), $diff[0], $diff[1]);
139 if (!$bugsys->in
['firstcomment'])
141 echo 'you need to enter some text in the first comment';
145 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
147 if (!$bugsys->options
['allowhtml'])
149 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
152 // we could pass this as a GET param, but that's unsafe
153 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
156 UPDATE " . TABLE_PREFIX
. "comment
157 SET comment = '" . $bugsys->in
['firstcomment'] . "',
158 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
159 WHERE commentid = $firstcomment[commentid]"
162 if ($bugsys->in
['changeproduct'])
164 $_REQUEST['do'] = 'editproduct';
168 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">done with update bug</a>";
172 // ###################################################################
174 if ($_REQUEST['do'] == 'edit')
176 foreach ($bugsys->datastore
['severity'] AS $severity)
178 $value = $severity['severityid'];
179 $selected = (($severity['severityid'] == $bug['severity']) ? true
: false
);
180 $label = $severity['severity'];
181 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
184 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
185 if (can_perform('canchangestatus'))
187 foreach ($bugsys->datastore
['priority'] AS $priority)
189 $value = $priority['priorityid'];
190 $selected = (($priority['priorityid'] == $bug['priority']) ? true
: false
);
191 $label = $priority['priority'];
192 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
195 foreach ($bugsys->datastore
['status'] AS $status)
197 $value = $status['statusid'];
198 $selected = (($status['statusid'] == $bug['status']) ? true
: false
);
199 $label = $status['status'];
200 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
203 foreach ($bugsys->datastore
['resolution'] AS $resolution)
205 $value = $resolution['resolutionid'];
206 $selected = (($resolution['resolutionid'] == $bug['resolution']) ? true
: false
);
207 $label = $resolution['resolution'];
208 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
212 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
213 if (can_perform('canassign'))
215 foreach ($bugsys->datastore
['assignto'] AS $dev)
217 $value = $dev['userid'];
218 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
219 $label = construct_user_display($dev, false
);
220 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
224 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
226 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
228 eval('$template->flush("' . $template->fetch('editreport') . '");');
231 /*=====================================================================*\
232 || ###################################################################
235 || ###################################################################
236 \*=====================================================================*/