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]");
84 process_custom_fields($bug['bugid']);
87 UPDATE " . TABLE_PREFIX
. "bug
88 SET summary = '" . $bugsys->in
['summary'] . "',
89 priority = " . intval($bugsys->in
['priority']) . ",
90 status = " . intval($bugsys->in
['status']) . ",
91 severity = " . intval($bugsys->in
['severity']) . ",
92 resolution = " . intval($bugsys->in
['resolution']) . ",
93 assignedto = " . intval($bugsys->in
['assignedto']) . ",
94 productid = " . $pcv['product'] . ",
95 componentid = " . $pcv['component'] . ",
96 versionid = " . $pcv['version'] . "
97 WHERE bugid = $bug[bugid]"
100 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
102 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
103 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
105 $lookupindex = array(
106 'status' => 'status',
107 'severity' => 'severity',
108 'priority' => 'priority',
109 'versionid' => 'version',
110 'assignedto' => 'assignto',
111 'resolution' => 'resolution',
112 'productid' => 'product',
113 'componentid' => 'product'
116 $log->language
= 'log_update_bug';
118 foreach ($diff AS $num => $diffs)
120 foreach ($diffs AS $key => $value)
122 if (!isset($lookupindex["$key"]))
127 $ref = $lookupindex["$key"];
128 $temp =& $bugsys->datastore
["$ref"]["$value"];
129 $thevalue = $temp["$ref"];
130 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
132 if ($key == 'assignedto')
134 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
137 else if ($key == 'productid' OR $key == 'componentid')
140 $thevalue = $temp['title'];
143 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
147 foreach ($diff[1] AS $key => $value)
149 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
152 if (!$bugsys->in
['firstcomment'])
154 $message->error('you need to enter some text in the first comment');
157 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
159 if (!$bugsys->options
['allowhtml'])
161 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
164 // we could pass this as a GET param, but that's unsafe
165 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
168 UPDATE " . TABLE_PREFIX
. "comment
169 SET comment = '" . $bugsys->in
['firstcomment'] . "',
170 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
171 WHERE commentid = $firstcomment[commentid]"
174 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
177 // ###################################################################
179 if ($_REQUEST['do'] == 'edit')
181 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
183 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
184 if (can_perform('canchangestatus'))
186 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
187 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
188 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
191 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
192 if (can_perform('canassign'))
194 foreach ($bugsys->datastore
['assignto'] AS $dev)
196 $value = $dev['userid'];
197 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
198 $label = construct_user_display($dev, false
);
199 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
203 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
205 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
207 $customfields = construct_custom_fields($bug);
209 eval('$template->flush("' . $template->fetch('editreport') . '");');
212 /*=====================================================================*\
213 || ###################################################################
216 || ###################################################################
217 \*=====================================================================*/