]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 180460 request.cgi doesn't filter list of products/components
authorbugreport%peshkin.net <>
Mon, 25 Nov 2002 13:38:08 +0000 (13:38 +0000)
committerbugreport%peshkin.net <>
Mon, 25 Nov 2002 13:38:08 +0000 (13:38 +0000)
patch by joel
r=bbaetz
a=justdave

globals.pl
request.cgi

index 9d4372d0093c5abdebafc7d18f246ae9dac8a5db..07e9804c259a0054c9f90ebe7d4400721fb132db 100644 (file)
@@ -795,6 +795,51 @@ sub GetEnterableProducts {
     return (@products);
 }
 
+# GetEnterableProductHash
+# returns a hash containing 
+# legal_products => an enterable product list
+# legal_components => the list of components of enterable products
+# components => a hash of component lists for each enterable product
+sub GetEnterableProductHash {
+    my $query = "SELECT products.name, components.name " .
+                "FROM products " .
+                "LEFT JOIN components " .
+                "ON components.product_id = products.id " .
+                "LEFT JOIN group_control_map " .
+                "ON group_control_map.product_id = products.id " .
+                "AND group_control_map.entry != 0 ";
+    if ((defined @{$::vars->{user}{groupids}}) 
+        && (@{$::vars->{user}{groupids}} > 0)) {
+        $query .= "AND group_id NOT IN(" . 
+                   join(',', @{$::vars->{user}{groupids}}) . ") ";
+    }
+    $query .= "WHERE group_id IS NULL " .
+              "ORDER BY products.name, components.name";
+    PushGlobalSQLState();
+    SendSQL($query);
+    my @products = ();
+    my %components = ();
+    my %components_by_product = ();
+    while (MoreSQLData()) {
+        my ($product, $component) = FetchSQLData();
+        if (!grep($_ eq $product, @products)) {
+            push @products, $product;
+        }
+        if ($component) {
+            $components{$component} = 1;
+            push @{$components_by_product{$product}}, $component;
+        }
+    }
+    PopGlobalSQLState();
+    my @componentlist = (sort keys %components);
+    return {
+        legal_products => \@products,
+        legal_components => \@componentlist,
+        components => \%components_by_product,
+    };
+}
+
+
 sub CanSeeBug {
 
     my ($id, $userid) = @_;
index c2dbae81eaec2ba20ba43c4008ca05cba6ea5941..c74e97e64cc475fa078cb19c79ad66ef60c5c858 100755 (executable)
@@ -254,9 +254,10 @@ sub queue {
     # menu when the products menu changes; used by the template to populate
     # the menus and keep the components menu consistent with the products menu
     GetVersionTable();
-    $vars->{'products'} = \@::legal_product;
-    $vars->{'components'} = \@::legal_components;
-    $vars->{'components_by_product'} = \%::components;
+    my $enterable = GetEnterableProductHash();
+    $vars->{'products'} = $enterable->{legal_products};
+    $vars->{'components'} = $enterable->{legal_components};
+    $vars->{'components_by_product'} = $enterable->{components};
     
     $vars->{'excluded_columns'} = \@excluded_columns;
     $vars->{'group_field'} = $::FORM{'group'};