summaryrefslogtreecommitdiffstats
path: root/globals.pl
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-10-12 11:08:54 +0200
committerlpsolit%gmail.com <>2005-10-12 11:08:54 +0200
commit2ecd676f8e8154f6364a3a158013250695ed9251 (patch)
treea5444c151d610a2d8a4751b4ffde88739624a259 /globals.pl
parent6e549ec68c0893d8eba685a5d1a4eb151752a07d (diff)
downloadbugzilla-2ecd676f8e8154f6364a3a158013250695ed9251.tar.gz
bugzilla-2ecd676f8e8154f6364a3a158013250695ed9251.tar.xz
Bug 306325: Move CanEnterProduct() and CanEnterProductOrWarn() out of globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=joel r=wicked a=justdave
Diffstat (limited to 'globals.pl')
-rw-r--r--globals.pl92
1 files changed, 0 insertions, 92 deletions
diff --git a/globals.pl b/globals.pl
index 4d21b088b..07d12a984 100644
--- a/globals.pl
+++ b/globals.pl
@@ -411,98 +411,6 @@ sub IsInClassification {
}
}
-# This function determines whether or not a user can enter
-# bugs into the named product.
-sub CanEnterProduct {
- my ($productname, $verbose) = @_;
- my $dbh = Bugzilla->dbh;
-
- return unless defined($productname);
- trick_taint($productname);
-
- # First check whether or not the user has access to that product.
- my $query = "SELECT group_id IS NULL " .
- "FROM products " .
- "LEFT JOIN group_control_map " .
- "ON group_control_map.product_id = products.id " .
- "AND group_control_map.entry != 0 ";
- if (%{Bugzilla->user->groups}) {
- $query .= "AND group_id NOT IN(" .
- join(',', values(%{Bugzilla->user->groups})) . ") ";
- }
- $query .= "WHERE products.name = ? " .
- $dbh->sql_limit(1);
-
- my $has_access = $dbh->selectrow_array($query, undef, $productname);
- if (!$has_access) {
- # Do we require the exact reason why we cannot enter
- # bugs into that product? Returning -1 explicitely
- # means the user has no access to the product or the
- # product does not exist.
- return (defined($verbose)) ? -1 : 0;
- }
-
- # Check if the product is open for new bugs and has
- # at least one component and has at least one version.
- my ($allow_new_bugs, $has_version) =
- $dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END, ' .
- 'versions.value IS NOT NULL ' .
- 'FROM products INNER JOIN components ' .
- 'ON components.product_id = products.id ' .
- 'LEFT JOIN versions ' .
- 'ON versions.product_id = products.id ' .
- 'WHERE products.name = ? ' .
- $dbh->sql_limit(1), undef, $productname);
-
-
- if (defined $verbose) {
- # Return (undef, undef) if the product has no components,
- # Return (?, 0) if the product has no versions,
- # Return (0, ?) if the product is closed for new bug entry,
- # Return (1, 1) if the user can enter bugs into the product,
- return ($allow_new_bugs, $has_version);
- } else {
- # Return undef if the product has no components
- # Return 0 if the product has no versions, or is closed for bug entry
- # Return 1 if the user can enter bugs into the product
- return ($allow_new_bugs && $has_version);
- }
-}
-
-# Call CanEnterProduct() and display an error message
-# if the user cannot enter bugs into that product.
-sub CanEnterProductOrWarn {
- my ($product) = @_;
-
- if (!defined($product)) {
- ThrowUserError("no_products");
- }
- my ($allow_new_bugs, $has_version) = CanEnterProduct($product, 1);
- trick_taint($product);
-
- if (!defined $allow_new_bugs) {
- ThrowUserError("missing_component", { product => $product });
- } elsif (!$allow_new_bugs) {
- ThrowUserError("product_disabled", { product => $product});
- } elsif ($allow_new_bugs < 0) {
- ThrowUserError("entry_access_denied", { product => $product});
- } elsif (!$has_version) {
- ThrowUserError("missing_version", { product => $product });
- }
- return 1;
-}
-
-sub GetEnterableProducts {
- my @products;
- # XXX rewrite into pure SQL instead of relying on legal_products?
- foreach my $p (@::legal_product) {
- if (CanEnterProduct($p)) {
- push @products, $p;
- }
- }
- return (@products);
-}
-
sub ValidatePassword {
# Determines whether or not a password is valid (i.e. meets Bugzilla's
# requirements for length and content).