Skip to content

Instantly share code, notes, and snippets.

@keto
Last active June 14, 2019 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keto/bbb09ea3e876f7272c44a9ce7e229d79 to your computer and use it in GitHub Desktop.
Save keto/bbb09ea3e876f7272c44a9ce7e229d79 to your computer and use it in GitHub Desktop.
Bugzilla 5.0 suppress mail patch
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 110a1ffaf..ab4c61e41 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -264,8 +264,14 @@ sub Send {
$dep_ok = $user->can_see_bug($params->{blocker}->id) ? 1 : 0;
}
+ # suppress mail
+ my $suppress_group = Bugzilla->params->{suppressmailgroup};
+ my $suppress_mail = ($suppress_group
+ && Bugzilla->user->in_group($suppress_group)
+ && Bugzilla->input_params->{suppress_mail});
+
# Email the user if the dep check passed.
- if ($dep_ok) {
+ if ($dep_ok && !$suppress_mail) {
my $sent_mail = sendMail(
{ to => $user,
bug => $bug,
diff --git a/Bugzilla/Config/GroupSecurity.pm b/Bugzilla/Config/GroupSecurity.pm
index e827834a0..7abe7027b 100644
--- a/Bugzilla/Config/GroupSecurity.pm
+++ b/Bugzilla/Config/GroupSecurity.pm
@@ -90,6 +90,14 @@ sub get_param_list {
name => 'or_groups',
type => 'b',
default => 0
+ },
+
+ {
+ name => 'suppressmailgroup',
+ type => 's',
+ choices => \&_get_all_group_names,
+ default => 'admin',
+ checker => \&check_group
} );
return @param_list;
}
diff --git a/template/en/default/admin/groups/list.html.tmpl b/template/en/default/admin/groups/list.html.tmpl
index 796872e1d..1ad41feda 100644
--- a/template/en/default/admin/groups/list.html.tmpl
+++ b/template/en/default/admin/groups/list.html.tmpl
@@ -76,7 +76,8 @@
%]
[% FOREACH group IN ["chartgroup", "comment_taggers_group", "debug_group",
- "insidergroup", "querysharegroup", "timetrackinggroup"] %]
+ "insidergroup", "querysharegroup", "timetrackinggroup",
+ "suppressmailgroup"] %]
[% special_group = Param(group) %]
[% IF special_group %]
diff --git a/template/en/default/admin/params/groupsecurity.html.tmpl b/template/en/default/admin/params/groupsecurity.html.tmpl
index 590f4da02..cd1cf4933 100644
--- a/template/en/default/admin/params/groupsecurity.html.tmpl
+++ b/template/en/default/admin/params/groupsecurity.html.tmpl
@@ -51,6 +51,10 @@
"view it. If it is off, a user needs to be a member of all " _
"the $terms.bug's groups. Note that in either case, if the " _
"user has a role on the $terms.bug (e.g. reporter) that may " _
- "also affect their permissions."
+ "also affect their permissions.",
+
+ suppressmailgroup => "The name of the group of users who can suppress mail " _
+ "sending when editing bugs. Set blank, to disable mail suppressing " _
+ "option from all.",
}
%]
diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl
index b8abe6bc5..ac23b1e97 100644
--- a/template/en/default/bug/edit.html.tmpl
+++ b/template/en/default/bug/edit.html.tmpl
@@ -1247,6 +1247,11 @@
<div class="knob-buttons">
<input type="submit" value="Save Changes"
id="commit[% id FILTER css_class_quote %]">
+ [% IF user.in_group(Param('suppressmailgroup')) %]
+ <br><input type="checkbox" name="suppress_mail" value="1">
+ <label style="font-size: small; font-weight: normal;"
+ for="suppress_mail">Suppress mail</label>
+ [% END %]
</div>
[% END %]
[% END %]
diff --git a/template/en/default/list/edit-multiple.html.tmpl b/template/en/default/list/edit-multiple.html.tmpl
index e581f0892..e1047a2aa 100644
--- a/template/en/default/list/edit-multiple.html.tmpl
+++ b/template/en/default/list/edit-multiple.html.tmpl
@@ -389,6 +389,10 @@
[%+ Hook.process('after_groups') %]
<input type="submit" id="commit" value="Commit">
+[% IF user.in_group(Param('suppressmailgroup')) %]
+<input type="checkbox" name="suppress_mail" value="1">
+<label for="suppress_mail">Suppress mail</label>
+[% END %]
[%############################################################################%]
[%# Select Menu Block #%]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment