summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Product.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-07-21 17:33:57 +0200
committermkanat%bugzilla.org <>2006-07-21 17:33:57 +0200
commite59b6279ae870f361726542ebb9180363965b71a (patch)
tree3bb345c4e3f0aa3523f1a0fa3c36b76164c8b007 /Bugzilla/Product.pm
parent0465112ab3b73b9c37b0bd54a363928b77985bda (diff)
downloadbugzilla-e59b6279ae870f361726542ebb9180363965b71a.tar.gz
bugzilla-e59b6279ae870f361726542ebb9180363965b71a.tar.xz
Bug 322848: Extremely slow performance with a lot of products (~1800) and security groups for each
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=myk
Diffstat (limited to 'Bugzilla/Product.pm')
-rw-r--r--Bugzilla/Product.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm
index 53dd0140e..995369130 100644
--- a/Bugzilla/Product.pm
+++ b/Bugzilla/Product.pm
@@ -164,6 +164,19 @@ sub bug_ids {
return $self->{'bug_ids'};
}
+sub user_has_access {
+ my ($self, $user) = @_;
+
+ return Bugzilla->dbh->selectrow_array(
+ 'SELECT CASE WHEN group_id IS NULL THEN 1 ELSE 0 END
+ 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 (' . $user->groups_as_string . ')
+ WHERE products.id = ? ' . Bugzilla->dbh->sql_limit(1),
+ undef, $self->id);
+}
+
###############################
#### Accessors ######
@@ -217,6 +230,7 @@ Bugzilla::Product - Bugzilla product class.
my @versions = $product->versions();
my $bugcount = $product->bug_count();
my $bug_ids = $product->bug_ids();
+ my $has_access = $product->user_has_access($user);
my $id = $product->id;
my $name = $product->name;
@@ -294,6 +308,18 @@ below.
Returns: An array of integer.
+=item C<user_has_access()>
+
+ Description: Tells you whether or not the user is allowed to enter
+ bugs into this product, based on the C<entry> group
+ control. To see whether or not a user can actually
+ enter a bug into a product, use C<$user-&gt;can_enter_product>.
+
+ Params: C<$user> - A Bugzilla::User object.
+
+ Returns C<1> If this user's groups allow him C<entry> access to
+ this Product, C<0> otherwise.
+
=back
=head1 SUBROUTINES