+my $query;
+
+if ( $Ticket and $Ticket->CurrentUserHasRight('SeeQueue') ) {
+ # Grab the queue name anyway if the current user can
+ # see the queue based on his role for this ticket
+ $value = $QueueObj->__Value('Name');
+ if ( $session{CurrentUser}->Privileged ) {
+ my @statuses = $QueueObj->ActiveStatusArray();
+ s{(['\\])}{\\$1}g for @statuses;
+ $query = "Queue = " . $QueueObj->id . " AND ( ". join(" OR ", map {"Status = '$_'"} @statuses) . " )";
+ }
+}
+