Edit ' . $type_display . '';
}
if ($delete)
{
$opt .= '';
}
if ($addcomponent)
{
$opt .= '';
}
if ($addversion)
{
$opt .= '';
}
$type = strtolower($type);
$name = $type . '_' . $id;
$displayorder = (($displayorder != -1) ? ' ' : '');
return $displayorder . ' ';
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'killversion')
{
$db->query("DELETE FROM " . TABLE_PREFIX . "version WHERE versionid = " . intval($bugsys->in['versionid']));
// #*# figure out what we do with bugs
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'deleteversion')
{
$admin->page_confirm(lang::p('confirm_delete_version'), 'product.php?do=killversion&versionid=' . intval($bugsys->in['versionid']));
}
// ###################################################################
if ($_REQUEST['do'] == 'insertversion')
{
$db->query("INSERT INTO " . TABLE_PREFIX . "version (productid, version, displayorder) VALUES (" . intval($bugsys->in['productid']) . ", '" . $bugsys->in['version'] . "', " . intval($bugsys->in['displayorder']) . ")");
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'addversion')
{
$admin->page_start(lang::p('add_version'));
if ($bugsys->in['productid'] != -1)
{
$product = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . intval($bugsys->in['productid']));
if (!is_array($product))
{
$admin->error(lang::p('error_invalid_id'));
}
}
else
{
$bugsys->in['productid'] = 0;
}
$admin->form_start('product.php', 'insertversion');
$admin->form_hidden_field('productid', intval($bugsys->in['productid']));
$admin->table_start();
$admin->table_head(lang::p('add_new_version'));
$admin->row_input(lang::p('version_title'), 'version');
$admin->row_input(lang::p('version_display_order'), 'displayorder');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'updateversion')
{
if (empty($bugsys->in['version']))
{
$admin->error(lang::p('fill_in_version_number'));
}
$db->query("UPDATE " . TABLE_PREFIX . "version SET version = '" . $bugsys->in['version'] . "', displayorder = " . intval($bugsys->in['displayorder']) . " WHERE versionid = " . intval($bugsys->in['versionid']));
build_versions();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'editversion')
{
$admin->page_start(lang::p('edit_version'));
$version = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "version WHERE versionid = " . intval($bugsys->in['versionid']));
if (!is_array($version))
{
$admin->error(lang::p('error_invalid_id'));
}
$admin->form_start('product.php', 'updateversion');
$admin->form_hidden_field('versionid', $version['versionid']);
$admin->table_start();
$admin->table_head(lang::p('edit_version_title', $version['version']));
$admin->row_input(lang::p('version_title'), 'version', $version['version']);
$admin->row_input(lang::p('version_display_order'), 'displayorder', $version['displayorder']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'killproduct')
{
$allprods = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . intval($bugsys->in['productid']) . " OR componentmother = " . intval($bugsys->in['productid']));
while ($prod = $db->fetch_array($allprods))
{
$list[] = $prod['productid'];
}
$db->query("DELETE FROM " . TABLE_PREFIX . "product WHERE productid IN (" . implode(', ', $list) . ")");
$db->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')
{
$admin->page_confirm(lang::p('confirm_delete_product'), 'product.php?do=killproduct&productid=' . intval($bugsys->in['productid']));
}
// ###################################################################
if ($_REQUEST['do'] == 'insertproduct')
{
if (empty($bugsys->in['shortname']) OR empty($bugsys->in['title']))
{
$admin->error(lang::p('go_back_and_fill_both_fields'));
}
$db->query("
INSERT INTO " . TABLE_PREFIX . "product
(shortname, title, componentmother, description, displayorder)
VALUES
('" . $bugsys->in['shortname'] . "', '" . $bugsys->in['title'] . "',
" . intval($bugsys->in['componentmother']) . ", '" . $bugsys->in['description'] . "', " . intval($bugsys->in['displayorder']) . ")"
);
build_products();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'addproduct')
{
$admin->page_start(lang::p('add_new_product'));
$admin->form_start('product.php', 'insertproduct');
$admin->form_hidden_field('componentmother', intval($bugsys->in['productid']));
$admin->table_start();
$admin->table_head(lang::p('add_product'));
$admin->row_input(lang::p('product_shortname'), 'shortname');
$admin->row_input(lang::p('product_title'), 'title');
$admin->row_textarea(lang::p('product_description'), 'description');
$admin->row_input(lang::p('product_display_order'), 'displayorder');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'updateproduct')
{
if (empty($bugsys->in['shortname']) OR empty($bugsys->in['title']))
{
$admin->error(lang::p('go_back_and_fill_both_fields'));
}
if (empty($bugsys->in['productid']))
{
$admin->error(lang::p('error_invalid_id'));
}
$db->query("UPDATE " . TABLE_PREFIX . "product SET title = '" . $bugsys->in['title'] . "', shortname = '" . $bugsys->in['shortname'] . "', description = '" . $bugsys->in['description'] . "', displayorder = " . intval($bugsys->in['displayorder']) . " WHERE productid = " . intval($bugsys->in['productid']));
build_products();
$admin->redirect('product.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'editproduct')
{
$admin->page_start(lang::p('edit_product'));
$product = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . intval($bugsys->in['productid']));
if (!is_array($product))
{
$admin->error(lang::p('error_invalid_id'));
}
$admin->form_start('product.php', 'updateproduct');
$admin->form_hidden_field('productid', $product['productid']);
$admin->table_start();
$admin->table_head(lang::p('edit_product_title', $product['title']));
$admin->row_input(lang::p('product_title'), 'title', $product['title']);
$admin->row_input(lang::p('product_shortname'), 'shortname', $product['shortname']);
$admin->row_textarea(lang::p('product_description'), 'description', $product['description']);
$admin->row_input(lang::p('product_display_order'), '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->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(lang::p('products_and_versions'));
$javascript = <<
EOF;
$admin->page_code($javascript);
$admin->form_start('product.php', 'displayorder');
$products = $db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
while ($prod = $db->fetch_array($products))
{
if (!$prod['componentmother'])
{
$product["$prod[productid]"] = $prod;
}
else
{
$component["$prod[componentmother]"][] = $prod;
}
$version["$prod[productid]"] = array();
}
$products = (array)$product;
$versions = $db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
while ($vers = $db->fetch_array($versions))
{
$version["$vers[productid]"]["$vers[versionid]"] = $vers;
}
$versions = (array)$version;
$admin->table_start();
$admin->table_head(lang::p('products_versions'));
// Handle our global versions
if (is_array($versions['0']))
{
$admin->row_text(lang::p('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$
|| ###################################################################
\*=====================================================================*/
?>