diff options
author | bugreport%peshkin.net <> | 2002-11-25 13:38:08 +0000 |
---|---|---|
committer | bugreport%peshkin.net <> | 2002-11-25 13:38:08 +0000 |
commit | 9c07e003b12869792fdad5637e4f76789ffdaf2e (patch) | |
tree | e7cc501b4d2390bb18e915269a9f11bf4f24fc2f /globals.pl | |
parent | 8d94367316de4ab473ff117859e0fa6613e56518 (diff) | |
download | bugs-9c07e003b12869792fdad5637e4f76789ffdaf2e.tar bugs-9c07e003b12869792fdad5637e4f76789ffdaf2e.tar.gz bugs-9c07e003b12869792fdad5637e4f76789ffdaf2e.tar.bz2 bugs-9c07e003b12869792fdad5637e4f76789ffdaf2e.tar.xz bugs-9c07e003b12869792fdad5637e4f76789ffdaf2e.zip |
Bug 180460 request.cgi doesn't filter list of products/components
patch by joel
r=bbaetz
a=justdave
Diffstat (limited to 'globals.pl')
-rw-r--r-- | globals.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/globals.pl b/globals.pl index 9d4372d00..07e9804c2 100644 --- a/globals.pl +++ b/globals.pl @@ -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) = @_; |