[Rt-commit] r4241 - in rtir/branches/1.9-EXPERIMENTAL: . lib/RT/Action

ruz at bestpractical.com ruz at bestpractical.com
Sun Dec 4 19:08:29 EST 2005


Author: ruz
Date: Sun Dec  4 19:08:28 2005
New Revision: 4241

Modified:
   rtir/branches/1.9-EXPERIMENTAL/   (props changed)
   rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetDueIncident.pm
Log:
 r420 at cubic-pc:  cubic | 2005-12-05 03:09:09 +0300
  r399 at cubic-pc:  cubic | 2005-12-04 23:40:05 +0300
  * search for any active status
 


Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetDueIncident.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetDueIncident.pm	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetDueIncident.pm	Sun Dec  4 19:08:28 2005
@@ -76,28 +76,34 @@
     my $self = shift;
 
     my $incident;
-    if ($self->TransactionObj->Type eq 'DeleteLink') {
-	my $uri = new RT::URI($self->CurrentUser);
-	$uri->FromURI($self->TransactionObj->OldValue);
-	$incident = $uri->Object;
+    if ( $self->TransactionObj->Type eq 'DeleteLink' ) {
+        my $uri = new RT::URI( $self->CurrentUser );
+        $uri->FromURI( $self->TransactionObj->OldValue );
+        $incident = $uri->Object;
     } else {
-	my $incidents = new RT::Tickets($self->CurrentUser);
-	$incidents->FromSQL("Queue = 'Incidents' AND HasMember = " . $self->TicketObj->id);
-
-	$incident = $incidents->First;
+        my $incidents = new RT::Tickets($self->CurrentUser);
+        $incidents->FromSQL("Queue = 'Incidents' AND HasMember = " . $self->TicketObj->id);
+        $incidents->RowsPerPage(1);
+        $incident = $incidents->First;
     }
+    return 1 unless $incident;
 
-    if ($incident) {
-	my $children = new RT::Tickets($self->CurrentUser);
-	$children->FromSQL("(Queue = 'Incident Reports' OR Queue = 'Investigations' OR Queue = 'Blocks') AND (Status = 'new' OR Status = 'open') AND MemberOf = " . $incident->Id);
-	$children->OrderBy(FIELD => 'Due', ORDER => 'ASC');
-
-	my $mostdue = $children->First();
-	if ($mostdue) {
-	    $incident->SetDue($mostdue->DueObj->ISO);
-	} else {
-	    $incident->SetDue(0);
-	}
+    my $query =  "(Queue = 'Incident Reports'"
+                ." OR Queue = 'Investigations'"
+                ." OR Queue = 'Blocks'"
+                .") AND MemberOf = " . $$incident->Id
+                ." AND ("
+                . join( " OR ", map "Status = '$_'", @RT::ActiveStatus )
+                .")";
+    my $children = new RT::Tickets($self->CurrentUser);
+    $children->FromSQL( $query );
+    $children->OrderBy( FIELD => 'Due', ORDER => 'ASC' );
+    $children->RowsPerPage(1);
+    my $mostdue = $children->First;
+    if ($mostdue) {
+        $incident->SetDue($mostdue->DueObj->ISO);
+    } else {
+        $incident->SetDue(0);
     }
 
     return 1;


More information about the Rt-commit mailing list