[Rt-commit] r7327 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Thu Mar 22 21:39:11 EDT 2007
Author: ruz
Date: Thu Mar 22 21:39:09 2007
New Revision: 7327
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
Log:
r4781 at cubic-pc: cubic | 2007-03-23 01:28:01 +0300
::Action::SendEmail
* sub AddAttachment
* sub AddTicket
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Action/SendEmail.pm Thu Mar 22 21:39:09 2007
@@ -297,19 +297,61 @@
# attach any of this transaction's attachments
while ( my $attach = $attachments->Next ) {
$MIMEObj->make_multipart('mixed');
- $MIMEObj->attach(
- Type => $attach->ContentType,
- Charset => $attach->OriginalEncoding,
- Data => $attach->OriginalContent,
- Filename => $self->MIMEEncodeString( $attach->Filename,
- RT->Config->Get('EmailOutputEncoding') ),
- 'RT-Attachment:' => $self->TicketObj->Id."/".$self->TransactionObj->Id."/".$attach->id,
- Encoding => '-SUGGEST'
- );
+ $self->AddAttachment( $attach );
}
}
+=head2 AddAttachment $attachment
+
+Takes one attachment object of L<RT::Attachmment> class and attaches it to the message
+we're building.
+
+=cut
+
+sub AddAttachment {
+ my $self = shift;
+ my $attach = shift;
+ my $MIMEObj = shift || $self->TemplateObj->MIMEObj;
+
+ $MIMEObj->attach(
+ Type => $attach->ContentType,
+ Charset => $attach->OriginalEncoding,
+ Data => $attach->OriginalContent,
+ Filename => $self->MIMEEncodeString( $attach->Filename,
+ RT->Config->Get('EmailOutputEncoding') ),
+ 'RT-Attachment:' => $self->TicketObj->Id."/".$self->TransactionObj->Id."/".$attach->id,
+ Encoding => '-SUGGEST',
+ );
+}
+
+sub AttachTicket {
+ my $self = shift;
+ my $tid = shift || $self->TicketObj->id;
+
+ # XXX: we need a current user here, but who is current user?
+ my $attachs = RT::Attachments->new( $RT::SystemUser );
+ # XXX: comments, correspondence or any?
+ $attachs->LimitByTicket( $tid );
+ $attachs->LimitNotEmpty;
+ $attachs->OrderBy( FIELD => 'Created' );
+
+ my $ticket_mime = MIME::Entity->build(
+ Type => 'multipart/mixed',
+ Top => 0,
+ Description => "ticket #$tid",
+ );
+ while ( my $attachment = $attachs->Next ) {
+ $self->AddAttachment( $attachment, $ticket_mime );
+ }
+ if ( $ticket_mime->parts ) {
+ my $email_mime = $self->TemplateObj->MIMEObj;
+ $email_mime->make_multipart;
+ $email_mime->add_part( $ticket_mime );
+ }
+ return;
+}
+
=head2 RecordOutgoingMailTransaction MIMEObj
Record a transaction in RT with this outgoing message for future record-keeping purposes
More information about the Rt-commit
mailing list