import rt 3.6.6
[freeside.git] / rt / lib / RT / Action / Autoreply.pm
1 # BEGIN BPS TAGGED BLOCK {{{
2
3 # COPYRIGHT:
4 #  
5 # This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
6 #                                          <jesse@bestpractical.com>
7
8 # (Except where explicitly superseded by other copyright notices)
9
10
11 # LICENSE:
12
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
16 # from www.gnu.org.
17
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.
22
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.
28
29
30 # CONTRIBUTION SUBMISSION POLICY:
31
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.)
37
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.
46
47 # END BPS TAGGED BLOCK }}}
48 package RT::Action::Autoreply;
49 require RT::Action::SendEmail;
50
51 use strict;
52 use vars qw/@ISA/;
53 @ISA = qw(RT::Action::SendEmail);
54
55 =head2 Prepare
56
57 Set up the relevant recipients, then call our parent.
58
59 =cut
60
61
62 sub Prepare {
63     my $self = shift;
64     $self->SetRecipients();
65     $self->SUPER::Prepare();
66 }
67
68 # {{{ sub SetRecipients
69
70 =head2 SetRecipients
71
72 Sets the recipients of this message to this ticket's Requestor.
73
74 =cut
75
76
77 sub SetRecipients {
78     my $self=shift;
79
80     push(@{$self->{'To'}}, $self->TicketObj->Requestors->MemberEmailAddresses);
81     
82     return(1);
83 }
84
85 # }}}
86
87
88 # {{{ sub SetReturnAddress 
89
90 =head2 SetReturnAddress
91
92 Set this message\'s return address to the apropriate queue address
93
94 =cut
95
96 sub SetReturnAddress {
97     my $self = shift;
98     my %args = ( is_comment => 0,
99                  @_
100                );
101     
102     my $replyto;
103     if ($args{'is_comment'}) { 
104         $replyto = $self->TicketObj->QueueObj->CommentAddress || 
105                      $RT::CommentAddress;
106     }
107     else {
108         $replyto = $self->TicketObj->QueueObj->CorrespondAddress ||
109                      $RT::CorrespondAddress;
110     }
111     
112     unless ($self->TemplateObj->MIMEObj->head->get('From')) {
113         if ($RT::UseFriendlyFromLine) {
114             my $friendly_name = $self->TicketObj->QueueObj->Description ||
115                     $self->TicketObj->QueueObj->Name;
116             $friendly_name =~ s/"/\\"/g;
117             $self->SetHeader( 'From',
118                         sprintf($RT::FriendlyFromLineFormat, 
119                 $self->MIMEEncodeString( $friendly_name, $RT::EmailOutputEncoding ), $replyto),
120             );
121         }
122         else {
123             $self->SetHeader( 'From', $replyto );
124         }
125     }
126     
127     unless ($self->TemplateObj->MIMEObj->head->get('Reply-To')) {
128         $self->SetHeader('Reply-To', "$replyto");
129     }
130     
131 }
132   
133 # }}}
134
135 eval "require RT::Action::Autoreply_Vendor";
136 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Autoreply_Vendor.pm});
137 eval "require RT::Action::Autoreply_Local";
138 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Autoreply_Local.pm});
139
140 1;