X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FAttachments.pm;h=6b935da6eef596d7ca8f443d9208dbe1d9d0a0a8;hp=2bdbc244c32c677242fd483c953ec32b573ad0eb;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=c24d6e2242ae0e026684b8f95decf156aba6e75e diff --git a/rt/lib/RT/Attachments.pm b/rt/lib/RT/Attachments.pm index 2bdbc244c..6b935da6e 100755 --- a/rt/lib/RT/Attachments.pm +++ b/rt/lib/RT/Attachments.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -71,11 +71,10 @@ package RT::Attachments; use strict; use warnings; +use base 'RT::SearchBuilder'; use RT::Attachment; -use base 'RT::SearchBuilder'; - sub Table { 'Attachments'} @@ -112,14 +111,12 @@ sub TransactionAlias { return $self->{'_sql_transaction_alias'} if $self->{'_sql_transaction_alias'}; - my $res = $self->NewAlias('Transactions'); - $self->Limit( - ENTRYAGGREGATOR => 'AND', - FIELD => 'TransactionId', - VALUE => $res . '.id', - QUOTEVALUE => 0, + return $self->{'_sql_transaction_alias'} = $self->Join( + ALIAS1 => 'main', + FIELD1 => 'TransactionId', + TABLE2 => 'Transactions', + FIELD2 => 'id', ); - return $self->{'_sql_transaction_alias'} = $res; } =head2 ContentType (VALUE => 'text/plain', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' ) @@ -133,9 +130,9 @@ sub ContentType { my $self = shift; my %args = ( VALUE => 'text/plain', - OPERATOR => '=', - ENTRYAGGREGATOR => 'OR', - @_ + OPERATOR => '=', + ENTRYAGGREGATOR => 'OR', + @_ ); return $self->Limit ( %args, FIELD => 'ContentType' ); @@ -203,13 +200,11 @@ sub LimitByTicket { VALUE => 'RT::Ticket', ); - my $tickets = $self->NewAlias('Tickets'); - $self->Limit( - ENTRYAGGREGATOR => 'AND', - ALIAS => $tickets, - FIELD => 'id', - VALUE => $transactions . '.ObjectId', - QUOTEVALUE => 0, + my $tickets = $self->Join( + ALIAS1 => $transactions, + FIELD1 => 'ObjectId', + TABLE2 => 'Tickets', + FIELD2 => 'id', ); $self->Limit( ENTRYAGGREGATOR => 'AND', @@ -220,31 +215,12 @@ sub LimitByTicket { return; } -# {{{ sub Next -sub Next { +sub AddRecord { my $self = shift; + my ($record) = @_; - my $Attachment = $self->SUPER::Next; - return $Attachment unless $Attachment; - - if ( $Attachment->TransactionObj->CurrentUserCanSee ) { - return $Attachment; - } else { - # If the user doesn't have the right to show this ticket - return $self->Next; - } -} - - -=head2 NewItem - -Returns an empty new RT::Attachment item - -=cut - -sub NewItem { - my $self = shift; - return(RT::Attachment->new($self->CurrentUser)); + return unless $record->TransactionObj->CurrentUserCanSee; + return $self->SUPER::AddRecord( $record ); } RT::Base->_ImportOverlays();