summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-09-24 05:55:03 +0200
committerByron Jones <glob@mozilla.com>2014-09-24 05:55:03 +0200
commit550d53cc7bc2ed66fd40ab6a276d9f65c6ac7278 (patch)
treeae891d282273c5fdc1ba6e3ba10aedd703990c86 /extensions
parent84c12dd98e2a4d60fbaab685831e7bc48e83b082 (diff)
downloadbugzilla-550d53cc7bc2ed66fd40ab6a276d9f65c6ac7278.tar.gz
bugzilla-550d53cc7bc2ed66fd40ab6a276d9f65c6ac7278.tar.xz
Bug 1054141: add the ability to filter on the user that made the change
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BugmailFilter/Extension.pm15
-rw-r--r--extensions/BugmailFilter/lib/Filter.pm16
-rw-r--r--extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl70
3 files changed, 99 insertions, 2 deletions
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
@@ -109,6 +109,20 @@ var cpts = new Array();
</td>
</tr>
<tr>
+ <th>Changer:</th>
+ <td>
+ [% INCLUDE global/userselect.html.tmpl
+ id => "changer"
+ name => "changer"
+ size => 32
+ emptyok => 1
+ %]
+ </td>
+ <td class="blurb">
+ the person who made the change (leave empty for "anyone")
+ </td>
+</tr>
+<tr>
<th>Action:</th>
<td>
<select name="action" id="action">
@@ -141,6 +155,7 @@ var cpts = new Array();
<th>Component</th>
<th>Field</th>
<th>Relationship</th>
+ <th>Changer</th>
<th>Action</th>
</tr>
[% FOREACH filter = filters %]
@@ -153,6 +168,15 @@ var cpts = new Array();
<td>[% filter.component ? filter.component.name : 'Any' FILTER html %]</td>
<td>[% filter.field_description FILTER html %]</td>
<td>[% filter.relationship ? filter.relationship_name : 'Any' FILTER html %]</td>
+ <td>
+ [% IF filter.changer %]
+ <span title="[% filter.changer.name FILTER html %]">
+ [% filter.changer.login FILTER html %]
+ </span>
+ [% ELSE %]
+ Anyone
+ [% END %]
+ </td>
<td>[% filter.action ? 'Exclude' : 'Include' %]</td>
</tr>
[% END %]
@@ -235,6 +259,40 @@ var cpts = new Array();
<td>Not Assignee</td>
</tr>
<tr>
+ <th>Changer:</th>
+ <td>(empty)</td>
+ </tr>
+ <tr>
+ <th>Action:</th>
+ <td>Exclude</td>
+ </tr>
+</table>
+
+<p>
+ To never receive email for any change made by webops-kanban@mozilla.bugs:
+</p>
+<table class="example_filter_table">
+ <tr>
+ <th>Field:</th>
+ <td>__Any__</td>
+ </tr>
+ <tr>
+ <th>Product:</th>
+ <td>__Any__</td>
+ </tr>
+ <tr>
+ <th>Component:</th>
+ <td>__Any__</td>
+ </tr>
+ <tr>
+ <th>Relationship:</th>
+ <td>__Any__</td>
+ </tr>
+ <tr>
+ <th>Changer:</th>
+ <td>webops-kanban@mozilla.bugs</td>
+ </tr>
+ <tr>
<th>Action:</th>
<td>Exclude</td>
</tr>
@@ -264,6 +322,10 @@ var cpts = new Array();
<td>__Any__</td>
</tr>
<tr>
+ <th>Changer:</th>
+ <td>(empty)</td>
+ </tr>
+ <tr>
<th>Action:</th>
<td>Exclude</td>
</tr>
@@ -290,6 +352,10 @@ var cpts = new Array();
<td>__Any__</td>
</tr>
<tr>
+ <th>Changer:</th>
+ <td>(empty)</td>
+ </tr>
+ <tr>
<th>Action:</th>
<td>Include</td>
</tr>
@@ -316,6 +382,10 @@ var cpts = new Array();
<td>__Any__</td>
</tr>
<tr>
+ <th>Changer:</th>
+ <td>(empty)</td>
+ </tr>
+ <tr>
<th>Action:</th>
<td>Include</td>
</tr>