[Rt-commit] r2082 - in rt/branches/PLATANO-EXPERIMENTAL: . html/Ticket/Elements lib/RT

jesse at bestpractical.com jesse at bestpractical.com
Fri Jan 14 03:40:48 EST 2005


Author: jesse
Date: Fri Jan 14 03:40:48 2005
New Revision: 2082

Modified:
   rt/branches/PLATANO-EXPERIMENTAL/   (props changed)
   rt/branches/PLATANO-EXPERIMENTAL/html/Ticket/Elements/ShowHistory
   rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm
   rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Transactions_Overlay.pm
Log:
 r2503 at hualien (orig r2024):  jesse | 2004-12-21T22:11:39.522527Z
  r2500 at hualien:  jesse | 2004-12-21T22:06:43.378557Z
  Refactored RT's logic that limits sets of transactions to tickets to make it easier to reuse.
  Fixed bugs in searches for transactions related to multiple tickets.
  
  
  
 


Modified: rt/branches/PLATANO-EXPERIMENTAL/html/Ticket/Elements/ShowHistory
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/html/Ticket/Elements/ShowHistory	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL/html/Ticket/Elements/ShowHistory	Fri Jan 14 03:40:48 2005
@@ -131,9 +131,7 @@
 my $Transactions = new RT::Transactions($session{'CurrentUser'});
 if ($Tickets) {
     while (my $t = $Tickets->Next) {
-	$Transactions->Limit(FIELD => 'Ticket',
-			     OPERATOR => '=',
-			     VALUE => $t->Id);
+	$Transactions->LimitToTicket($t->id);
     }
 } else {
     $Transactions = $Ticket->Transactions;

Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm	Fri Jan 14 03:40:48 2005
@@ -150,6 +150,7 @@
 use RT::Date;
 use RT::CustomFields;
 use RT::Tickets;
+use RT::Transactions;
 use RT::URI::fsck_com_rt;
 use RT::URI;
 use MIME::Entity;
@@ -3563,27 +3564,11 @@
 sub Transactions {
     my $self = shift;
 
-    use RT::Transactions;
     my $transactions = RT::Transactions->new( $self->CurrentUser );
 
     #If the user has no rights, return an empty object
     if ( $self->CurrentUserHasRight('ShowTicket') ) {
-        my $tickets = $transactions->NewAlias('Tickets');
-        $transactions->Join(
-            ALIAS1 => 'main',
-            FIELD1 => 'ObjectId',
-            ALIAS2 => $tickets,
-            FIELD2 => 'id'
-        );
-        $transactions->Limit(
-            ALIAS => $tickets,
-            FIELD => 'EffectiveId',
-            VALUE => $self->id()
-        );
-	$transactions->Limit(
-	    FIELD    => 'ObjectType',
-	    VALUE    => ref($self),
-	);
+        $transactions->LimitToTicket($self->id);
 
         # if the user may not see comments do not return them
         unless ( $self->CurrentUserHasRight('ShowTicketComments') ) {

Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Transactions_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Transactions_Overlay.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Transactions_Overlay.pm	Fri Jan 14 03:40:48 2005
@@ -112,6 +112,48 @@
 
 }
 
+
+
+=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;


More information about the Rt-commit mailing list