- my $self = shift;
- my $attachment = shift;
- $self->Limit ( FIELD => 'Parent',
- VALUE => $attachment);
+ my $self = shift;
+ my $attachment = shift;
+ return $self->Limit(
+ FIELD => 'Parent',
+ VALUE => $attachment
+ );
+}
+
+=head2 LimitNotEmpty
+
+Limit result set to attachments with not empty content.
+
+=cut
+
+sub LimitNotEmpty {
+ my $self = shift;
+ $self->Limit(
+ ENTRYAGGREGATOR => 'AND',
+ FIELD => 'Content',
+ OPERATOR => 'IS NOT',
+ VALUE => 'NULL',
+ QUOTEVALUE => 0,
+ );
+
+ # http://rt3.fsck.com/Ticket/Display.html?id=12483
+ if ( RT->Config->Get('DatabaseType') ne 'Oracle' ) {
+ $self->Limit(
+ ENTRYAGGREGATOR => 'AND',
+ FIELD => 'Content',
+ OPERATOR => '!=',
+ VALUE => '',
+ );
+ }
+ return;
+}
+
+=head2 LimitByTicket $ticket_id
+
+Limit result set to attachments of a ticket.
+
+=cut
+
+sub LimitByTicket {
+ my $self = shift;
+ my $tid = shift;
+
+ my $transactions = $self->TransactionAlias;
+ $self->Limit(
+ ENTRYAGGREGATOR => 'AND',
+ ALIAS => $transactions,
+ FIELD => 'ObjectType',
+ VALUE => 'RT::Ticket',
+ );
+
+ my $tickets = $self->NewAlias('Tickets');
+ $self->Limit(
+ ENTRYAGGREGATOR => 'AND',
+ ALIAS => $tickets,
+ FIELD => 'id',
+ VALUE => $transactions . '.ObjectId',
+ QUOTEVALUE => 0,
+ );
+ $self->Limit(
+ ENTRYAGGREGATOR => 'AND',
+ ALIAS => $tickets,
+ FIELD => 'EffectiveId',
+ VALUE => $tid,
+ );
+ return;