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__
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
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.)
$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) {
@legal_platform
@legal_opsys
@legal_resolution
-
- @legal_components
- @legal_target_milestone
);
# Use the global template variables defined in globals.pl
use Bugzilla::FlagType;
use Bugzilla::Group;
use Bugzilla::Util;
+use Bugzilla::Product;
my $template = Bugzilla->template;
my $vars = {};
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;
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";
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;
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.
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;
}
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 " .
}
my $ref = $::components{$p};
push @$ref, $c;
- $carray{$c} = 1;
}
SendSQL("SELECT products.name, classifications.name " .
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");
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']));
"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']));
}
$zz = @::legal_opsys;
$zz = @::legal_platform;
$zz = @::legal_priority;
- $zz = @::legal_product;
$zz = @::legal_severity;
$zz = %::target_milestone;
}
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);
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;
$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
$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.
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">