From 550d53cc7bc2ed66fd40ab6a276d9f65c6ac7278 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 24 Sep 2014 11:55:03 +0800 Subject: Bug 1054141: add the ability to filter on the user that made the change --- extensions/BugmailFilter/Extension.pm | 15 ++++- extensions/BugmailFilter/lib/Filter.pm | 16 +++++ .../default/account/prefs/bugmail_filter.html.tmpl | 70 ++++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) (limited to 'extensions/BugmailFilter') diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm index f645d03ac..ebfc1f851 100644 --- a/extensions/BugmailFilter/Extension.pm +++ b/extensions/BugmailFilter/Extension.pm @@ -49,6 +49,16 @@ sub user_preferences { $params->{field_name} = '~' . $input->{field_contains}; } $params->{relationship} = $input->{relationship} || IS_NULL; + if ($input->{changer}) { + Bugzilla::User::match_field({ changer => { type => 'single'} }); + $params->{changer_id} = Bugzilla::User->check({ + name => $input->{changer}, + cache => 1, + })->id; + } + else { + $params->{changer_id} = IS_NULL; + } if (my $product_name = $input->{product}) { my $product = Bugzilla::Product->check({ name => $product_name, cache => 1 @@ -57,7 +67,7 @@ sub user_preferences { if (my $component_name = $input->{component}) { $params->{component_id} = Bugzilla::Component->check({ - name => $component_name, product => $product, + name => $component_name, product => $product, cache => 1 })->id; } @@ -268,7 +278,7 @@ sub _should_drop { # calculate relationships - my ($user, $bug, $relationship) = @$args{qw( user bug relationship )}; + my ($user, $bug, $relationship, $changer) = @$args{qw( user bug relationship changer )}; my ($user_id, $login) = ($user->id, $user->login); my $bit_direct = Bugzilla::BugMail::BIT_DIRECT; my $bit_watching = Bugzilla::BugMail::BIT_WATCHING; @@ -306,6 +316,7 @@ sub _should_drop { product_id => $bug->product_id, component_id => $bug->component_id, rel_map => \@rel_map, + changer_id => $changer->id, }; foreach my $field (@$fields) { diff --git a/extensions/BugmailFilter/lib/Filter.pm b/extensions/BugmailFilter/lib/Filter.pm index a6e8af459..6246f51d9 100644 --- a/extensions/BugmailFilter/lib/Filter.pm +++ b/extensions/BugmailFilter/lib/Filter.pm @@ -30,6 +30,7 @@ use constant DB_COLUMNS => qw( component_id field_name relationship + changer_id action ); @@ -117,6 +118,17 @@ sub relationship { return $_[0]->{relationship}; } +sub changer_id { + return $_[0]->{changer_id}; +} + +sub changer { + my ($self) = @_; + return $self->{changer_id} + ? Bugzilla::User->new({ id => $self->{changer_id}, cache => 1 }) + : undef; +} + sub relationship_name { my ($self) = @_; foreach my $rel (@{ FILTER_RELATIONSHIPS() }) { @@ -190,6 +202,10 @@ sub matches { return 0; } + if ($self->{changer_id} && $self->{changer_id} != $args->{changer_id}) { + return 0; + } + return 1; } diff --git a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl index 43d18f516..e7e0ed749 100644 --- a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl +++ b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl @@ -108,6 +108,20 @@ var cpts = new Array(); your relationship with the [% terms.bug %] + + Changer: + + [% INCLUDE global/userselect.html.tmpl + id => "changer" + name => "changer" + size => 32 + emptyok => 1 + %] + + + the person who made the change (leave empty for "anyone") + + Action: @@ -141,6 +155,7 @@ var cpts = new Array(); Component Field Relationship + Changer Action [% FOREACH filter = filters %] @@ -153,6 +168,15 @@ var cpts = new Array(); [% filter.component ? filter.component.name : 'Any' FILTER html %] [% filter.field_description FILTER html %] [% filter.relationship ? filter.relationship_name : 'Any' FILTER html %] + + [% IF filter.changer %] + + [% filter.changer.login FILTER html %] + + [% ELSE %] + Anyone + [% END %] + [% filter.action ? 'Exclude' : 'Include' %] [% END %] @@ -234,6 +258,40 @@ var cpts = new Array(); Relationship: Not Assignee + + Changer: + (empty) + + + Action: + Exclude + + + +

+ To never receive email for any change made by webops-kanban@mozilla.bugs: +

+ + + + + + + + + + + + + + + + + + + + + @@ -263,6 +321,10 @@ var cpts = new Array(); + + + + @@ -289,6 +351,10 @@ var cpts = new Array(); + + + + @@ -315,6 +381,10 @@ var cpts = new Array(); + + + + -- cgit v1.2.3-24-g4f1b
Field:__Any__
Product:__Any__
Component:__Any__
Relationship:__Any__
Changer:webops-kanban@mozilla.bugs
Action: ExcludeRelationship: __Any__
Changer:(empty)
Action: ExcludeRelationship: __Any__
Changer:(empty)
Action: IncludeRelationship: __Any__
Changer:(empty)
Action: Include