From 6b44875b901ac8d1d7383fed017c973a9f954051 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 3 Sep 2005 04:12:07 +0000 Subject: Bug 286158: Remove GetSelectableProducts() from globals.pl and use Bugzilla::User::get_selectable_products() instead - Patch by Frédéric Buclin r=joel,kiko a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- globals.pl | 107 ------------------------------------------------------------- 1 file changed, 107 deletions(-) (limited to 'globals.pl') diff --git a/globals.pl b/globals.pl index 7f3d9dd13..46ceebc74 100644 --- a/globals.pl +++ b/globals.pl @@ -518,113 +518,6 @@ sub GetEnterableProducts { return (@products); } - -# -# This function returns an alphabetical list of product names to which -# the user can enter bugs. If the $by_id parameter is true, also retrieves IDs -# and pushes them onto the list as id, name [, id, name...] for easy slurping -# into a hash by the calling code. -sub GetSelectableProducts { - my ($by_id,$by_classification) = @_; - - my $extra_sql = $by_id ? "id, " : ""; - - my $extra_from_sql = $by_classification ? " INNER JOIN classifications" - . " ON classifications.id = products.classification_id" : ""; - - my $query = "SELECT $extra_sql products.name " . - "FROM products $extra_from_sql " . - "LEFT JOIN group_control_map " . - "ON group_control_map.product_id = products.id "; - if (Param('useentrygroupdefault')) { - $query .= "AND group_control_map.entry != 0 "; - } else { - $query .= "AND group_control_map.membercontrol = " . - CONTROLMAPMANDATORY . " "; - } - if (%{Bugzilla->user->groups}) { - $query .= "AND group_id NOT IN(" . - join(',', values(%{Bugzilla->user->groups})) . ") "; - } - $query .= "WHERE group_id IS NULL "; - if ($by_classification) { - $query .= "AND classifications.name = "; - $query .= SqlQuote($by_classification) . " "; - } - $query .= "ORDER BY name"; - PushGlobalSQLState(); - SendSQL($query); - my @products = (); - push(@products, FetchSQLData()) while MoreSQLData(); - PopGlobalSQLState(); - return (@products); -} - -# GetSelectableProductHash -# returns a hash containing -# legal_products => an enterable product list -# legal_(components|versions|milestones) => -# the list of components, versions, and milestones of enterable products -# (components|versions|milestones)_by_product -# => a hash of component lists for each enterable product -# Milestones only get returned if the usetargetmilestones parameter is set. -sub GetSelectableProductHash { - # The hash of selectable products and their attributes that gets returned - # at the end of this function. - my $selectables = {}; - - my %products = GetSelectableProducts(1); - - $selectables->{legal_products} = [sort values %products]; - - # Run queries that retrieve the list of components, versions, - # and target milestones (if used) for the selectable products. - my @tables = qw(components versions); - push(@tables, 'milestones') if Param('usetargetmilestone'); - - PushGlobalSQLState(); - foreach my $table (@tables) { - my %values; - my %values_by_product; - - if (scalar(keys %products)) { - # Why oh why can't we standardize on these names?!? - my $fld = ($table eq "components" ? "name" : "value"); - - my $query = "SELECT $fld, product_id FROM $table WHERE product_id " . - "IN (" . join(",", keys %products) . ") ORDER BY $fld"; - SendSQL($query); - - while (MoreSQLData()) { - my ($name, $product_id) = FetchSQLData(); - next unless $name; - $values{$name} = 1; - push @{$values_by_product{$products{$product_id}}}, $name; - } - } - - $selectables->{"legal_$table"} = [sort keys %values]; - $selectables->{"${table}_by_product"} = \%values_by_product; - } - PopGlobalSQLState(); - - return $selectables; -} - -# -# This function returns an alphabetical list of classifications that has products the user can enter bugs. -sub GetSelectableClassifications { - my @selectable_classes = (); - - foreach my $c (sort keys %::classdesc) { - if ( scalar(GetSelectableProducts(0,$c)) > 0) { - push(@selectable_classes,$c); - } - } - return (@selectable_classes); -} - - sub ValidatePassword { # Determines whether or not a password is valid (i.e. meets Bugzilla's # requirements for length and content). -- cgit v1.2.3-24-g4f1b