From 22c141030bfd6a3a5e911cad72bed53f6553c8af Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 22 Feb 2006 01:24:32 +0000 Subject: Bug 311278: Eliminate %::proddesc - Patch by Max Kanat-Alexander r=LpSolit a=justdave --- describecomponents.cgi | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'describecomponents.cgi') diff --git a/describecomponents.cgi b/describecomponents.cgi index 1b1ccbfe0..c00f39bed 100755 --- a/describecomponents.cgi +++ b/describecomponents.cgi @@ -42,28 +42,21 @@ my $product = trim($cgi->param('product') || ''); my $product_id = get_product_id($product); if (!$product_id || !$user->can_enter_product($product)) { - # Reference to a subset of %::proddesc, which the user is allowed to see - my %products; - - if (AnyEntryGroups()) { - # OK, now only add products the user can see - Bugzilla->login(LOGIN_REQUIRED); - foreach my $p (@::legal_product) { - if ($user->can_enter_product($p)) { - $products{$p} = $::proddesc{$p}; - } - } - } - else { - %products = %::proddesc; - } + # Products which the user is allowed to see. + my @products = @{$user->get_enterable_products()}; - my $prodsize = scalar(keys %products); - if ($prodsize == 0) { + if (scalar(@products) == 0) { ThrowUserError("no_products"); } - elsif ($prodsize > 1) { - $vars->{'proddesc'} = \%products; + elsif (scalar(@products) > 1) { + # XXX - For backwards-compatibility with old template + # interfaces, we now create a proddesc hash. This can go away + # once we update the templates. + my %product_desc; + foreach my $product (@products) { + $product_desc{$product->name} = $product->description; + } + $vars->{'proddesc'} = \%product_desc; $vars->{'target'} = "describecomponents.cgi"; # If an invalid product name is given, or the user is not # allowed to access that product, a message is displayed @@ -79,8 +72,9 @@ if (!$product_id || !$user->can_enter_product($product)) { exit; } - $product = (keys %products)[0]; - $product_id = get_product_id($product); + # Else, if there is only one product: + $product = $products[0]->name; + $product_id = $products[0]->id; } ###################################################################### -- cgit v1.2.3-24-g4f1b