summaryrefslogtreecommitdiffstats
path: root/describecomponents.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'describecomponents.cgi')
-rwxr-xr-xdescribecomponents.cgi68
1 files changed, 36 insertions, 32 deletions
diff --git a/describecomponents.cgi b/describecomponents.cgi
index 86f652fcc..48b0c4bf6 100755
--- a/describecomponents.cgi
+++ b/describecomponents.cgi
@@ -33,53 +33,57 @@ use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Product;
-my $user = Bugzilla->login();
-my $cgi = Bugzilla->cgi;
+my $user = Bugzilla->login();
+my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
-my $vars = {};
+my $vars = {};
print $cgi->header();
# This script does nothing but displaying mostly static data.
Bugzilla->switch_to_shadow_db;
-my $product_name = trim($cgi->param('product') || '');
+my $product_name = trim($cgi->param('product') || '');
my $component_mark = trim($cgi->param('component') || '');
my $product = new Bugzilla::Product({'name' => $product_name});
unless ($product && $user->can_access_product($product->name)) {
- # Products which the user is allowed to see.
- my @products = @{$user->get_accessible_products};
- if (scalar(@products) == 0) {
- ThrowUserError("no_products");
- }
- # If there is only one product available but the user entered
- # another product name, we display a list with this single
- # product only, to not confuse the user with components of a
- # product he didn't request.
- elsif (scalar(@products) > 1 || $product_name) {
- $vars->{'classifications'} = [{object => undef, products => \@products}];
- $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
- # with a list of the products the user can choose from.
- if ($product_name) {
- $vars->{'message'} = "product_invalid";
- # Do not use $product->name here, else you could use
- # this way to determine whether the product exists or not.
- $vars->{'product'} = $product_name;
- }
-
- $template->process("global/choose-product.html.tmpl", $vars)
- || ThrowTemplateError($template->error());
- exit;
+ # Products which the user is allowed to see.
+ my @products = @{$user->get_accessible_products};
+
+ if (scalar(@products) == 0) {
+ ThrowUserError("no_products");
+ }
+
+ # If there is only one product available but the user entered
+ # another product name, we display a list with this single
+ # product only, to not confuse the user with components of a
+ # product he didn't request.
+ elsif (scalar(@products) > 1 || $product_name) {
+ $vars->{'classifications'} = [{object => undef, products => \@products}];
+ $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
+ # with a list of the products the user can choose from.
+ if ($product_name) {
+ $vars->{'message'} = "product_invalid";
+
+ # Do not use $product->name here, else you could use
+ # this way to determine whether the product exists or not.
+ $vars->{'product'} = $product_name;
}
- # If there is only one product available and the user didn't specify
- # any product name, we show this product.
- $product = $products[0];
+ $template->process("global/choose-product.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ exit;
+ }
+
+ # If there is only one product available and the user didn't specify
+ # any product name, we show this product.
+ $product = $products[0];
}
######################################################################