From f709156da6e562a4466d45c9422ff0a111aaa7e0 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Mon, 4 Jan 2016 23:47:11 +0100 Subject: Bug 1191706: When editing flag types, components do not match the selected product when classifications are enabled r=dkl --- editflagtypes.cgi | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'editflagtypes.cgi') diff --git a/editflagtypes.cgi b/editflagtypes.cgi index d848d250a..d0b9443b5 100755 --- a/editflagtypes.cgi +++ b/editflagtypes.cgi @@ -436,17 +436,30 @@ sub get_products_and_components { my @products; if ($user->in_group('editcomponents')) { - @products = Bugzilla::Product->get_all; + if (Bugzilla->params->{useclassification}) { + # We want products grouped by classifications. + @products = map { @{ $_->products } } Bugzilla::Classification->get_all; + } + else { + @products = Bugzilla::Product->get_all; + } } else { @products = @{$user->get_products_by_permission('editcomponents')}; + + if (Bugzilla->params->{useclassification}) { + my %class; + push(@{$class{$_->classification_id}}, $_) foreach @products; + + # Let's sort the list by classifications. + @products = (); + push(@products, @{$class{$_->id}}) foreach Bugzilla::Classification->get_all; + } } - # We require all unique component names. + my %components; foreach my $product (@products) { - foreach my $component (@{$product->components}) { - $components{$component->name} = 1; - } + $components{$_->name} = 1 foreach @{$product->components}; } $vars->{'products'} = \@products; $vars->{'components'} = [sort(keys %components)]; -- cgit v1.2.3-24-g4f1b