also hide unreplied status for Deleted tickets, #41670
[freeside.git] / rt / lib / RT / Search / UnrepliedTickets.pm
index a996901..0328983 100644 (file)
@@ -6,9 +6,9 @@
 
 =head1 DESCRIPTION
 
-Find all unresolved tickets owned by the current user where the last correspondence
-from a requestor (or ticket creation) is more recent than the last
-correspondence from a non-requestor (if there is any).
+Find all unresolved tickets owned by the current user where the last
+correspondence from a requestor (or ticket creation) is more recent than the
+last correspondence from a non-requestor (if there is any).
 
 =head1 METHODS
 
@@ -30,15 +30,22 @@ sub Prepare  {
   my $self = shift;
 
   my $TicketsObj = $self->TicketsObj;
-  $TicketsObj->Limit(
-    FIELD => 'Owner',
-    VALUE => $TicketsObj->CurrentUser->id
-  );
-  $TicketsObj->Limit(
-    FIELD => 'Status',
-    OPERATOR => '!=',
-    VALUE => 'resolved'
-  );
+  # if SystemUser does this search (as in QueueSummaryByLifecycle), they
+  # should get all tickets regardless of ownership
+  if ($TicketsObj->CurrentUser->id != RT->SystemUser->id) {
+    $TicketsObj->Limit(
+      FIELD => 'Owner',
+      VALUE => $TicketsObj->CurrentUser->id
+    );
+  }
+  foreach my $status (qw(resolved rejected deleted)) {
+    $TicketsObj->Limit(
+      FIELD => 'Status',
+      OPERATOR => '!=',
+      ENTRYAGGREGATOR => 'AND',
+      VALUE => $status,
+    );
+  }
   my $txn_alias = $TicketsObj->JoinTransactions;
   $TicketsObj->Limit(
     ALIAS => $txn_alias,