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 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
173 // ###################################################################
175 if ($_REQUEST['do'] == 'edit')
177 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
179 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
180 if (can_perform('canchangestatus'))
182 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
183 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
184 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
187 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
188 if (can_perform('canassign'))
190 foreach ($bugsys->datastore
['assignto'] AS $dev)
192 $value = $dev['userid'];
193 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
194 $label = construct_user_display($dev, false
);
195 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
199 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
201 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
203 eval('$template->flush("' . $template->fetch('editreport') . '");');
206 /*=====================================================================*\
207 || ###################################################################
210 || ###################################################################
211 \*=====================================================================*/