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->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(phrase('confirm_delete_version'), 'product.php?do=killversion&versionid=' . $vars['versionid']); } // ################################################################### if ($_REQUEST['do'] == 'insertversion') { sanitize(array('productid' => INT, 'version' => STR, 'displayorder' => INT)); $db->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(phrase('add_version')); if ($vars['productid'] != -1) { $product = $db->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(phrase('add_new_version')); $admin->row_input(phrase('version_title'), 'version'); $admin->row_input(phrase('version_display_order'), '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(phrase('fill_in_version_number')); } $db->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(phrase('edit_version')); $version = $db->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(phrase('edit_version_title', $version['version'])); $admin->row_input(phrase('version_title'), 'version', $version['version']); $admin->row_input(phrase('version_display_order'), '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->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = $vars[productid] OR componentmother = $vars[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') { sanitize(array('productid' => INT)); $admin->page_confirm(phrase('confirm_delete_product'), '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(phrase('go_back_and_fill_both_fields')); } $db->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(phrase('add_new_product')); $admin->form_start('product.php', 'insertproduct'); $admin->form_hidden_field('componentmother', $vars['productid']); $admin->table_start(); $admin->table_head(phrase('add_product')); $admin->row_input(phrase('product_shortname'), 'shortname'); $admin->row_input(phrase('product_title'), 'title'); $admin->row_textarea(phrase('product_description'), 'description'); $admin->row_input(phrase('product_display_order'), '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(phrase('go_back_and_fill_both_fields')); } if (empty($vars['productid'])) { $admin->error('-1'); } $db->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(phrase('edit_product')); $product = $db->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(phrase('edit_product_title', $product['title'])); $admin->row_input(phrase('product_title'), 'title', $product['title']); $admin->row_input(phrase('product_shortname'), 'shortname', $product['shortname']); $admin->row_textarea(phrase('product_description'), 'description', $product['description']); $admin->row_input(phrase('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(phrase('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(phrase('products_versions')); // Handle our global versions if (is_array($versions['0'])) { $admin->row_text(phrase('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$ || ################################################################### \*=====================================================================*/ ?>