X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fhtml%2FTicket%2FElements%2FShowTransactionAttachments;h=662b744ae75a4203bae187bedc986b9591134acc;hp=b01586debd5e1a5f006ea5f4fb66f9ea70b09caa;hb=fc6209f398899f0211cfcedeb81a3cd65e04a941;hpb=d39d52aac8f38ea9115628039f0df5aa3ac826de diff --git a/rt/html/Ticket/Elements/ShowTransactionAttachments b/rt/html/Ticket/Elements/ShowTransactionAttachments index b01586deb..662b744ae 100644 --- a/rt/html/Ticket/Elements/ShowTransactionAttachments +++ b/rt/html/Ticket/Elements/ShowTransactionAttachments @@ -1,8 +1,8 @@ -%# {{{ BEGIN BPS TAGGED BLOCK +%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -42,7 +44,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# }}} END BPS TAGGED BLOCK +%# END BPS TAGGED BLOCK }}} <%perl> # Find all the attachments which have parent $Parent # For each of these attachments @@ -79,21 +81,25 @@ foreach my $message ( grep { $_->Parent == $Parent } @$Attachments ) { } -<&|/l&>Download<%$message->Filename || loc('(untitled)') %> -
-<%$message->ContentType%> <% $size %> -
+<&|/l&>Download <%$message->Filename || loc('(untitled)') %> + +[<%$message->ContentType%> <% $size %>] + -%} - +% } % # }}}
<%perl> -# {{{ if it's got content-disposition inline, show it inline +# {{{ if it has a content-disposition: attachment, don't show inline +unless ( ($message->GetHeader('Content-Disposition')||"") =~ /attachment/i ) { + my $content; # If it's text - if ( $message->ContentType =~ m{^(text|message)}i ) { + if ( $message->ContentType =~ m{^(text|message)}i + && !($RT::SuppressInlineTextFiles && $message->Filename) + && $message->ContentLength <= $RT::MaxInlineBody ) + { if ( @@ -127,13 +133,13 @@ foreach my $message ( grep { $_->Parent == $Parent } @$Attachments ) { if ( $message->ContentType =~ m{^text/(?:html|enriched)$}i ) { $content = $m->comp( '/Elements/ScrubHTML', Content => $content ); - $m->out( $content ); + $m->out($content); } # if it's a text/plain show the body elsif ( $message->ContentType =~ m{^(text|message|text)}i ) { - eval { $content = Text::Quoted::extract($content); }; + eval { require Text::Quoted; $content = Text::Quoted::extract($content); }; if ($@) { 1; } $m->comp( @@ -146,26 +152,33 @@ foreach my $message ( grep { $_->Parent == $Parent } @$Attachments ) { } } - # if it's an image, show it as an image - elsif ( $message->ContentType =~ /^image\//i ) { - $m->out('' ); - } + # if it's an image, show it as an image + elsif ( $RT::ShowTransactionImages and $message->ContentType =~ /^image\//i ) { + $m->out('' ); + } + elsif ( $message->ContentLength > 0 ) { + $m->out( + loc( 'Message body not shown because it is too large or is not plain text.' ) + ); + } +} - # }}} - - $m->comp( 'ShowTransactionAttachments', %ARGS, - Parent => $message->id, - ParentObj => $message ); +# }}} +$m->comp( + 'ShowTransactionAttachments', %ARGS, + Parent => $message->id, + ParentObj => $message +); -}
+% } <%ARGS> $Ticket => undef $Transaction => undef