[Rt-commit] r7328 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Thu Mar 22 21:39:19 EDT 2007


Author: ruz
Date: Thu Mar 22 21:39:18 2007
New Revision: 7328

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachments_Overlay.pm

Log:
 r4782 at cubic-pc:  cubic | 2007-03-23 04:23:00 +0300
 * add TransactionAlias sub to Attachments


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachments_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachments_Overlay.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachments_Overlay.pm	Thu Mar 22 21:39:18 2007
@@ -77,7 +77,6 @@
 
 use RT::Attachment;
 
-# {{{ sub _Init  
 sub _Init   {
     my $self = shift;
     $self->{'table'} = "Attachments";
@@ -88,10 +87,36 @@
     );
     return $self->SUPER::_Init( @_ );
 }
-# }}}
 
+sub CleanSlate {
+    my $self = shift;
+    delete $self->{_sql_transaction_alias};
+    return $self->SUPER::CleanSlate( @_ );
+}
+
+
+=head2 TransactionAlias
+
+Returns alias for transactions table with applied join condition.
+Always return the same alias, so if you want to build some complex
+or recursive joining then you have to create new alias youself.
 
-# {{{ sub ContentType
+=cut
+
+sub TransactionAlias {
+    my $self = shift;
+    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'} = $res;
+}
 
 =head2 ContentType (VALUE => 'text/plain', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' ) 
 
@@ -112,9 +137,6 @@
 		 OPERATOR => $args{'OPERATOR'},
 		 ENTRYAGGREGATOR => $args{'ENTRYAGGREGATOR'});
 }
-# }}}
-
-# {{{ sub ChildrenOf 
 
 =head2 ChildrenOf ID
 
@@ -165,13 +187,8 @@
 sub LimitByTicket {
     my $self = shift;
     my $tid = shift;
-    my $transactions = $self->NewAlias('Transactions');
-    $self->Limit(
-        ENTRYAGGREGATOR => 'AND',
-        FIELD           => 'TransactionId',
-        VALUE           => $transactions . '.id',
-        QUOTEVALUE      => 0,
-    );
+
+    my $transactions = $self->TransactionAlias;
     $self->Limit(
         ENTRYAGGREGATOR => 'AND',
         ALIAS           => $transactions,


More information about the Rt-commit mailing list