]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 330521: Remove @::legal_product, @::legal_components and @::legal_target_mileston...
authorlpsolit%gmail.com <>
Thu, 16 Mar 2006 05:51:34 +0000 (05:51 +0000)
committerlpsolit%gmail.com <>
Thu, 16 Mar 2006 05:51:34 +0000 (05:51 +0000)
Bugzilla/Version.pm
collectstats.pl
config.cgi
editflagtypes.cgi
globals.pl
post_bug.cgi
query.cgi
template/en/default/admin/flag-type/edit.html.tmpl

index 53bf9a6786666c3e5711327bf38f24abc34421a4..9492e8135b616b6513c1d980b5bf220467e68602 100644 (file)
@@ -109,13 +109,6 @@ sub check_version {
     return $version;
 }
 
-sub distinct_names {
-    my $dbh = Bugzilla->dbh;
-    my $names = $dbh->selectcol_arrayref(
-        'SELECT DISTINCT value FROM versions ORDER BY value');
-    return @$names;
-}
-
 1;
 
 __END__
@@ -179,17 +172,6 @@ Version.pm represents a Product Version object.
 
  Returns:     Bugzilla::Version object.
 
-=item C<distinct_names()>
-
- Description: A utility function for getting all the
-              possible version values from the database,
-              regardless of what product they're in.
-              Returns a list with no duplicate versions.
-
- Params:      none
-
- Returns:     A list of strings (versions).
-
 =back
 
 =cut
index 2d7d3d25846b9c7345e8316b6878a228349a11f6..f6bfbdae115a3ea628a8570e66c1bf0857565073 100755 (executable)
 use AnyDBM_File;
 use strict;
 use IO::Handle;
-use vars @::legal_product;
 
 use lib ".";
 require "globals.pl";
-use Bugzilla::Search;
-use Bugzilla::User;
-
 use Bugzilla;
 use Bugzilla::Config qw(:DEFAULT $datadir);
+use Bugzilla::Search;
+use Bugzilla::User;
+use Bugzilla::Product;
 
 # Turn off output buffering (probably needed when displaying output feedback
 # in the regenerate mode.)
@@ -64,8 +63,8 @@ if ($#ARGV >= 0 && $ARGV[0] eq "--regenerate") {
     $regenerate = 1;
 }
 
-my @myproducts;
-push( @myproducts, "-All-", @::legal_product );
+my @myproducts = map {$_->name} Bugzilla::Product::get_all_products();
+unshift(@myproducts, "-All-");
 
 my $tstart = time;
 foreach (@myproducts) {
index f3471e14f514492f55c137db15ed8822d6dbc951..fe1c5936b01bf5f001ba1a0055bc67fff13368c9 100755 (executable)
@@ -44,9 +44,6 @@ use vars
     @legal_platform 
     @legal_opsys 
     @legal_resolution 
-
-    @legal_components 
-    @legal_target_milestone 
   );
 
 # Use the global template variables defined in globals.pl 
index 1851e8b135f23033f754b73036d0db18e1451286..29a7467aded6b06b067c6469717dfa30fa65417a 100755 (executable)
@@ -38,6 +38,7 @@ use Bugzilla::Flag;
 use Bugzilla::FlagType;
 use Bugzilla::Group;
 use Bugzilla::Util;
+use Bugzilla::Product;
 
 my $template = Bugzilla->template;
 my $vars = {};
@@ -49,9 +50,6 @@ $user->in_group('editcomponents')
                                      action => "edit",
                                      object => "flagtypes"});
 
-# Suppress "used only once" warnings.
-use vars qw(@legal_product @legal_components %components);
-
 my $cgi = Bugzilla->cgi;
 my $product_id;
 my $component_id;
@@ -128,17 +126,18 @@ sub list {
 sub edit {
     $action eq 'enter' ? validateTargetType() : (my $id = validateID());
     my $dbh = Bugzilla->dbh;
-    
-    # Get this installation's products and components.
-    GetVersionTable();
-
-    # products and components and the function used to modify the components
-    # menu when the products menu changes; used by the template to populate
-    # the menus and keep the components menu consistent with the products menu
-    $vars->{'products'} = \@::legal_product;
-    $vars->{'components'} = \@::legal_components;
-    $vars->{'components_by_product'} = \%::components;
-    
+
+    my @products = Bugzilla::Product::get_all_products();
+    # We require all unique component names.
+    my %components;
+    foreach my $product (@products) {
+        foreach my $component (@{$product->components}) {
+            $components{$component->name} = 1;
+        }
+    }
+    $vars->{'products'} = \@products;
+    $vars->{'components'} = [sort(keys %components)];
+
     $vars->{'last_action'} = $cgi->param('action');
     if ($cgi->param('action') eq 'enter' || $cgi->param('action') eq 'copy') {
         $vars->{'action'} = "insert";
@@ -216,17 +215,21 @@ sub processCategoryChange {
     my %inclusions = clusion_array_to_hash(\@inclusions);
     my %exclusions = clusion_array_to_hash(\@exclusions);
 
-    # Get this installation's products and components.
-    GetVersionTable();
+    my @products = Bugzilla::Product::get_all_products();
+    # We require all unique component names.
+    my %components;
+    foreach my $product (@products) {
+        foreach my $component (@{$product->components}) {
+            $components{$component->name} = 1;
+        }
+    }
+    $vars->{'products'} = \@products;
+    $vars->{'components'} = [sort(keys %components)];
 
-    # products and components; used by the template to populate the menus 
-    # and keep the components menu consistent with the products menu
-    $vars->{'products'} = \@::legal_product;
-    $vars->{'components'} = \@::legal_components;
-    $vars->{'components_by_product'} = \%::components;
     my @groups = Bugzilla::Group::get_all_groups();
     $vars->{'groups'} = \@groups;
     $vars->{'action'} = $cgi->param('action');
+
     my $type = {};
     foreach my $key ($cgi->param()) { $type->{$key} = $cgi->param($key) }
     $type->{'inclusions'} = \%inclusions;
index 018260959ea6143863326ee648cbbddb65ad4aba..8ac08846a4fe7dc4d8fa10d8c512f51bc8a7d385 100644 (file)
@@ -38,6 +38,7 @@ use Bugzilla::Util;
 use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
 use Bugzilla::User;
 use Bugzilla::Error;
+use Bugzilla::Product;
 
 # Shut up misguided -w warnings about "used only once".  For some reason,
 # "use vars" chokes on me when I try it here.
@@ -46,13 +47,10 @@ sub globals_pl_sillyness {
     my $zz;
     $zz = @main::enterable_products;
     $zz = @main::legal_bug_status;
-    $zz = @main::legal_components;
     $zz = @main::legal_opsys;
     $zz = @main::legal_platform;
     $zz = @main::legal_priority;
-    $zz = @main::legal_product;
     $zz = @main::legal_severity;
-    $zz = @main::legal_target_milestone;
     $zz = @main::milestoneurl;
     $zz = @main::prodmaxvotes;
 }
@@ -104,7 +102,7 @@ $::SIG{PIPE} = 'IGNORE';
 sub GenerateVersionTable {
     my $dbh = Bugzilla->dbh;
 
-    my (@line, %carray);
+    my @line;
     SendSQL("SELECT components.name, products.name " .
             "FROM components, products " .
             "WHERE products.id = components.product_id " .
@@ -116,7 +114,6 @@ sub GenerateVersionTable {
         }
         my $ref = $::components{$p};
         push @$ref, $c;
-        $carray{$c} = 1;
     }
 
     SendSQL("SELECT products.name, classifications.name " .
@@ -185,8 +182,6 @@ sub GenerateVersionTable {
         splice(@::settable_resolution, $z, 1);
     }
 
-    @::legal_product = map($_->name, Bugzilla::Product::get_all_products());
-
     require File::Temp;
     my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
                                               DIR => "$datadir");
@@ -202,21 +197,19 @@ sub GenerateVersionTable {
     print $fh (Data::Dumper->Dump([\@::log_columns],
                                   ['*::log_columns']));
 
-    foreach my $i (@::legal_product) {
+    my @legal_products = map($_->name, Bugzilla::Product::get_all_products());
+    foreach my $i (@legal_products) {
         if (!defined $::components{$i}) {
             $::components{$i} = [];
         }
     }
     print $fh (Data::Dumper->Dump([\%::components],
                                   ['*::components']));
-    @::legal_components = sort {uc($a) cmp uc($b)} keys(%carray);
 
-    print $fh (Data::Dumper->Dump([\@::legal_components, \@::legal_product,
-                                   \@::legal_priority, \@::legal_severity,
+    print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity,
                                    \@::legal_platform, \@::legal_opsys,
                                    \@::legal_bug_status, \@::legal_resolution],
-                                  ['*::legal_components', '*::legal_product',
-                                   '*::legal_priority', '*::legal_severity',
+                                  ['*::legal_priority', '*::legal_severity',
                                    '*::legal_platform', '*::legal_opsys',
                                    '*::legal_bug_status', '*::legal_resolution']));
 
@@ -234,25 +227,17 @@ sub GenerateVersionTable {
                 "WHERE products.id = milestones.product_id " .
                 "ORDER BY milestones.sortkey, milestones.value");
         my @line;
-        my %tmarray;
-        @::legal_target_milestone = ();
         while(@line = FetchSQLData()) {
             my ($tm, $pr) = (@line);
             if (!defined $::target_milestone{$pr}) {
                 $::target_milestone{$pr} = [];
             }
             push @{$::target_milestone{$pr}}, $tm;
-            if (!exists $tmarray{$tm}) {
-                $tmarray{$tm} = 1;
-                push(@::legal_target_milestone, $tm);
-            }
         }
 
         print $fh (Data::Dumper->Dump([\%::target_milestone,
-                                       \@::legal_target_milestone,
                                        \%::milestoneurl],
                                       ['*::target_milestone',
-                                       '*::legal_target_milestone',
                                        '*::milestoneurl']));
     }
 
index de806354326b1cffe072f2ab5389288c6636e6b4..dd699e66885fd2cf96630e6d62ce5d75a31733df 100755 (executable)
@@ -44,7 +44,6 @@ sub sillyness {
     $zz = @::legal_opsys;
     $zz = @::legal_platform;
     $zz = @::legal_priority;
-    $zz = @::legal_product;
     $zz = @::legal_severity;
     $zz = %::target_milestone;
 }
@@ -219,7 +218,8 @@ if (!Param('letsubmitterchoosepriority')) {
 GetVersionTable();
 
 # Some more sanity checking
-check_field('product',      scalar $cgi->param('product'),      \@::legal_product);
+check_field('product',      scalar $cgi->param('product'),
+            [map($_->name, Bugzilla::Product::get_all_products())]);
 check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform);
 check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity);
 check_field('priority',     scalar $cgi->param('priority'),     \@::legal_priority);
index 9bb90e7828cf29418a8fe42af27568f0cdee507c..bda05d7aa01794325761e831dc6388b09e7ba6a0 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -35,21 +35,16 @@ use Bugzilla::Search;
 use Bugzilla::User;
 use Bugzilla::Util;
 use Bugzilla::Product;
-use Bugzilla::Version;
 use Bugzilla::Keyword;
 
 use vars qw(
     @legal_resolution
     @legal_bug_status
-    @legal_components
     @legal_opsys
     @legal_platform
     @legal_priority
-    @legal_product
     @legal_severity
-    @legal_target_milestone
     @log_columns
-    %components
 );
 
 my $cgi = Bugzilla->cgi;
@@ -215,50 +210,26 @@ if ($default{'chfieldto'}->[0] eq "") {
     $default{'chfieldto'} = ["Now"];
 }
 
-GetVersionTable();
-
 # if using groups for entry, then we don't want people to see products they 
 # don't have access to. Remove them from the list.
-
 my @selectable_products = sort {lc($a->name) cmp lc($b->name)} 
                                @{$user->get_selectable_products};
 
-my %component_set;
-my %version_set;
-my %milestone_set;
-
-foreach my $prod_obj (@selectable_products) {
-    # We build up boolean hashes in the "-set" hashes for each of these things 
-    # before making a list because there may be duplicates names across products.
-    my @component_names = map($_->name, @{$prod_obj->components});
-    my @version_names   = map($_->name, @{$prod_obj->versions});
-    my @milestone_names = map($_->name, @{$prod_obj->milestones});
-    $component_set{$_} = 1 foreach (@component_names);
-    $version_set{$_}   = 1 foreach (@version_names);
-    $milestone_set{$_} = 1 foreach (@milestone_names);
-}
-
 # Create the component, version and milestone lists.
-my @components = ();
-my @versions = ();
-my @milestones = ();
-foreach my $c (@::legal_components) {
-    if ($component_set{$c}) {
-        push @components, $c;
-    }
-}
-my @all_versions = Bugzilla::Version::distinct_names();
-foreach my $v (@all_versions) {
-    if ($version_set{$v}) {
-        push @versions, $v;
-    }
-}
-foreach my $m (@::legal_target_milestone) {
-    if ($milestone_set{$m}) {
-        push @milestones, $m;
-    }
+my %components;
+my %versions;
+my %milestones;
+
+foreach my $product (@selectable_products) {
+    $components{$_->name} = 1 foreach (@{$product->components});
+    $versions{$_->name}   = 1 foreach (@{$product->versions});
+    $milestones{$_->name} = 1 foreach (@{$product->milestones});
 }
 
+my @components = sort(keys %components);
+my @versions = sort(keys %versions);
+my @milestones = sort(keys %milestones);
+
 $vars->{'product'} = \@selectable_products;
 
 # Create data structures representing each classification
@@ -277,6 +248,8 @@ if (Param('usetargetmilestone')) {
 
 $vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count();
 
+GetVersionTable();
+
 push @::legal_resolution, "---"; # Oy, what a hack.
 shift @::legal_resolution; 
       # Another hack - this array contains "" for some reason. See bug 106589.
index dc49890b77cbf8dc0c689fd2eca74d3c33666e54..cb3ce9e172042991b0dfa6035206d674dbf9182f 100644 (file)
@@ -28,9 +28,9 @@
   var first_load = 1; // is this the first time we load the page?
   var last_sel = []; // caches last selection
   var cpts = new Array();
-  [% FOREACH p = products %]
-    cpts['[% p FILTER js %]'] = [
-      [%- FOREACH item = components_by_product.$p %]'[% item FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
+  [% FOREACH prod = products %]
+    cpts['[% prod.name FILTER js %]'] = [
+      [%- FOREACH comp = prod.components %]'[% comp.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
   [% END %]
 [% END %]
 
               <b>Product/Component:</b><br>
               <select name="product" onchange="selectProduct(this.form, 'product', 'component', '__Any__');">
                 <option value="">__Any__</option>
-                [% FOREACH item = products %]
-                  <option value="[% item FILTER html %]" 
-                          [% "selected" IF type.product.name == item %]>
-                          [% item FILTER html %]</option>
+                [% FOREACH prod = products %]
+                  <option value="[% prod.name FILTER html %]" 
+                          [% "selected" IF type.product.name == prod.name %]>
+                          [% prod.name FILTER html %]</option>
                 [% END %]
               </select><br>
               <select name="component">
                 <option value="">__Any__</option>
-                [% FOREACH item = components %]
-                  <option value="[% item FILTER html %]" 
-                          [% "selected" IF type.component.name == item %]>
-                          [% item FILTER html %]</option>
+                [% FOREACH comp = components %]
+                  <option value="[% comp FILTER html %]" 
+                          [% "selected" IF type.component.name == comp %]>
+                          [% comp FILTER html %]</option>
                 [% END %]
               </select><br>
               <input type="submit" name="categoryAction-include" value="Include">