diff options
-rw-r--r-- | Bugzilla/Attachment.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Bug.pm | 5 | ||||
-rw-r--r-- | Bugzilla/FlagType.pm | 7 | ||||
-rw-r--r-- | extensions/FlagTypeComment/Extension.pm | 2 | ||||
-rw-r--r-- | template/en/default/bug/edit.html.tmpl | 2 |
5 files changed, 12 insertions, 7 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 2a89678c5..5ac71412c 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -504,7 +504,8 @@ sub flag_types { my $vars = { target_type => 'attachment', product_id => $self->bug->product_id, component_id => $self->bug->component_id, - attach_id => $self->id }; + attach_id => $self->id, + active_or_has_flags => $self->bug_id }; $self->{flag_types} = Bugzilla::Flag->_flag_types($vars); return $self->{flag_types}; diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 131ece6ff..6b51129af 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -3290,8 +3290,7 @@ sub duplicate_ids { } sub flag_types { - my ($self, $params) = @_; - $params ||= {}; + my ($self) = @_; return $self->{'flag_types'} if exists $self->{'flag_types'}; return [] if $self->{'error'}; @@ -3299,7 +3298,7 @@ sub flag_types { product_id => $self->{product_id}, component_id => $self->{component_id}, bug_id => $self->bug_id, - %$params }; + active_or_has_flags => $self->bug_id }; $self->{'flag_types'} = Bugzilla::Flag->_flag_types($vars); return $self->{'flag_types'}; diff --git a/Bugzilla/FlagType.pm b/Bugzilla/FlagType.pm index ea81dfe46..b17e2771e 100644 --- a/Bugzilla/FlagType.pm +++ b/Bugzilla/FlagType.pm @@ -601,7 +601,7 @@ sub match { $tables = join(' ', @$tables); $criteria = join(' AND ', @criteria); - my $flagtype_ids = $dbh->selectcol_arrayref("SELECT id FROM $tables WHERE $criteria"); + my $flagtype_ids = $dbh->selectcol_arrayref("SELECT flagtypes.id FROM $tables WHERE $criteria"); return Bugzilla::FlagType->new_from_list($flagtype_ids); } @@ -679,6 +679,11 @@ sub sqlify_criteria { my $is_active = $criteria->{is_active} ? "1" : "0"; push(@criteria, "flagtypes.is_active = $is_active"); } + if (exists($criteria->{active_or_has_flags}) && $criteria->{active_or_has_flags} =~ /^\d+$/) { + push(@$tables, "LEFT JOIN flags AS f ON flagtypes.id = f.type_id " . + "AND f.bug_id = " . $criteria->{active_or_has_flags}); + push(@criteria, "(flagtypes.is_active = 1 OR f.id IS NOT NULL)"); + } if ($criteria->{product_id}) { my $product_id = $criteria->{product_id}; diff --git a/extensions/FlagTypeComment/Extension.pm b/extensions/FlagTypeComment/Extension.pm index 4b5ef5510..caa41adf0 100644 --- a/extensions/FlagTypeComment/Extension.pm +++ b/extensions/FlagTypeComment/Extension.pm @@ -119,7 +119,7 @@ sub _set_ftc_states { 'product_id' => $bug->product_id, 'component_id' => $bug->component_id, 'bug_id' => $bug->id, - 'is_active' => 1, + 'active_or_has_bugs' => $bug->id, }); my $types = join(',', map { $_->id } @$flag_types); diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl index a55be45fe..7c6f5e462 100644 --- a/template/en/default/bug/edit.html.tmpl +++ b/template/en/default/bug/edit.html.tmpl @@ -870,7 +870,7 @@ [% show_bug_flags = 0 %] [% bug_flags_set = 0 %] [% show_more_flags = 0 %] - [% FOREACH type = bug.flag_types(is_active=>1) %] + [% FOREACH type = bug.flag_types %] [% IF (type.flags && type.flags.size > 0) || (user.id && type.is_active) %] [% show_bug_flags = 1 %] [% END %] |