[Rt-devel] Re: [rt-users] Modification: Showing tickets in queues you watch on the front page

Andy Moran andy at wildbrain.com
Wed Oct 5 17:19:27 EDT 2005



Okay I figured this out myself after looking through some other RT code
and brushing up my perl syntax.

I have attached  the code to list all unowned unresolved tickets in all
the queues that the current logged in user is a watcher of.   Drop this
"MyQueues" into /usr/local/rt3/local/html/Elements/MyQueues and copy
/usr/local/rt3/share/html/index.html to
/usr/local/rt3/local/html/index.html and add:
<& /Elements/MyQueues &>
<BR>

where appropriate.


Andy Moran wrote:
> Okay I didn't get any response on this so I'm gonna include rt-devel and
> see if I get any bites.
> 
> I found code to do it for RT2, but it breaks under Rt3:
> 
> my $userEmail = $session{'CurrentUser'}->EmailAddress;
> my $queueCount = 0;
> my $Queues = new RT::Queues($session{'CurrentUser'});
> $Queues->UnLimit();
> 
> my $Tickets = new RT::Tickets ($session{'CurrentUser'});
> $Tickets->ClearRestrictions;
> $Tickets->LimitOwner(VALUE => "Nobody");
> $Tickets->LimitStatus(VALUE => "resolved", OPERATOR => '!=');
> $Tickets->LimitStatus(VALUE => "dead", OPERATOR => '!=');
> 
> while (my $queue = $Queues->Next) {
>                  my $watcherEmails = $queue->Watchers()->EmailsAsString();
>      next if $watcherEmails !~ /\b$userEmail/;
>      $queueCount++;
>      $Tickets->LimitQueue(VALUE => $queue->id);
> }
> 
> $Tickets->OrderBy(FIELD => 'Priority', ORDER => 'DESC');
> $Tickets->RowsPerPage(25);
> 
> 
> The Rt3 way seems to be about using query strings.. but I'm missing the
> part where I'm searching all queues that the current user is a watcher on.
> 
> Any help would be awesome.. thanks!
> 
> --Andy
> 
> 
> 
> Andy Moran wrote:
> 
>>Hi guys,
>>
>>I'm setting up an Rt3 instance.  I'd like to change the front page for
>>privileged users so instead of showing "X newest onowned tickets", it
>>only shows "X newest unowned tickets in the queues I watch.."
>>
>>I know I need to copy share/html/Elements/MyRequests to
>>local/html/Elements/MyRequests and modify it somehow to only show queues
>>that the person logged in is a watcher on.   But I don't wanna learn the
>>entire RT API to just change this one bit.. If anyone could tell me the
>>code I need, I'd be grateful.. thanks!
>>
>>
>>
>>
>>
>>_______________________________________________
>>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>
>>Be sure to check out the RT Wiki at http://wiki.bestpractical.com
>>
>>Buy your copy of our new book, RT Essentials, today! 
>>
>>Download a free sample chapter from http://rtbook.bestpractical.com
>>
> 
> 
> _______________________________________________
> Rt-devel mailing list
> Rt-devel at lists.bestpractical.com
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> 

-------------- next part --------------
%# MyQueues 2.0 -- Andy Moran 10/05/2005

<&|/Elements/TitleBox, 
        title => loc("[_1] newest unowned tickets in the queues I watch", $rows),
	title_href => "Search/Results.html".$QueryString &>
<& /Elements/TicketList, 
        Format => "'<a href=\"$RT::WebPath/Ticket/Display.html?id=__id__\">__id__</a>/TITLE:#', '<a href=\"$RT::WebPath/Ticket/Display.html?id=__id__\">__Subject__</a>/TITLE:Subject', QueueName, ExtendedStatus, CreatedRelative, '<A HREF=\"$RT::WebPath/Ticket/Display.html?Action=Take&id=__id__\">".loc('Take')."</a>/TITLE:&nbsp;' ",
        Query => $Query,
        OrderBy => 'Created',
        Order => 'DESC',
        ShowNavigation => 0,
        Rows => $rows

        &>
</&>

<%init>

my $rows = $RT::MyRequestsLength;

my $Queues = RT::Queues->new($session{'CurrentUser'}); 
my $userEmail = $session{'CurrentUser'}->EmailAddress;
$Queues->UnLimit();
my @QueueList = ();
while (my $queue = $Queues->Next) {
    my $watcherEmails = $queue->AdminCcAddresses();
    next if $watcherEmails !~ /\b$userEmail/;
    next unless ($queue->CurrentUserHasRight('ShowTicket'));
    push(@QueueList, $queue->Name);
}

my $Query = "";

if (scalar(@QueueList) == 0) {
    $Query = "Queue = 'None'";
} else {
    $Query = "Owner = 'Nobody' AND ( Status = 'new' OR Status = 'open') AND ( Queue = '". join("' OR Queue = '", @QueueList) . "')";

}

my $QueryString = "";
$QueryString = '?' . $m->comp('/Elements/QueryString', 
                              Query => $Query,
                              Order => 'DESC',
                              OrderBy => 'Priority') if ($Query);

</%init>



More information about the Rt-devel mailing list