4 #A default implementation here loops through all transactions and pulls out all their attachments.
5 # We end up doing an end-run around that to get a bit more performance
7 # We force the cache of ticket transactions to get populated up front. otherwise, the
8 # code that looks at attachments will look at each one in turn.
9 my $transactions = $Ticket->Transactions->First;
12 my $attachments = RT::Attachments->new( $session{'CurrentUser'} );
14 $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId Created));
16 if ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
17 my $transactions = $attachments->NewAlias('Transactions');
18 $attachments->Join( ALIAS1 => 'main',
19 FIELD1 => 'TransactionId',
20 ALIAS2 => $transactions,
23 my $tickets = $attachments->NewAlias('Tickets');
25 $attachments->Join( ALIAS1 => $transactions,
30 $attachments->Limit( ALIAS => $tickets,
31 FIELD => 'EffectiveId',
32 VALUE => $Ticket->id() );
33 # if the user may not see comments do not return them
34 unless ( $Ticket->CurrentUserHasRight('ShowTicketComments') ) {
35 $attachments->Limit( ALIAS => $transactions,
41 return ($attachments);