diff options
author | lpsolit%gmail.com <> | 2006-02-22 01:24:32 +0000 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-02-22 01:24:32 +0000 |
commit | 22c141030bfd6a3a5e911cad72bed53f6553c8af (patch) | |
tree | 4f13739cbfb5d28bd3cf3ab1637e66c5c68bd140 /describecomponents.cgi | |
parent | Bug 219555: 'Format for Printing' page is a mess - Patch by Olav Vitters <bug... (diff) | |
download | bugzilla-22c141030bfd6a3a5e911cad72bed53f6553c8af.tar.gz bugzilla-22c141030bfd6a3a5e911cad72bed53f6553c8af.tar.bz2 bugzilla-22c141030bfd6a3a5e911cad72bed53f6553c8af.zip |
Bug 311278: Eliminate %::proddesc - Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit a=justdave
Diffstat (limited to 'describecomponents.cgi')
-rwxr-xr-x | describecomponents.cgi | 36 |
1 files changed, 15 insertions, 21 deletions
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; } ###################################################################### |