From b3cae593e43eed73573b1cbdc82edc9a057909ae Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 10 Dec 2006 22:22:08 +0000 Subject: [PATCH] r1349: Renaming product.componentmother to product.parentid --- admin/permission.php | 2 +- admin/product.php | 12 ++++++------ docs/schema_changes.sql | 2 ++ explain.php | 2 +- includes/api_bug.php | 4 ++-- includes/functions.php | 7 ++----- includes/functions_datastore.php | 16 +++++++++++++--- includes/functions_product.php | 18 +++++++++--------- 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/admin/permission.php b/admin/permission.php index 1d89b4a..780a11a 100755 --- a/admin/permission.php +++ b/admin/permission.php @@ -199,7 +199,7 @@ if ($_REQUEST['do'] == 'modify') $permissions["$permission[productid]"] = $permission['mask']; } - $products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC"); + $products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !parentid ORDER BY displayorder ASC"); while ($product = $db->fetch_array($products_fetch)) { $groupid = $group['usergroupid']; diff --git a/admin/product.php b/admin/product.php index 92735e2..8ec720c 100755 --- a/admin/product.php +++ b/admin/product.php @@ -184,7 +184,7 @@ if ($_REQUEST['do'] == 'editversion') if ($_REQUEST['do'] == 'killproduct') { $bugsys->input_clean('productid', TYPE_UINT); - $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . $bugsys->in['productid'] . " OR componentmother = " . $bugsys->in['productid']); + $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . $bugsys->in['productid'] . " OR parentid = " . $bugsys->in['productid']); while ($prod = $db->fetch_array($allprods)) { $list[] = $prod['productid']; @@ -217,9 +217,9 @@ if ($_REQUEST['do'] == 'insertproduct') $db->query(" INSERT INTO " . TABLE_PREFIX . "product - (title, componentmother, description, displayorder) + (title, parentid, description, displayorder) VALUES - ('" . $bugsys->input_escape('title') . "', " . $bugsys->input_clean('componentmother', TYPE_UINT) . ", + ('" . $bugsys->input_escape('title') . "', " . $bugsys->input_clean('parentid', TYPE_UINT) . ", '" . $bugsys->input_escape('description') . "', " . $bugsys->input_clean('displayorder', TYPE_UINT) . " )" ); @@ -245,7 +245,7 @@ if ($_REQUEST['do'] == 'addproduct') $admin->page_start(_('Add New Product')); $admin->form_start('product.php', 'insertproduct'); - $admin->form_hidden_field('componentmother', $bugsys->in['productid']); + $admin->form_hidden_field('parentid', $bugsys->in['productid']); $admin->table_start(); $admin->table_head(_('Add Product')); $admin->row_input(_('Title'), 'title'); @@ -357,13 +357,13 @@ EOF; $products = array(); while ($prod = $db->fetch_array($products_get)) { - if (!$prod['componentmother']) + if (!$prod['parentid']) { $products["$prod[productid]"] = $prod; } else { - $components["$prod[componentmother]"][] = $prod; + $components["$prod[parentid]"][] = $prod; } $version["$prod[productid]"] = array(); } diff --git a/docs/schema_changes.sql b/docs/schema_changes.sql index 5eb9e62..dd01cf1 100644 --- a/docs/schema_changes.sql +++ b/docs/schema_changes.sql @@ -3,3 +3,5 @@ ALTER TABLE `comment` ADD parselinks BOOL NULL; ALTER TABLE user ADD columnoptions TEXT NULL; + +ALTER TABLE product CHANGE componentmother parentid int(10) UNSIGNED NULL; diff --git a/explain.php b/explain.php index e4b2bab..4ccf0b0 100644 --- a/explain.php +++ b/explain.php @@ -49,7 +49,7 @@ if ($_REQUEST['do'] == 'products') foreach ($bugsys->datastore['product'] AS $product) { - if ($product['componentmother']) + if ($product['parentid']) { $components["$product[componentmother]"]["$product[productid]"] = $product; } diff --git a/includes/api_bug.php b/includes/api_bug.php index d1da1d4..66c62a3 100644 --- a/includes/api_bug.php +++ b/includes/api_bug.php @@ -147,10 +147,10 @@ class BugAPI extends API { if ($this->values['component'] != 0) { - $component = $this->registry->datastore['product'][ $this->values['component'] ]; + $component = $this->registry->datastore['component'][ $this->values['component'] ]; $product = $this->registry->datastore['product'][ $this->values['product'] ]; $version = $this->registry->datastore['version'][ $this->values['version'] ]; - if ($component['componentmother'] != $product['productid']) + if ($component['parentid'] != $product['productid']) { return false; } diff --git a/includes/functions.php b/includes/functions.php index 982dbfa..01e5428 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -460,10 +460,7 @@ function fetch_on_bits($mask, $userinfo = null) { foreach ($bugsys->datastore['product'] AS $id => $product) { - if (!$product['componentmother']) - { - $onbits["$id"] = $id; - } + $onbits["$id"] = $id; } } @@ -635,7 +632,7 @@ function ProcessBugDataForDisplay($bug, $color = '') $bug['bgcolor'] = ($bugsys->userinfo['showcolors'] ? $bugsys->datastore['status']["$bug[status]"]['color'] : $color); $bug['product'] = $bugsys->datastore['product']["$bug[product]"]['title']; $bug['version'] = $bugsys->datastore['version']["$bug[version]"]['version']; - $bug['component'] = $bugsys->datastore['product']["$bug[component]"]['title']; + $bug['component'] = $bugsys->datastore['component']["$bug[component]"]['title']; $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status']; $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution']; $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority']; diff --git a/includes/functions_datastore.php b/includes/functions_datastore.php index b9a9561..c2cf24e 100755 --- a/includes/functions_datastore.php +++ b/includes/functions_datastore.php @@ -212,16 +212,26 @@ function build_products() $products = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); while ($product = $bugsys->db->fetch_array($products)) { - $tempstore["$product[productid]"] = $product; + if ($product['parentid']) + { + $tempstore['component']["$product[productid]"] = $product; + } + else + { + $tempstore['product']["$product[productid]"] = $product; + } } $bugsys->db->query(" ### replacing product / component cache ### REPLACE INTO " . TABLE_PREFIX . "datastore (title, data) - VALUES ('product', '" . $bugsys->escape(serialize($tempstore)) . "')" + VALUES + ('product', '" . $bugsys->escape(serialize($tempstore['product'])) . "'), + ('component', '" . $bugsys->escape(serialize($tempstore['component'])) . "')" ); - $bugsys->datastore['product'] = $tempstore; + $bugsys->datastore['product'] = $tempstore['product']; + $bugsys->datastore['component'] = $tempstore['component']; } // ##################### Start build_permissions ##################### diff --git a/includes/functions_product.php b/includes/functions_product.php index 5191854..57bb576 100644 --- a/includes/functions_product.php +++ b/includes/functions_product.php @@ -37,15 +37,15 @@ function ConstructProductSelect($action = 'canviewbugs', $select = null) $output = ''; - // index all of the products by parent and ID - $products = array(); - foreach ($bugsys->datastore['product'] AS $id => $prod) + // index all of the components by parent and ID + $components = array(); + foreach ($bugsys->datastore['component'] AS $id => $prod) { - $products["$prod[componentmother]"]["$id"] = $prod; + $components["$prod[parentid]"]["$id"] = $prod; } // these are products - foreach ($products['0'] AS $productid => $product) + foreach ($bugsys->datastore['product'] AS $productid => $product) { if (!can_perform($action, $product['productid']) OR !can_perform('canviewbugs', $product['productid'])) { @@ -55,7 +55,7 @@ function ConstructProductSelect($action = 'canviewbugs', $select = null) $output .= ConstructOptionGroup($product['title'], ConstructVersionSelect($productid, $select)); // these are components - foreach ($products["$productid"] AS $componentid => $component) + foreach ($components["$productid"] AS $componentid => $component) { $output .= ConstructOptionGroup($product['title'] . '/' . $component['title'], ConstructVersionSelect($componentid, $select)); } @@ -85,10 +85,10 @@ function ConstructVersionSelect($productid, $select) $build = ''; // this is a component - if ($product['componentmother']) + if ($product == null) { - $component = $bugsys->datastore['product']["$productid"]; - $product = $bugsys->datastore['product']["$component[componentmother]"]; + $component = $bugsys->datastore['component']["$productid"]; + $product = $bugsys->datastore['product']["$component[parentid]"]; } foreach ($bugsys->datastore['version'] AS $versionid => $version) -- 2.22.5