[rt-users] Faking {$Transaction->Content()}
Mauricio Tavares
raubvogel at gmail.com
Thu Jun 30 17:59:08 EDT 2011
From what I understand (thanks trs), in an on Owner Change event
you cannot rely on using {$Transaction->Content()} to copy the last
message/correspondence in a given ticket because no transaction was
created. So, how can you fake it in an template? If the content was
only a text file, it is not hard to do it, but what happens when you
also have attachments? I wrote the following template,
{
my $thingie = "Attachments:";
my $Transactions = $Ticket->Transactions;
$Transactions->Limit( FIELD => 'Type',
VALUE => "Correspond"
);
# $Rt::Logger->debug("Find Transaction");
my $TransactionObj = $Transactions->Last;
my $AttachmentsObj = RT::Attachments->new($TransactionObj->CurrentUser);
$AttachmentsObj->Limit( FIELD => 'TransactionID',
VALUE => $TransactionObj->id
);
while ( my $a = $AttachmentsObj->Next ) {
$thingie .= "\nFound an attachment with encoding " .
$a->ContentType . " and ID " . $a->id;
if ( $a->ContentType eq 'text/plain' || $a->ContentType eq
'text/html'){
$thingie .= "\nContent:\n" . $a->Content;
}
elseif ( $a->ContentType eq 'multipart/mixed') {
}
else {
$thingie .= "\n" . $RT::WebURL ."/Ticket/Attachment/".
$a->TransactionId ."/". $a->id ."/". $a->Filename;
$thingie .= "\n ";
}
}
$thingie;
}
which finds the attachments and put links for the non-text (from
http://requesttracker.wikia.com/wiki/AddAttachmentLinksToMail)
attachments, but what I really want is, well, emulate
{$Transaction->Content()}. Would anyone have any pointers?
More information about the rt-users
mailing list