3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
24 package RT::Action::Notify;
25 require RT::Action::SendEmail;
29 @ISA = qw(RT::Action::SendEmail);
31 # {{{ sub SetRecipients
35 Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All.
36 Explicitly B<does not> notify the creator of the transaction by default
43 my $arg = $self->Argument;
45 $arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc/;
47 my ( @To, @PseudoTo, @Cc, @Bcc );
50 if ($arg =~ /\bOtherRecipients\b/) {
51 if ($self->TransactionObj->Attachments->First) {
52 push (@Cc, $self->TransactionObj->Attachments->First->GetHeader('RT-Send-Cc'));
53 push (@Bcc, $self->TransactionObj->Attachments->First->GetHeader('RT-Send-Bcc'));
57 if ( $arg =~ /\bRequestor\b/ ) {
58 push ( @To, $self->TicketObj->Requestors->MemberEmailAddresses );
63 if ( $arg =~ /\bCc\b/ ) {
65 #If we have a To, make the Ccs, Ccs, otherwise, promote them to To
67 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
68 push ( @Cc, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
71 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
72 push ( @To, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
76 if ( ( $arg =~ /\bOwner\b/ )
77 && ( $self->TicketObj->OwnerObj->id != $RT::Nobody->id ) )
80 # If we're not sending to Ccs or requestors,
81 # then the Owner can be the To.
83 push ( @Bcc, $self->TicketObj->OwnerObj->EmailAddress );
86 push ( @To, $self->TicketObj->OwnerObj->EmailAddress );
91 if ( $arg =~ /\bAdminCc\b/ ) {
92 push ( @Bcc, $self->TicketObj->AdminCc->MemberEmailAddresses );
93 push ( @Bcc, $self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses );
96 if ($RT::UseFriendlyToLine) {
100 sprintf($RT::FriendlyToLineFormat, $arg, $self->TicketObj->id),
105 my $creator = $self->TransactionObj->CreatorObj->EmailAddress();
107 #Strip the sender out of the To, Cc and AdminCc and set the
108 # recipients fields used to build the message by the superclass.
109 # unless a flag is set
110 if ($RT::NotifyActor) {
111 @{ $self->{'To'} } = @To;
112 @{ $self->{'Cc'} } = @Cc;
113 @{ $self->{'Bcc'} } = @Bcc;
116 @{ $self->{'To'} } = grep ( !/^$creator$/, @To );
117 @{ $self->{'Cc'} } = grep ( !/^$creator$/, @Cc );
118 @{ $self->{'Bcc'} } = grep ( !/^$creator$/, @Bcc );
120 @{ $self->{'PseudoTo'} } = @PseudoTo;
127 eval "require RT::Action::Notify_Vendor";
128 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Vendor.pm});
129 eval "require RT::Action::Notify_Local";
130 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Local.pm});