[rt-users] RT At A Glance

Jason Long jlong at messiah.edu
Fri Sep 21 09:38:32 EDT 2007


>>>> "slamp slamp" <slackamp at gmail.com> 9/20/07 11:01 AM >>>
>Can anyone point me on how to build a search to search for unowned
>tickets but only to the groups you belong to?
>
>we have multiple groups, one group has access to every queue and when
>i build a search for all unowned tickets, all tickets from different
>queues are shown. the reason for this is we want this one group to
>manage all other groups/queues but not necessarily the tickets
>themselves.



The following patch may or may not be helpful... I created this a while ago
to address a similar complaint about the "newest unowned tickets" list. You
could use the "Take" right to determine which queues different groups should
see.
Jason



>>> Jason Long <jlong at messiah.edu> 9/21/07 8:43 AM >>>
This patch changes the behavior of the "newest unowned tickets list"
to limit the query to queues where the user has the "take" right.

It's kind of a hack, since it is logic that triggers based on the
name of the query: "Unowned Tickets".

This solves two problems:

1. formerly, if the 10 newest tickets were tickets the user couldn't
   see, the "10 newest unowned tickets" box would be blank, even
   if there were other tickets that he could see

2. formerly, the "10 newest unowned tickets" would display tickets in
   all queues the current user could see, not just queues that the
   current user might be interested in

This creates a potential new issue:

* if your RT system has many queues, and the current user can "take"
  tickets in many of those queues, you may experience performance
  issues.
---

 html/Elements/ShowSearch |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/html/Elements/ShowSearch b/html/Elements/ShowSearch
index ded865b..d50a8b9 100644
--- a/html/Elements/ShowSearch
+++ b/html/Elements/ShowSearch
@@ -93,6 +93,28 @@ if ($SavedSearch) {
     }
 
     $SearchArg = $user->Preferences( $search, $search->Content );
+    if ($Name eq "Unowned Tickets")
+    {
+       # list of queues on system
+       my $queues = RT::Queues->new($session{CurrentUser});
+       $queues->UnLimit;
+       my @queues;
+       while (my $queue = $queues->Next) { push @queues, $queue; };
+
+       # determine which queues the current user has "TakeTicket" right
+       my $principal = $session{CurrentUser}->PrincipalObj;
+       @queues = grep { $principal->HasRight(
+                               Object => $_,
+                               Right => "TakeTicket") } @queues;
+       if (@queues)
+       {
+               $SearchArg->{'Query'} .=
+                       ' AND ( '
+                       . join(' OR ',
+                       map { "'Queue' = '" . $_->Name . "'" } @queues)
+                       . ' ) ';
+       }
+    }
     $customize = $RT::WebPath . '/Prefs/Search.html?'
         . $m->comp( '/Elements/QueryString',
         name => ref($search) . '-' . $search->Id );




More information about the rt-users mailing list