summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-07-07 03:58:10 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2010-07-07 03:58:10 +0200
commit814b24fdc9407a741967322041ff817665f8e00b (patch)
tree8137af19b7fbb04b8966c959f56b78be98b4e404 /Bugzilla
parentef414f2b12f7686ad830fb884f69865cdb41f6c0 (diff)
downloadbugzilla-814b24fdc9407a741967322041ff817665f8e00b.tar.gz
bugzilla-814b24fdc9407a741967322041ff817665f8e00b.tar.xz
Bug 519835: Remove Bugzilla::Product::check_product() in favor of Bugzilla::Product->check()
r=mkanat a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm6
-rw-r--r--Bugzilla/Product.pm32
-rw-r--r--Bugzilla/User.pm2
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))