Edit ' . $type_display . '';
}
if ($delete)
{
$opt .= '';
}
if ($addcomponent)
{
$opt .= '';
}
if ($addversion)
{
$opt .= '';
}
$type = strtolower($type);
$name = $type . '_' . $id;
$displayorder = iff($displayorder != -1, ' ', '');
return $displayorder . ' ';
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'killversion')
{
sanitize(array('versionid' => INT));
$DB_sql->query("DELETE FROM " . TABLE_PREFIX . "version WHERE versionid = $vars[versionid]");
// #*# figure out what we do with bugs
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'deleteversion')
{
sanitize(array('versionid' => INT));
$admin->page_confirm('Are you sure you want to delete this version? Doing so will do x to the bugs with this version.', 'product.php?do=killversion&versionid=' . $vars['versionid']);
}
// ###################################################################
if ($_REQUEST['do'] == 'insertversion')
{
sanitize(array('productid' => INT, 'version' => STR, 'displayorder' => INT));
$DB_sql->query("INSERT INTO " . TABLE_PREFIX . "version (productid, version, displayorder) VALUES ($vars[productid], '" . addslasheslike($vars['version']) . "', $vars[displayorder])");
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'addversion')
{
sanitize(array('productid' => INT));
$admin->page_start('Add Version');
if ($vars['productid'] != -1)
{
$product = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = $vars[productid]");
if (!is_array($product))
{
$admin->error('-1');
}
}
else
{
$vars['productid'] = 0;
}
$admin->form_start('product.php', 'insertversion');
$admin->form_hidden_field('productid', $vars['productid']);
$admin->table_start();
$admin->table_head('Add New Version');
$admin->row_input('Version Number
This is the version string for this product.
', 'version');
$admin->row_input('Display OrderThe order in which the versions are displayed.
', 'displayorder');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'updateversion')
{
sanitize(array('versionid' => INT, 'version' => STR, 'displayorder' => INT));
if (empty($vars['version']))
{
$admin->error('Please fill in a version number.');
}
$DB_sql->query("UPDATE " . TABLE_PREFIX . "version SET version = '" . addslasheslike($vars['version']) . "', displayorder = $vars[displayorder] WHERE versionid = $vars[versionid]");
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'editversion')
{
sanitize(array('versionid' => INT));
$admin->page_start('Edit Version');
$version = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX . "version WHERE versionid = $vars[versionid]");
if (!is_array($version))
{
$admin->error('-1');
}
$admin->form_start('product.php', 'updateversion');
$admin->form_hidden_field('versionid', $version['versionid']);
$admin->table_start();
$admin->table_head('Edit Version - ' . $version['version']);
$admin->row_input('Version NumberThis is the version string for this product.
', 'version', $version['version']);
$admin->row_input('Display OrderThe order in which the versions are displayed.
', 'displayorder', $version['displayorder']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'killproduct')
{
sanitize(array('productid' => INT));
$allprods = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = $vars[productid] OR componentmother = $vars[productid]");
while ($prod = $DB_sql->fetch_array($allprods))
{
$list[] = $prod['productid'];
}
$DB_sql->query("DELETE FROM " . TABLE_PREFIX . "product WHERE productid IN (" . implode(', ', $list) . ")");
$DB_sql->query("DELETE FROM " . TABLE_PREFIX . "version WHERE productid IN (" . implode(', ', $list) . ")");
// #*# do bug kills here
build_products();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'deleteproduct')
{
sanitize(array('productid' => INT));
$admin->page_confirm('Are you sure you want to delete this product and all of it\'s sub-versions and components (as well as any bugs contained within those groups)?', 'product.php?do=killproduct&productid=' . $vars['productid']);
}
// ###################################################################
if ($_REQUEST['do'] == 'insertproduct')
{
sanitize(array('shortname' => STR, 'title' => STR, 'componentmother' => INT, 'description' => STR, 'displayorder' => INT));
if (empty($vars['shortname']) OR empty($vars['title']))
{
$admin->error('please go back and enter both fields');
}
$DB_sql->query("
INSERT INTO " . TABLE_PREFIX . "product
(shortname, title, componentmother, description, displayorder)
VALUES
('" . addslasheslike($vars['shortname']) . "', '" . addslasheslike($vars['title']) . "',
$vars[componentmother], '" . addslasheslike($vars['description']) . "', $vars[displayorder])"
);
build_products();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'addproduct')
{
sanitize(array('productid' => INT));
$admin->page_start('Add New Product');
$admin->form_start('product.php', 'insertproduct');
$admin->form_hidden_field('componentmother', $vars['productid']);
$admin->table_start();
$admin->table_head('Add Product');
$admin->row_input('Short NameThe name that can be used to submit email reports. This should be unique.
', 'shortname');
$admin->row_input('Product Title', 'title');
$admin->row_textarea('DescriptionA short description of this product.
', 'description');
$admin->row_input('Display OrderThe order in which the products are displayed.
', 'displayorder');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'updateproduct')
{
sanitize(array('productid' => INT, 'title' => STR, 'shortname' => STR, 'description' => STR, 'displayorder' => INT));
if (empty($vars['shortname']) OR empty($vars['title']))
{
$admin->error('please go back and fill in both fields');
}
if (empty($vars['productid']))
{
$admin->error('-1');
}
$DB_sql->query("UPDATE " . TABLE_PREFIX . "product SET title = '" . addslasheslike($vars['title']) . "', shortname = '" . addslasheslike($vars['shortname']) . "', description = '" . addslasheslike($vars['description']) . "', displayorder = $vars[displayorder] WHERE productid = $vars[productid]");
build_products();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'editproduct')
{
sanitize(array('productid' => INT));
$admin->page_start('Edit Product');
$product = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = $vars[productid]");
if (!is_array($product))
{
$admin->error('-1');
}
$admin->form_start('product.php', 'updateproduct');
$admin->form_hidden_field('productid', $product['productid']);
$admin->table_start();
$admin->table_head('Edit Product - ' . $product['title']);
$admin->row_input('Product Title', 'title', $product['title']);
$admin->row_input('Short NameThe name that can be used to submit email reports. This should be unique.
', 'shortname', $product['shortname']);
$admin->row_textarea('DescriptionA short description of this product.
', 'description', $product['description']);
$admin->row_input('Display OrderThe order in which the products are displayed.
', 'displayorder', $product['displayorder']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'displayorder')
{
foreach ((array)$_POST['displayorder'] AS $namebit => $displayorder)
{
$name = explode('_', $namebit);
if ($name[0] == 'product' OR $name[0] == 'version')
{
$id = intval($name[1]);
$order = intval($displayorder);
$DB_sql->query("UPDATE " . TABLE_PREFIX . "$name[0] SET displayorder = $order WHERE $name[0]id = $id");
}
}
build_products();
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$admin->page_start('Products and Versions');
$javascript = <<
EOF;
$admin->page_code($javascript);
$admin->form_start('product.php', 'displayorder');
$products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
while ($prod = $DB_sql->fetch_array($products))
{
if (!$prod['componentmother'])
{
$product["$prod[productid]"] = $prod;
}
else
{
$component["$prod[componentmother]"][] = $prod;
}
$version["$prod[productid]"] = array();
}
$products = (array)$product;
$versions = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
while ($vers = $DB_sql->fetch_array($versions))
{
$version["$vers[productid]"]["$vers[versionid]"] = $vers;
}
$versions = (array)$version;
$admin->table_start();
$admin->table_head('Products / Versions');
// Handle our global versions
if (is_array($versions['0']))
{
$admin->row_text('Global Versions', construct_option_list('product', -1, 0, 0, 1, 0, -1), 'middle', 2, 'alt3');
foreach ($versions['0'] AS $version)
{
$admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
}
}
// Now let's do the rest of the versions
foreach ($products AS $product)
{
// Product
$admin->row_text("$product[title]", construct_option_list('product', $product['productid'], 1, 1, 1, 1, $product['displayorder']), 'middle', 2, 'alt3');
// Versions
foreach ($versions["$product[productid]"] AS $version)
{
$admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
}
// Components
foreach ((array)$component["$product[productid]"] AS $comp)
{
$admin->row_text("-- $comp[title]", construct_option_list('component', $comp['productid'], 1, 0, 1, 1, $comp['displayorder']), 'middle', 2, 'alt1');
// Component versions
foreach ($versions["$comp[productid]"] AS $version)
{
$admin->row_text('---- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
}
}
}
$admin->row_span(' ', 'tfoot', 'center');
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>