' . $bugsys->lang->string('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'])); $db->query("DELETE FROM " . TABLE_PREFIX . "bug WHERE versionid = " . intval($bugsys->in['versionid'])); build_versions(); $admin->redirect('product.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'deleteversion') { $admin->page_confirm($lang->string('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=' . 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->string('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->getlex('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->string('Add New Version')); $admin->row_input($lang->string('Version Number
This is the version string for this product.
'), 'version'); $admin->row_input($lang->string('Display Order
The order in which the versions are displayed.
'), '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->string('Please fill in a 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->string('Edit Version')); $version = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "version WHERE versionid = " . intval($bugsys->in['versionid'])); if (!is_array($version)) { $admin->error($lang->getlex('error_invalid_id')); } $admin->form_start('product.php', 'updateversion'); $admin->form_hidden_field('versionid', $version['versionid']); $admin->table_start(); $admin->table_head(sprintf($lang->string('Edit Version - %1$s'), $version['version'])); $admin->row_input($lang->string('Version Number
This is the version string for this product.
'), 'version', $version['version']); $admin->row_input($lang->string('Display Order
The 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') { $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) . ")"); $db->query("DELETE FROM " . TABLE_PREFIX . "bug WHERE productid IN (" . implode(', ', $list) . ")"); build_products(); $admin->redirect('product.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'deleteproduct') { $admin->page_confirm($lang->string('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=' . intval($bugsys->in['productid'])); } // ################################################################### if ($_REQUEST['do'] == 'insertproduct') { if (empty($bugsys->in['shortname']) OR empty($bugsys->in['title'])) { $admin->error($lang->string('Please go back and fill in 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->string('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->string('Add Product')); $admin->row_input($lang->string('Short Name
The name that can be used to submit email reports. This should be unique.
'), 'shortname'); $admin->row_input($lang->string('Title'), 'title'); $admin->row_textarea($lang->string('Description
A short description of this product.
'), 'description'); $admin->row_input($lang->string('Display Order
The order in which the products are displayed.
'), '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->string('Please go back and fill in both fields.')); } if (empty($bugsys->in['productid'])) { $admin->error($lang->getlex('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->string('Edit Product')); $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . intval($bugsys->in['productid'])); if (!is_array($product)) { $admin->error($lang->getlex('error_invalid_id')); } $admin->form_start('product.php', 'updateproduct'); $admin->form_hidden_field('productid', $product['productid']); $admin->table_start(); $admin->table_head(sprintf($lang->string('Edit Product - %1$s'), $product['title'])); $admin->row_input($lang->string('Title'), 'title', $product['title']); $admin->row_input($lang->string('Short Name
The name that can be used to submit email reports. This should be unique.
'), 'shortname', $product['shortname']); $admin->row_textarea($lang->string('Description
A short description of this product.
'), 'description', $product['description']); $admin->row_input($lang->string('Display Order
The 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->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->string('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->string('Products / Versions')); // Handle our global versions if (is_array($versions['0'])) { $admin->row_text($lang->string('Global Versions'), construct_option_list($lang->string('Product'), -1, 0, 0, 1, 0, -1), 'middle', 2, 'alt3'); foreach ($versions['0'] AS $version) { $admin->row_text('-- ' . $version['version'], construct_option_list($lang->string('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($lang->string('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($lang->string('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($lang->string('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($lang->string('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2'); } } } $admin->row_submit('[' . $lang->string('Add New Product') . ']', $lang->string('Save Display Order'), null); $admin->table_end(); $admin->form_end(); $admin->page_end(); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>