2 /*=====================================================================*\
3 || ################################################################### ||
4 || # [#]app[#] [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 require_once('./global.php');
15 sanitize(array('bugid' => INT));
17 $bug = $DB_sql->query_first("
18 SELECT bug.*, user.email, user.displayname, user.showemail
19 FROM " . TABLE_PREFIX
. "bug AS bug
20 LEFT JOIN " . TABLE_PREFIX
. "user AS user
21 ON (bug.userid = user.userid)
22 WHERE bug.bugid = $vars[bugid]"
27 echo 'alert: bad bug';
31 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
37 // ###################################################################
39 if (empty($_REQUEST['do']))
41 $_REQUEST['do'] = 'edit';
44 // ###################################################################
46 #*# do these later once we have delete permissions figured out
47 if ($_REQUEST['do'] == 'kill')
49 // run code to remove item in database
52 // ###################################################################
54 if ($_REQUEST['do'] == 'delete')
56 // display delete confirmation message
59 // ###################################################################
61 if ($_POST['do'] == 'update')
64 'summary' => STR_NOHTML
,
69 'changeproduct' => STR
)
73 UPDATE " . TABLE_PREFIX
. "bug
74 SET summary = '" . addslasheslike($vars['summary']) . "',
75 priority = $vars[priority], status = $vars[status],
76 resolution = $vars[resolution],
77 assignedto = $vars[assignedto]
78 WHERE bugid = $bug[bugid]"
81 if ($vars['changeproduct'])
83 $_REQUEST['do'] = 'editproduct';
87 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">done with update bug</a>";
91 // ###################################################################
93 if ($_REQUEST['do'] == 'edit')
95 echo '<form name="editreport" action="editreport.php" method="post">';
96 echo '<input type="hidden" name="do" value="update" /><input type="hidden" name="bugid" value="' . $bug['bugid'] . '" />';
97 echo "<div><strong>Bug ID:</strong> $bug[bugid]</div>";
98 echo "<div><strong>Summary/title:</strong> <input type=\"text\" name=\"summary\" value=\"$bug[summary]\" size=\"35\" />";
99 if (can_perform('canchangestatus'))
101 echo '<div><strong>Priority:</strong> <select name="priority">';
102 foreach ($bugsys->datastore
['priority'] AS $priority)
104 echo '<option value="' . $priority['priorityid'] . '"' . iff($priority['priorityid'] == $bug['priority'], ' selected="selected"') . '>' . $priority['priority'] . '</option>';
106 echo '</select></div>';
108 echo '<div><strong>Status:</strong> <select name="status">';
109 foreach ($bugsys->datastore
['status'] AS $status)
111 echo '<option value="' . $status['statusid'] . '"' . iff($status['statusid'] == $bug['status'], ' selected="selected"') . '>' . $status['status'] . '</option>';
113 echo '</select></div>';
115 echo '<div><strong>Resolution:</strong> <select name="resolution">';
116 foreach ($bugsys->datastore
['resolution'] AS $resolution)
118 echo '<option value="' . $resolution['resolutionid'] . '"' . iff($resolution['resolutionid'] == $bug['resolution'], ' selected="selected"') . '>' . $resolution['resolution'] . '</option>';
120 echo '</select></div>';
122 if (can_perform('canassign'))
124 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0"' . iff(!$bug['assignedto'], ' selected="selected"') . '>No Assignment</option>';
125 foreach ($bugsys->datastore
['assignto'] AS $dev)
127 echo '<option value="' . $dev['userid'] . '"' . iff($dev['userid'] == $bug['assignedto'], ' selected="selected"') . '>' . construct_user_display($dev, false
) . '</option>';
129 echo '</select></div>';
131 echo '<div><input type="submit" name="changeproduct" value="Change Product and Version Information" />';
132 echo '<div><input type="submit" name="submit" value="Save Changes" /></div></form>';
135 // ###################################################################
137 if ($_POST['do'] == 'updateproduct')
139 sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
143 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
145 echo 'there was a problem selecting the product, component, or version';
148 $product = $bugsys->datastore
['product']["$vars[product]"];
151 echo 'please select a valid product';
154 $version = $bugsys->datastore
['version']["$vars[version]"];
157 echo 'please select a valid version';
161 if ($vars['component'] == -1)
163 // not global version and version.productid != product.productid
164 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
166 echo 'invalid version specified';
173 $component = $bugsys->datastore
['product']["$vars[component]"];
174 // component has the right mother
175 if ($component['componentmother'] == $product['productid'])
177 // version.productid != {component.productid | product.productid}
178 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
180 echo 'invalid version specified';
186 echo 'invalid component specified';
192 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "bug SET productid = $vars[product], componentid = $vars[component], versionid = $vars[version] WHERE bugid = $bug[bugid]");
194 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">changed product info</a>";
197 // ###################################################################
199 if ($_REQUEST['do'] == 'editproduct')
201 sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
203 // the user can hit the back button without reposting data...
204 if (!$vars['product'] OR !$vars['component'])
213 echo '<form name="newbug" action="editreport.php" method="' . $method . '">';
217 if (!$vars['product'])
219 echo '<strong>Product:</strong> <select name="product">';
220 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
221 while ($product = $DB_sql->fetch_array($products))
223 echo "<option value=\"$product[productid]\">$product[title]</option>";
227 else if (!$vars['component'])
229 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
230 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
231 while ($component = $DB_sql->fetch_array($components))
233 echo "<option value=\"$component[productid]\">$component[title]</option>";
236 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
238 else if (!$vars['version'])
240 echo '<strong>Version:</strong> <select name="version">';
241 $versions = $DB_sql->query("
242 SELECT version.*, product.componentmother, product.title AS productname
243 FROM " . TABLE_PREFIX
. "version AS version
244 LEFT JOIN " . TABLE_PREFIX
. "product ON (product.productid = version.productid)
245 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
246 ORDER BY version.productid, version.displayorder ASC"
249 while ($version = $DB_sql->fetch_array($versions))
251 $versionlist["$version[productid]"][] = $version;
252 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
255 foreach ($versionlist AS $productid => $versions)
261 echo '<optgroup label="Global Versions">';
264 else if ($lookup["$productid"]['componentmother'])
266 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
270 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
273 foreach ($versions AS $version)
275 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
282 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
283 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
284 $do = 'updateproduct';
287 echo '<input type="hidden" name="bugid" value="' . $bug['bugid'] . '" />';
288 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value="Change Product and Version Information" /></div>';
292 /*=====================================================================*\
293 || ###################################################################
296 || ###################################################################
297 \*=====================================================================*/