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 # Find all the attachments which have parent $Parent
50 # For each of these attachments
51 foreach my $message ( grep { $_->Parent == $Parent } @$Attachments ) {
53 # {{{ show the headers
54 my $headers = $message->Headers;
57 # localize the common headers (like 'Subject:'), too.
58 $headers =~ s/^([^:]+)(?=:)/loc($1)/em;
62 Transaction => $Transaction,
63 DisplayHeaders => \@DisplayHeaders
67 # {{{ if there's any size at all, show the download link
68 my $size = $message->ContentLength;
72 <div class="downloadattachment">
75 # show a download link
77 $size = loc( "[_1]k", int( $size / 102.4 ) / 10 );
80 $size = loc( "[_1]b", $size );
84 <a href="<%$AttachPath%>/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename | u%>"><&|/l&>Download</&> <%$message->Filename || loc('(untitled)') %></a>
85 <span class="downloadcontenttype">
86 [<%$message->ContentType%> <% $size %>]
91 <div class="messagebody">
93 # {{{ if it has a content-disposition: attachment, don't show inline
94 unless ( ($message->GetHeader('Content-Disposition')||"") =~ /attachment/i ) {
99 if ( $message->ContentType =~ m{^(text|message)}i
100 && !($RT::SuppressInlineTextFiles && $message->Filename)
101 && $message->ContentLength <= $RT::MaxInlineBody )
106 # it's a toplevel object
109 # or its parent isn't a multipart alternative
110 || ( $ParentObj->ContentType !~ m{^multipart/alternative$}i )
112 # or it's of our prefered alterative type
116 && ( $message->ContentType =~ m{^text/(?:html|enriched)$} )
118 || ( !$RT::PreferRichText
119 && ( $message->ContentType !~ m{^text/(?:html|enriched)$} )
125 if ( $AttachmentContent->{ $message->id } ) {
126 $content = $AttachmentContent->{ $message->id }->Content;
129 $content = $message->Content;
132 # if it's a text/html clean the body and show it
133 if ( $message->ContentType =~ m{^text/(?:html|enriched)$}i ) {
135 $m->comp( '/Elements/ScrubHTML', Content => $content );
139 # if it's a text/plain show the body
140 elsif ( $message->ContentType =~ m{^(text|message|text)}i ) {
142 #don't want to use this even if it is installed, its
143 #segfaulting on weird characters and silently truncating the
144 #ticket history output
146 # r44838@pinglin: jesse | 2006-11-14 15:53:18 -0500
147 # * Move Text::Quoted back to being a run-time require. So that it's possible to turn off the feature if it causes your perl to segfault. (Text::Tabs is...not robust in the face of perl bugs)
148 #eval { require Text::Quoted; $content = Text::Quoted::extract($content); };
155 Transaction => $Transaction
162 # if it's an image, show it as an image
163 elsif ( $RT::ShowTransactionImages and $message->ContentType =~ /^image\//i ) {
166 . $Transaction->Id . '/'
170 elsif ( $message->ContentLength > 0 ) {
172 loc( 'Message body not shown because it is too large or is not plain text.' )
180 'ShowTransactionAttachments', %ARGS,
181 Parent => $message->id,
182 ParentObj => $message
190 $Transaction => undef
193 $ShowTitleBarCommands => 1
195 $AttachPath => $RT::WebPath."/Ticket/Attachment"
196 $UpdatePath => $RT::WebPath."/Ticket/Update.html"
197 $EmailRecordPath => $RT::WebPath."/Ticket/ShowEmailRecord.html"
198 $Attachments => undef
199 $AttachmentContent => undef
205 my @DisplayHeaders=qw( _all);
207 if ( $Transaction->Type =~ /EmailRecord$/ ) {
208 @DisplayHeaders = qw(To Cc Bcc);
211 # If the transaction has anything attached to it at all
212 elsif (!$ShowHeaders) {
213 @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);