import torrus 1.0.9
[freeside.git] / rt / lib / RT / Transactions_Overlay.pm
index 62a0727..af72c20 100644 (file)
@@ -1,8 +1,8 @@
-# {{{ BEGIN BPS TAGGED BLOCK
+# BEGIN BPS TAGGED BLOCK {{{
 # 
 # COPYRIGHT:
-#  
-# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
+# 
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
 #                                          <jesse@bestpractical.com>
 # 
 # (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 # 
 # 
 # CONTRIBUTION SUBMISSION POLICY:
@@ -42,7 +44,8 @@
 # works based on those contributions, and sublicense and distribute
 # those contributions and any derivatives thereof.
 # 
-# }}} END BPS TAGGED BLOCK
+# END BPS TAGGED BLOCK }}}
+
 =head1 NAME
 
   RT::Transactions - a collection of RT Transaction objects
 
 =head1 METHODS
 
-=begin testing
 
-ok (require RT::Transactions);
+=cut
 
-=end testing
 
-=cut
+package RT::Transactions;
 
 use strict;
 no warnings qw(redefine);
@@ -85,6 +86,46 @@ sub _Init   {
 }
 # }}}
 
+=head2 LimitToTicket TICKETID 
+
+Find only transactions for the ticket whose id is TICKETID.
+
+This includes tickets merged into TICKETID.
+
+Repeated calls to this method will intelligently limit down to that set of tickets, joined with an OR
+
+
+=cut
+
+
+sub LimitToTicket {
+    my $self = shift;
+    my $tid  = shift;
+
+    unless ( $self->{'tickets_table'} ) {
+        $self->{'tickets_table'} ||= $self->NewAlias('Tickets');
+        $self->Join(
+            ALIAS1 => 'main',
+            FIELD1 => 'ObjectId',
+            ALIAS2 => $self->{'tickets_table'},
+            FIELD2 => 'id'
+        );
+        $self->Limit(
+            FIELD => 'ObjectType',
+            VALUE => 'RT::Ticket',
+        );
+    }
+    $self->Limit(
+        ALIAS           => $self->{tickets_table},
+        FIELD           => 'EffectiveId',
+        OPERATOR        => '=',
+        ENTRYAGGREGATOR => 'OR',
+        VALUE           => $tid,
+    );
+
+}
+
+
 # {{{ sub Next
 sub Next {
     my $self = shift;