diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Bug.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Product.pm | 32 | ||||
-rw-r--r-- | Bugzilla/User.pm | 2 |
3 files changed, 10 insertions, 30 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 7d86fe328..ed302a053 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1649,10 +1649,8 @@ sub _check_product { } # Check that the product exists and that the user # is allowed to enter bugs into this product. - Bugzilla->user->can_enter_product($name, THROW_ERROR); - # can_enter_product already does everything that check_product - # would do for us, so we don't need to use it. - return new Bugzilla::Product({ name => $name }); + my $product = Bugzilla->user->can_enter_product($name, THROW_ERROR); + return $product; } sub _check_priority { diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm index 80e1752e6..e61b3b577 100644 --- a/Bugzilla/Product.pm +++ b/Bugzilla/Product.pm @@ -812,26 +812,17 @@ sub classification_id { return $_[0]->{'classification_id'}; } #### Subroutines ###### ############################### -sub check_product { - my ($product_name) = @_; - - unless ($product_name) { - ThrowUserError('product_not_specified'); - } - my $product = new Bugzilla::Product({name => $product_name}); - unless ($product) { - ThrowUserError('product_doesnt_exist', - {'product' => $product_name}); - } - return $product; -} - sub check { my ($class, $params) = @_; $params = { name => $params } if !ref $params; - $params->{_error} = 'product_access_denied'; + if (!$params->{allow_inaccessible}) { + $params->{_error} = 'product_access_denied'; + } my $product = $class->SUPER::check($params); - if (!Bugzilla->user->can_access_product($product)) { + + if (!$params->{allow_inaccessible} + && !Bugzilla->user->can_access_product($product)) + { ThrowUserError('product_access_denied', $params); } return $product; @@ -1052,15 +1043,6 @@ than calling those accessors on every item in the array individually. This function is not exported, so must be called like C<Bugzilla::Product::preload($products)>. -=item C<check_product($product_name)> - - Description: Checks if the product name was passed in and if is a valid - product. - - Params: $product_name - String with a product name. - - Returns: Bugzilla::Product object. - =back =head1 SEE ALSO diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index b9405e412..78e92eca0 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -985,7 +985,7 @@ sub check_can_admin_product { my ($self, $product_name) = @_; # First make sure the product name is valid. - my $product = Bugzilla::Product::check_product($product_name); + my $product = Bugzilla::Product->check($product_name); ($self->in_group('editcomponents', $product->id) && $self->can_see_product($product->name)) |