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 echo 'done with update bug';
83 if ($vars['changeproduct'])
85 $_REQUEST['do'] = 'editproduct';
89 // ###################################################################
91 if ($_REQUEST['do'] == 'edit')
93 echo '<form name="editreport" action="editreport.php" method="post">';
94 echo '<input type="hidden" name="do" value="update" /><input type="hidden" name="bugid" value="' . $bug['bugid'] . '" />';
95 echo "<div><strong>Bug ID:</strong> $bug[bugid]</div>";
96 echo "<div><strong>Summary/title:</strong> <input type=\"text\" name=\"summary\" value=\"$bug[summary]\" size=\"35\" />";
97 if (can_perform('canchangestatus'))
99 echo '<div><strong>Priority:</strong> <select name="priority">';
100 foreach ($bugsys->datastore
['priority'] AS $priority)
102 echo '<option value="' . $priority['priorityid'] . '"' . iff($priority['priorityid'] == $bug['priority'], ' selected="selected"') . '>' . $priority['priority'] . '</option>';
104 echo '</select></div>';
106 echo '<div><strong>Status:</strong> <select name="status">';
107 foreach ($bugsys->datastore
['status'] AS $status)
109 echo '<option value="' . $status['statusid'] . '"' . iff($status['statusid'] == $bug['status'], ' selected="selected"') . '>' . $status['status'] . '</option>';
111 echo '</select></div>';
113 echo '<div><strong>Resolution:</strong> <select name="resolution">';
114 foreach ($bugsys->datastore
['resolution'] AS $resolution)
116 echo '<option value="' . $resolution['resolutionid'] . '"' . iff($resolution['resolutionid'] == $bug['resolution'], ' selected="selected"') . '>' . $resolution['resolution'] . '</option>';
118 echo '</select></div>';
120 if (can_perform('canassign'))
122 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0"' . iff(!$bug['assignedto'], ' selected="selected"') . '>No Assignment</option>';
123 foreach ($bugsys->datastore
['assignto'] AS $dev)
125 echo '<option value="' . $dev['userid'] . '"' . iff($dev['userid'] == $bug['assignedto'], ' selected="selected"') . '>' . construct_user_display($dev, false
) . '</option>';
127 echo '</select></div>';
129 echo '<div><input type="submit" name="changeproduct" value="Change Product and Version Information" />';
130 echo '<div><input type="submit" name="submit" value="Save Changes" /></div></form>';
133 // ###################################################################
135 if ($_POST['do'] == 'updateproduct')
137 sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
141 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
143 echo 'there was a problem selecting the product, component, or version';
146 $product = $bugsys->datastore
['product']["$vars[product]"];
149 echo 'please select a valid product';
152 $version = $bugsys->datastore
['version']["$vars[version]"];
155 echo 'please select a valid version';
159 if ($vars['component'] == -1)
161 // not global version and version.productid != product.productid
162 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
164 echo 'invalid version specified';
171 $component = $bugsys->datastore
['product']["$vars[component]"];
172 // component has the right mother
173 if ($component['componentmother'] == $product['productid'])
175 // version.productid != {component.productid | product.productid}
176 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
178 echo 'invalid version specified';
184 echo 'invalid component specified';
190 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "bug SET productid = $vars[product], componentid = $vars[component], versionid = $vars[version] WHERE bugid = $bug[bugid]");
192 echo 'changed product info';
195 // ###################################################################
197 if ($_REQUEST['do'] == 'editproduct')
199 sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
201 // the user can hit the back button without reposting data...
202 if (!$vars['product'] OR !$vars['component'])
211 echo '<form name="newbug" action="editreport.php" method="' . $method . '">';
215 if (!$vars['product'])
217 echo '<strong>Product:</strong> <select name="product">';
218 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
219 while ($product = $DB_sql->fetch_array($products))
221 echo "<option value=\"$product[productid]\">$product[title]</option>";
225 else if (!$vars['component'])
227 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
228 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
229 while ($component = $DB_sql->fetch_array($components))
231 echo "<option value=\"$component[productid]\">$component[title]</option>";
234 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
236 else if (!$vars['version'])
238 echo '<strong>Version:</strong> <select name="version">';
239 $versions = $DB_sql->query("
240 SELECT version.*, product.componentmother, product.title AS productname
241 FROM " . TABLE_PREFIX
. "version AS version
242 LEFT JOIN " . TABLE_PREFIX
. "product ON (product.productid = version.productid)
243 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
244 ORDER BY version.productid, version.displayorder ASC"
247 while ($version = $DB_sql->fetch_array($versions))
249 $versionlist["$version[productid]"][] = $version;
250 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
253 foreach ($versionlist AS $productid => $versions)
259 echo '<optgroup label="Global Versions">';
262 else if ($lookup["$productid"]['componentmother'])
264 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
268 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
271 foreach ($versions AS $version)
273 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
280 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
281 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
282 $do = 'updateproduct';
285 echo '<input type="hidden" name="bugid" value="' . $bug['bugid'] . '" />';
286 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value="Change Product and Version Information" /></div>';
290 /*=====================================================================*\
291 || ###################################################################
294 || ###################################################################
295 \*=====================================================================*/