WatcherSummary

From Request Tracker Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Based on QueueSummary, aka the "Quick search" box on the RT at a glance page, this gives you a grid showing how many tickets the user is listed as Requestor, Cc, Owner, or AdminCc of, and what the status of the ticket is, with links to the searches showing the actual tickets.

It looks something like this:

Watched Tickets

<strong>Type</strong> <strong>new</strong> <strong>open</strong> <strong>stalled</strong> <strong>resolved</strong> <strong>rejected</strong>
Requestor 45 2 ‎0 579 ‎0
Owner ‎0 ‎0 ‎0 49 ‎0
Cc ‎0 ‎0 ‎0 ‎0 ‎0

| AdminCc | ‎0 | ‎0 | ‎0 | 1 | ‎0 |

Put this into html/Elements/WatcherSummary:

<table border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
       <th class="collection-as-table"><&|/l&>Type</&></th>
% for my $condition (@$conditions) {
       <th class="collection-as-table"><% $condition->{name} %></th>
% }
</tr>
% my $i;
% for my $type (@types) {
%   $i++;
%   my $type_cond = "$type.Id = ".$UserObj->Id;
%   my $all_q = $type_cond;
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td><a href="<% $RT::WebPath%>/Search/Results.html?Query=<%$all_q%>"><%$type%></a></td>
%   for my $condition (@$conditions) {
%       my $Tickets = RT::Tickets->new($session{'CurrentUser'});
%       $Tickets->FromSQL($type_cond." AND ".$condition->{cond});
<td align="right"><a href="<% $RT::WebPath%>/Search/Results.html?Query=<%$type_cond." AND ".$condition->{cond}%>"><% $Tickets->Count %></a></td>
%   }
</tr>
% }
</table>
<%INIT>
my @types = ('Requestor', 'Owner', 'Cc', 'AdminCc');
</%INIT>
<%ARGS>
$UserObj => undef
$conditions => ()
</%ARGS>


I like to use it in Admin/Users/Memberships.html, like so:

--- share/html/Admin/Users/Memberships.html     2006-06-19 15:44:04.000000000 -0700
+++ local/html/Admin/Users/Memberships.html     2006-09-20 16:37:26.000000000 -0700
@@ -54,6 +54,17 @@

 <& /Elements/ShowMemberships, UserObj => $UserObj &>

+<&| /Widgets/TitleBox, title => loc('Watched Tickets'),
+    title_href => "$RT::WebPath/Search/Results.html?Query=Watcher.Id=".$UserObj->Id &>
+<& /Elements/WatcherSummary,
+   UserObj => $UserObj,
+   conditions => [ {cond => "Status = 'new'",  name => loc ('new') },
+                  {cond => "Status = 'open'", name => loc ('open') },
+                  {cond => "Status = 'stalled'", name => loc ('stalled') },
+                  {cond => "Status = 'resolved'", name => loc ('resolved') },
+                  {cond => "Status = 'rejected'", name => loc ('rejected') }] &>
+</&>
+
 <%INIT>
 my $UserObj = RT::User->new($session{'CurrentUser'});
 $UserObj->Load($id) || Abort("Couldn't load user '$id'");