[Rt-commit] r7709 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Thu Apr 26 15:20:21 EDT 2007


Author: ruz
Date: Thu Apr 26 15:20:20 2007
New Revision: 7709

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Ticket/ShowEmailRecord.html

Log:
 r5161 at cubic-pc:  cubic | 2007-04-26 23:20:12 +0400
 * show nested attachments in EmailRecords


Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/ShowEmailRecord.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/ShowEmailRecord.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/ShowEmailRecord.html	Thu Apr 26 15:20:20 2007
@@ -49,25 +49,48 @@
 $Attachment => undef
 $Transaction => undef
 </%ARGS>
-<%init>
-     my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
-     $AttachmentObj->Load($Attachment) || Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
-
+<%INIT>
+my $show_content = sub {
+    my $attach = shift;
+    if ( $attach->ContentType =~ m{^(?:text|message)/}i ) {
+        $m->out( $m->interp->apply_escapes( $attach->Content, 'h' ) );
+        return;
+    }
+    my $href = RT->Config->Get('WebPath') .'/Ticket/Attachment/'
+        . $attach->TransactionId .'/'. $attach->id .'/'
+        . $m->interp->apply_escapes( $attach->Filename, 'u' );
+    $m->out( '<a href="'. $href  .'">'. loc('download') .'</a>' );
+};
 
-     unless ($AttachmentObj->id) {
-        Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+my $show;
+$show = sub {
+    my $attach = shift;
+    $m->out( '<pre style="padding: 2em;">' );
+    $m->out( $m->interp->apply_escapes( $attach->Headers, 'h' ) );
+    $m->out( "\n\n" );
+    if ( $attach->ContentType =~ m{^multipart/}i ) {
+        my $children = $attach->Children;
+        while ( my $child = $children->Next ) {
+            $show->( $child );
+        }
+    } else {
+        $show_content->( $attach );
     }
-     unless ($AttachmentObj->TransactionId() == $Transaction ) {
-        Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
-     }
+    $m->out( '</pre>' );
+};
 
-</%init>
-<& /Elements/Header, ShowBar => 0 &>
-<pre style="padding: 2em;">
-<%$AttachmentObj->Headers%>
+my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
+$AttachmentObj->Load($Attachment) || Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+unless ( $AttachmentObj->id ) {
+    Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+}
+unless ($AttachmentObj->TransactionId() == $Transaction ) {
+    Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+}
 
-<%$AttachmentObj->Content%>
-</pre>
+</%INIT>
+<& /Elements/Header, ShowBar => 0 &>
+% $show->( $AttachmentObj );
 </body>
 </html>
-%$m->abort;
+% $m->abort;


More information about the Rt-commit mailing list