1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/copyleft/gpl.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
49 package RT::Action::Notify;
50 require RT::Action::SendEmail;
54 @ISA = qw(RT::Action::SendEmail);
59 Set up the relevant recipients, then call our parent.
66 $self->SetRecipients();
67 $self->SUPER::Prepare();
70 # {{{ sub SetRecipients
74 Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All.
75 Explicitly B<does not> notify the creator of the transaction by default
82 my $arg = $self->Argument;
84 $arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc/;
86 my ( @To, @PseudoTo, @Cc, @Bcc );
89 if ( $arg =~ /\bOtherRecipients\b/ ) {
90 if ( $self->TransactionObj->Attachments->First ) {
91 my @cc_addresses = Mail::Address->parse($self->TransactionObj->Attachments->First->GetHeader('RT-Send-Cc'));
92 foreach my $addr (@cc_addresses) {
93 push @Cc, $addr->address;
95 my @bcc_addresses = Mail::Address->parse($self->TransactionObj->Attachments->First->GetHeader('RT-Send-Bcc'));
97 foreach my $addr (@bcc_addresses) {
98 push @Bcc, $addr->address;
104 if ( $arg =~ /\bRequestor\b/ ) {
105 push ( @To, $self->TicketObj->Requestors->MemberEmailAddresses );
110 if ( $arg =~ /\bCc\b/ ) {
112 #If we have a To, make the Ccs, Ccs, otherwise, promote them to To
114 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
115 push ( @Cc, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
118 push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
119 push ( @To, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses );
123 if ( ( $arg =~ /\bOwner\b/ )
124 && ( $self->TicketObj->OwnerObj->id != $RT::Nobody->id ) )
127 # If we're not sending to Ccs or requestors,
128 # then the Owner can be the To.
130 push ( @Bcc, $self->TicketObj->OwnerObj->EmailAddress );
133 push ( @To, $self->TicketObj->OwnerObj->EmailAddress );
138 if ( $arg =~ /\bAdminCc\b/ ) {
139 push ( @Bcc, $self->TicketObj->AdminCc->MemberEmailAddresses );
140 push ( @Bcc, $self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses );
143 if ($RT::UseFriendlyToLine) {
147 sprintf($RT::FriendlyToLineFormat, $arg, $self->TicketObj->id),
152 my $creator = $self->TransactionObj->CreatorObj->EmailAddress();
154 #Strip the sender out of the To, Cc and AdminCc and set the
155 # recipients fields used to build the message by the superclass.
156 # unless a flag is set
157 if ($RT::NotifyActor) {
158 @{ $self->{'To'} } = @To;
159 @{ $self->{'Cc'} } = @Cc;
160 @{ $self->{'Bcc'} } = @Bcc;
163 @{ $self->{'To'} } = grep ( lc $_ ne lc $creator, @To );
164 @{ $self->{'Cc'} } = grep ( lc $_ ne lc $creator, @Cc );
165 @{ $self->{'Bcc'} } = grep ( lc $_ ne lc $creator, @Bcc );
167 @{ $self->{'PseudoTo'} } = @PseudoTo;
174 eval "require RT::Action::Notify_Vendor";
175 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Vendor.pm});
176 eval "require RT::Action::Notify_Local";
177 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Notify_Local.pm});