1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
6 # <jesse@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 # CONTRIBUTION SUBMISSION POLICY:
30 # (The following paragraph is not intended to limit the rights granted
31 # to you to modify and distribute this software under the terms of
32 # the GNU General Public License and is only of importance to you if
33 # you choose to contribute your changes and enhancements to the
34 # community by submitting them to Best Practical Solutions, LLC.)
36 # By intentionally submitting any modifications, corrections or
37 # derivatives to this work, or any other work intended for use with
38 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 # you are the copyright holder for those contributions and you grant
40 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 # royalty-free, perpetual, license to use, copy, create derivative
42 # works based on those contributions, and sublicense and distribute
43 # those contributions and any derivatives thereof.
45 # END BPS TAGGED BLOCK }}}
47 package RT::Action::Notify;
48 require RT::Action::SendEmail;
52 @ISA = qw(RT::Action::SendEmail);
57 Set up the relevant recipients, then call our parent.
64 $self->SetRecipients();
65 $self->SUPER::Prepare();
68 # {{{ sub SetRecipients
72 Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All.
73 Explicitly B<does not> notify the creator of the transaction by default
80 my $arg = $self->Argument;
82 $arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc/;
84 my ( @To, @PseudoTo, @Cc, @Bcc );
87 if ( $arg =~ /\bOtherRecipients\b/ ) {
88 if ( $self->TransactionObj->Attachments->First ) {
89 my @cc_addresses = Mail::Address->parse($self->TransactionObj->Attachments->First->GetHeader('RT-Send-Cc'));
90 foreach my $addr (@cc_addresses) {
91 push @Cc, $addr->address;
93 my @bcc_addresses = Mail::Address->parse($self->TransactionObj->Attachments->First->GetHeader('RT-Send-Bcc'));
95 foreach my $addr (@bcc_addresses) {
96 push @Bcc, $addr->address;
102 if ( $arg =~ /\bRequestor\b/ ) {
103 push ( @To, $self->TicketObj->Requestors->MemberEmailAddresses );
108 if ( $arg =~ /\bCc\b/ ) {
110 #If we have a To, make the Ccs, Ccs, otherwise, promote them to To
112 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
113 push ( @Cc, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
116 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
117 push ( @To, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
121 if ( ( $arg =~ /\bOwner\b/ )
122 && ( $self->TicketObj->OwnerObj->id != $RT::Nobody->id ) )
125 # If we're not sending to Ccs or requestors,
126 # then the Owner can be the To.
128 push ( @Bcc, $self->TicketObj->OwnerObj->EmailAddress );
131 push ( @To, $self->TicketObj->OwnerObj->EmailAddress );
136 if ( $arg =~ /\bAdminCc\b/ ) {
137 push ( @Bcc, $self->TicketObj->AdminCc->MemberEmailAddresses );
138 push ( @Bcc, $self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses );
141 if ($RT::UseFriendlyToLine) {
145 sprintf($RT::FriendlyToLineFormat, $arg, $self->TicketObj->id),
150 my $creator = $self->TransactionObj->CreatorObj->EmailAddress();
152 #Strip the sender out of the To, Cc and AdminCc and set the
153 # recipients fields used to build the message by the superclass.
154 # unless a flag is set
155 if ($RT::NotifyActor) {
156 @{ $self->{'To'} } = @To;
157 @{ $self->{'Cc'} } = @Cc;
158 @{ $self->{'Bcc'} } = @Bcc;
161 @{ $self->{'To'} } = grep ( lc $_ ne lc $creator, @To );
162 @{ $self->{'Cc'} } = grep ( lc $_ ne lc $creator, @Cc );
163 @{ $self->{'Bcc'} } = grep ( lc $_ ne lc $creator, @Bcc );
165 @{ $self->{'PseudoTo'} } = @PseudoTo;
172 eval "require RT::Action::Notify_Vendor";
173 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Vendor.pm});
174 eval "require RT::Action::Notify_Local";
175 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Local.pm});