INT));
$bug = $DB_sql->query_first("
SELECT bug.*, user.email, user.displayname, user.showemail
FROM " . TABLE_PREFIX . "bug AS bug
LEFT JOIN " . TABLE_PREFIX . "user AS user
ON (bug.userid = user.userid)
WHERE bug.bugid = $vars[bugid]"
);
if (!$bug)
{
echo 'alert: bad bug';
exit;
}
if (!(((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
{
echo 'no permission';
exit;
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'edit';
}
// ###################################################################
/*
#*# do these later once we have delete permissions figured out
if ($_REQUEST['do'] == 'kill')
{
// run code to remove item in database
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
// display delete confirmation message
}*/
// ###################################################################
if ($_POST['do'] == 'update')
{
sanitize(array(
'summary' => STR_NOHTML,
'priority' => INT,
'status' => INT,
'resolution' => INT,
'assignedto' => INT,
'changeproduct' => STR)
);
$DB_sql->query("
UPDATE " . TABLE_PREFIX . "bug
SET summary = '" . addslasheslike($vars['summary']) . "',
priority = $vars[priority], status = $vars[status],
resolution = $vars[resolution],
assignedto = $vars[assignedto]
WHERE bugid = $bug[bugid]"
);
if ($vars['changeproduct'])
{
$_REQUEST['do'] = 'editproduct';
}
else
{
echo "done with update bug";
}
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
foreach ($bugsys->datastore['severity'] AS $severity)
{
$value = $severity['severityid'];
$selected = iff($severity['severityid'] == $bug['severity'], true, false);
$label = $severity['severity'];
eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";');
}
$show['changestatus'] = iff(can_perform('canchangestatus'), true, false);
if (can_perform('canchangestatus'))
{
foreach ($bugsys->datastore['priority'] AS $priority)
{
$value = $priority['priorityid'];
$selected = iff($priority['priorityid'] == $bug['priority'], true, false);
$label = $priority['priority'];
eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";');
}
foreach ($bugsys->datastore['status'] AS $status)
{
$value = $status['statusid'];
$selected = iff($status['statusid'] == $bug['status'], true, false);
$label = $status['status'];
eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";');
}
foreach ($bugsys->datastore['resolution'] AS $resolution)
{
$value = $resolution['resolutionid'];
$selected = iff($resolution['resolutionid'] == $bug['resolution'], true, false);
$label = $resolution['resolution'];
eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";');
}
}
$show['assign'] = iff(can_perform('canassign'), true, false);
if (can_perform('canassign'))
{
foreach ($bugsys->datastore['assignto'] AS $dev)
{
$value = $dev['userid'];
$selected = iff($dev['userid'] == $bug['assignedto'], true, false);
$label = construct_user_display($dev, false);
eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";');
}
}
eval('$tpl->flush("' . $tpl->fetch('editreport') . '");');
}
// ###################################################################
if ($_POST['do'] == 'updateproduct')
{
sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
var_dump($vars);
if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
{
echo 'there was a problem selecting the product, component, or version';
exit;
}
$product = $bugsys->datastore['product']["$vars[product]"];
if (!$product)
{
echo 'please select a valid product';
exit;
}
$version = $bugsys->datastore['version']["$vars[version]"];
if (!$version)
{
echo 'please select a valid version';
exit;
}
// no component
if ($vars['component'] == -1)
{
// not global version and version.productid != product.productid
if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
{
echo 'invalid version specified';
exit;
}
}
// using a component
else
{
$component = $bugsys->datastore['product']["$vars[component]"];
// component has the right mother
if ($component['componentmother'] == $product['productid'])
{
// version.productid != {component.productid | product.productid}
if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
{
echo 'invalid version specified';
exit;
}
}
else
{
echo 'invalid component specified';
exit;
}
}
// good-to-go
$DB_sql->query("UPDATE " . TABLE_PREFIX . "bug SET productid = $vars[product], componentid = $vars[component], versionid = $vars[version] WHERE bugid = $bug[bugid]");
echo "changed product info";
}
// ###################################################################
if ($_REQUEST['do'] == 'editproduct')
{
sanitize(array('product' => INT, 'component' => INT, 'version' => INT));
$select['do'] = 'editproduct';
$select['script'] = 'editreport';
if (!$vars['product'])
{
$products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC");
while ($product = $DB_sql->fetch_array($products))
{
$value = $product['productid'];
$selected = iff($product['productid'] == $bug['productid'], true, false);
$label = $product['title'];
eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
}
$select['display'] = 'Product';
$select['name'] = 'product';
eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
}
else if (!$vars['component'])
{
$value = '-1';
$selected = iff($bug['componentid'] == -1, true, false);
$label = 'No Component';
eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
$components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
while ($component = $DB_sql->fetch_array($components))
{
$value = $component['productid'];
$selected = iff($component['productid'] == $bug['componentid'], true, false);
$label = $component['title'];
eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
}
$select['display'] = 'Component';
$select['name'] = 'component';
eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
}
else if (!$vars['version'])
{
$versions = $DB_sql->query("
SELECT version.*, product.componentmother, product.title AS productname
FROM " . TABLE_PREFIX . "version AS version
LEFT JOIN " . TABLE_PREFIX . "product ON (product.productid = version.productid)
WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
ORDER BY version.productid, version.displayorder ASC"
);
while ($version = $DB_sql->fetch_array($versions))
{
$versionlist["$version[productid]"][] = $version;
$lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
}
foreach ($versionlist AS $productid => $versions)
{
$prepend = '-- ';
// global version
if ($productid == 0)
{
$glabel = 'Global Versions';
}
// component
else if ($lookup["$productid"]['componentmother'])
{
$glabel = $lookup["$productid"]['productname'];
}
else
{
$glabel = $lookup["$productid"]['productname'];
}
foreach ($versions AS $version)
{
$value = $version['versionid'];
$selected = iff($version['versionid'] == $bug['versionid'], true, false);
$label = $prepend . $version['version'];
eval('$optbits .= "' . $tpl->fetch('selectoption') . '";');
}
eval('$select[options] .= "' . $tpl->fetch('selectoptgroup') . '";');
$optbits = '';
}
$select['display'] = 'Version';
$select['name'] = 'version';
$select['do'] = 'updateproduct';
$select['method'] = 'post';
eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
}
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>