From 6b44875b901ac8d1d7383fed017c973a9f954051 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 3 Sep 2005 04:12:07 +0000 Subject: Bug 286158: Remove GetSelectableProducts() from globals.pl and use Bugzilla::User::get_selectable_products() instead - Patch by Frédéric Buclin r=joel,kiko a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- query.cgi | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'query.cgi') diff --git a/query.cgi b/query.cgi index 2f73f0602..4a414d46c 100755 --- a/query.cgi +++ b/query.cgi @@ -66,7 +66,8 @@ if ($cgi->param("GoAheadAndLogIn")) { Bugzilla->login(); } -my $userid = Bugzilla->user->id; +my $user = Bugzilla->user; +my $userid = $user->id; # Backwards compatibility hack -- if there are any of the old QUERY_* # cookies around, and we are logged in, then move them into the database @@ -219,23 +220,26 @@ GetVersionTable(); # if using groups for entry, then we don't want people to see products they # don't have access to. Remove them from the list. -my @products = (); +my @selectable_product_objects = @{$user->get_selectable_products}; + my %component_set; my %version_set; my %milestone_set; -foreach my $p (GetSelectableProducts()) { +# extract product names +my @products = map { $_->name } @selectable_product_objects; + +foreach my $prod_name (@products) { # We build up boolean hashes in the "-set" hashes for each of these things # before making a list because there may be duplicates names across products. - push @products, $p; - if ($::components{$p}) { - foreach my $c (@{$::components{$p}}) { + if ($::components{$prod_name}) { + foreach my $c (@{$::components{$prod_name}}) { $component_set{$c} = 1; } } - foreach my $v (@{$::versions{$p}}) { + foreach my $v (@{$::versions{$prod_name}}) { $version_set{$v} = 1; } - foreach my $m (@{$::target_milestone{$p}}) { + foreach my $m (@{$::target_milestone{$prod_name}}) { $milestone_set{$m} = 1; } } @@ -296,11 +300,16 @@ $vars->{'product'} = \@products; if (Param('useclassification')) { my @classifications = (); - foreach my $c (GetSelectableClassifications()) { + my $class = $user->get_selectable_classifications; + foreach my $c (@$class) { + # Extract the name of products being in this classification. + my @prod_in_class + = grep { $_->classification_id == $c->id } @selectable_product_objects; + @prod_in_class = map { $_->name } @prod_in_class; # Create hash to hold attributes for each classification. my %classification = ( - 'name' => $c, - 'products' => [ GetSelectableProducts(0,$c) ] + 'name' => $c->name, + 'products' => \@prod_in_class ); # Assign hash back to classification array. push @classifications, \%classification; -- cgit v1.2.3-24-g4f1b