]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 674574: When all components or versions are disabled, you cannot enter bugs into...
authorFrédéric Buclin <LpSolit@gmail.com>
Mon, 1 Aug 2011 08:32:12 +0000 (10:32 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 1 Aug 2011 08:32:12 +0000 (10:32 +0200)
r=dkl a=LpSolit

Bugzilla/User.pm
template/en/default/global/user-error.html.tmpl

index 1884322414a676265028460a8ac6c0711e416470..3a3edcb5ba063ae67062fe33f41ef79ce42a623b 100644 (file)
@@ -1004,11 +1004,15 @@ sub can_enter_product {
         ThrowUserError('product_disabled', { product => $product });
     }
     # It could have no components...
-    elsif (!@{$product->components}) {
+    elsif (!@{$product->components}
+           || !grep { $_->is_active } @{$product->components})
+    {
         ThrowUserError('missing_component', { product => $product });
     }
     # It could have no versions...
-    elsif (!@{$product->versions}) {
+    elsif (!@{$product->versions}
+           || !grep { $_->is_active } @{$product->versions})
+    {
         ThrowUserError ('missing_version', { product => $product });
     }
 
@@ -1024,28 +1028,29 @@ sub get_enterable_products {
     }
 
      # All products which the user has "Entry" access to.
-     my @enterable_ids =@{$dbh->selectcol_arrayref(
+     my $enterable_ids = $dbh->selectcol_arrayref(
            'SELECT products.id FROM products
          LEFT JOIN group_control_map
                    ON group_control_map.product_id = products.id
                       AND group_control_map.entry != 0
                       AND group_id NOT IN (' . $self->groups_as_string . ')
             WHERE group_id IS NULL
-                  AND products.isactive = 1') || []};
+                  AND products.isactive = 1');
 
-    if (@enterable_ids) {
+    if (scalar @$enterable_ids) {
         # And all of these products must have at least one component
         # and one version.
-        @enterable_ids = @{$dbh->selectcol_arrayref(
+        $enterable_ids = $dbh->selectcol_arrayref(
                'SELECT DISTINCT products.id FROM products
             INNER JOIN components ON components.product_id = products.id
             INNER JOIN versions ON versions.product_id = products.id
-                 WHERE products.id IN (' . (join(',', @enterable_ids)) .
-            ')') || []};
+                 WHERE products.id IN (' . join(',', @$enterable_ids) . ')
+                   AND components.isactive = 1
+                   AND versions.isactive = 1');
     }
 
     $self->{enterable_products} =
-         Bugzilla::Product->new_from_list(\@enterable_ids);
+         Bugzilla::Product->new_from_list($enterable_ids);
     return $self->{enterable_products};
 }
 
index 3e831c0c4ddae14bbe8a8e5d889785cd0ed4e0ae..52ac64ddde2a6a7b4dab73f4e9e1bd06d551958b 100644 (file)
     [% admindocslinks = {'products.html'   => 'Administering products',
                          'components.html' => 'Creating a component'} %]
     Sorry, the product <em>[% product.name FILTER html %]</em>
-    has to have at least one component in order for you to
+    has to have at least one active component in order for you to
     enter [% terms.abug %] into it.<br>
     [% IF user.in_group("editcomponents", product.id) %]
       <a href="editcomponents.cgi?action=add&amp;product=[% product.name FILTER uri %]">Create
     [% title = "Missing Version" %]
     [% admindocslinks = {'versions.html' => 'Defining versions'} %]
     Sorry, the product <em>[% product.name FILTER html %]</em>
-    has to have at least one version in order for you to
+    has to have at least one active version in order for you to
     enter [% terms.abug %] into it.<br>
     [% IF user.in_group("editcomponents", product.id) %]
       <a href="editversions.cgi?action=add&amp;product=[% product.name FILTER uri %]">Create