3 my $attachments = RT::Attachments->new( $session{'CurrentUser'} );
5 $attachments->Columns( qw(id Content ContentType TransactionId ContentEncoding));
7 if ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
8 my $transactions = $attachments->NewAlias('Transactions');
9 $attachments->Join( ALIAS1 => 'main',
10 FIELD1 => 'TransactionId',
11 ALIAS2 => $transactions,
14 my $tickets = $attachments->NewAlias('Tickets');
16 $attachments->Join( ALIAS1 => $transactions,
21 $attachments->Limit( ALIAS => $tickets,
22 FIELD => 'EffectiveId',
23 VALUE => $Ticket->id() );
24 # if the user may not see comments do not return them
25 unless ( $Ticket->CurrentUserHasRight('ShowTicketComments') ) {
26 $attachments->Limit( ALIAS => $transactions, FIELD => 'Type', OPERATOR => '!=', VALUE => "Comment" );
29 $attachments->Limit ( FIELD => 'ContentType', OPERATOR => '=', VALUE => 'text/plain');
30 $attachments->Limit ( FIELD => 'ContentType', OPERATOR => 'STARTSWITH', VALUE => 'message/');
31 $attachments->Limit ( FIELD => 'ContentType', OPERATOR => '=', VALUE => 'text');
34 return ($attachments);