r1349: Renaming product.componentmother to product.parentid
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 10 Dec 2006 22:22:08 +0000 (22:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 10 Dec 2006 22:22:08 +0000 (22:22 +0000)
admin/permission.php
admin/product.php
docs/schema_changes.sql
explain.php
includes/api_bug.php
includes/functions.php
includes/functions_datastore.php
includes/functions_product.php

index 1d89b4a57c6a18c6d038fb7a0348823741b116fe..780a11ace49a580019e518f7e4538120ed88d92a 100755 (executable)
@@ -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'];
index 92735e2491de6875fdae2ce357c3964d16554f6b..8ec720c8caa75252d64d79a8ee01a9a28c34cd9e 100755 (executable)
@@ -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();
        }
index 5eb9e625ee18216a0b55acff01ac1e9294069cdf..dd01cf18e6ee394e11f1e05e0e4b07aaa50b9b3c 100644 (file)
@@ -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;
index e4b2baba49dfb45e01dfd0d24a74df65987f9bdb..4ccf0b02edd0fb821e66ee88876067881453cca1 100644 (file)
@@ -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;
                }
index d1da1d40aae0d535a80d2da0e9261c43617c4815..66c62a32fdfb1aada851766aebc3a77fe3167284 100644 (file)
@@ -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;
                        }
index 982dbfa78e5282cedfc889f307eee48fb4f29d40..01e5428a84eb3c43e31768c37237a6386c27aae2 100755 (executable)
@@ -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'];
index b9a9561c51cd310a2164a0f4d477906d9ca6f1d5..c2cf24ef2b832efcd08eb15a60cc6f25040c99b7 100755 (executable)
@@ -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 #####################
index 5191854d0619d0c2aa6622f2a34b9a9c39851979..57bb576ca06844eaacf1085e09582d51a14b5f92 100644 (file)
@@ -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)