]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 545683: New Hook: bugmail_recipients
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Thu, 11 Feb 2010 20:12:48 +0000 (12:12 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Thu, 11 Feb 2010 20:12:48 +0000 (12:12 -0800)
r=mkanat, a=mkanat (module owner)

Bugzilla/BugMail.pm
Bugzilla/Hook.pm
extensions/Example/Extension.pm

index f7af921ebc320b2532e62bcc78cdb74521c8e9fe..20336b1d993ac2c477d85c7123b64d0dfe874ed4 100644 (file)
@@ -42,6 +42,7 @@ use Bugzilla::Product;
 use Bugzilla::Component;
 use Bugzilla::Status;
 use Bugzilla::Mailer;
+use Bugzilla::Hook;
 
 use Date::Parse;
 use Date::Format;
@@ -418,6 +419,9 @@ sub Send {
             }
         }
     }
+
+    Bugzilla::Hook::process('bugmail_recipients',
+                            { bug => $bug, recipients => \%recipients });
     
     # Find all those user-watching anyone on the current list, who is not
     # on it already themselves.
index 13e435e86ef233e77b6e5d72e417c9d1478cabfb..2b9341ab43e4c8c3f6cdc9e7abb6b02797dfaf17 100644 (file)
@@ -354,6 +354,48 @@ The definition is structured as:
 
 =back
 
+=head2 bugmail_recipients
+
+This allows you to modify the list of users who are going to be receiving
+a particular bugmail. It also allows you to specify why they are receiving
+the bugmail.
+
+Users' bugmail preferences will be applied to any users that you add
+to the list. (So, for example, if you add somebody as though they were
+a CC on the bug, and their preferences state that they don't get email
+when they are a CC, they won't get email.)
+
+This hook is called before watchers or globalwatchers are added to the
+recipient list.
+
+Params:
+
+=over
+
+=item C<bug>
+
+The L<Bugzilla::Bug> that bugmail is being sent about.
+
+=item C<recipients>
+
+This is a hashref. The keys are numeric user ids from the C<profiles>
+table in the database, for each user who should be receiving this bugmail.
+The values are hashrefs. The keys in I<these> hashrefs correspond to
+the "relationship" that the user has to the bug they're being emailed
+about, and the value should always be C<1>. The "relationships"
+are described by the various C<REL_> constants in L<Bugzilla::Constants>.
+
+Here's an example of adding userid C<123> to the recipient list
+as though he were on the CC list:
+
+ $recipients->{123}->{+REL_CC} = 1
+
+(We use C<+> in front of C<REL_CC> so that Perl interprets it as a constant
+instead of as a string.)
+
+=back
+
+
 =head2 colchange_columns
 
 This happens in F<colchange.cgi> right after the list of possible display
index 1a483ad536e2b0d2e79db8aeb28114ff474aadfa..8ce2ece6acc09c4b7eeed8641f43a158da6693bc 100644 (file)
@@ -188,6 +188,18 @@ sub buglist_columns {
     $columns->{'example'} = { 'name' => 'bugs.delta_ts' , 'title' => 'Example' };
 }
 
+sub bugmail_recipients {
+    my ($self, $args) = @_;
+    my $recipients = $args->{recipients};
+    my $bug = $args->{bug};
+    if ($bug->id == 1) {
+        # Uncomment the line below to add the second user in the Bugzilla
+        # database to the recipients list of every bugmail sent out about
+        # bug 1 as though that user were on the CC list.
+        #$recipients->{2}->{+REL_CC} = 1;
+    }
+}
+
 sub colchange_columns {
     my ($self, $args) = @_;