Solution to displaying tickets requested by user's groups

I have the following code in file
’/Elements/GrpRequests’. It displays the ticket’s
requested by Logged-In user’s groups. It displays all
the tickets rqeuested by all the groups the user has
membership to.

#-------------START------------------------------
% my $j = 0;

% while ( $j < @ids ) {

<&|/Elements/TitleBox,
title => (“Group $idsName[$j] ticket
requests”),
title_href => “Search/Results.html”.$QStrings[$j] &>
<& /Elements/TicketList,
Format => “’<a
href=”$RT::WebPath/Ticket/Display.html?id=id">id/TITLE:#’,

'<a

href="$RT::WebPath/Ticket/Display.html?id=id">Subject/TITLE:Subject’,

QueueName, ExtendedStatus, CreatedRelative, ' ",
    Query => $Queries[$j],
    OrderBy => 'Created',
    Order => 'DESC',
    ShowNavigation => 0,
    Rows => $rows
    &>

</&>


% $j = $j + 1;

% }

<%init>
my $Groups = RT::Groups->new($session{‘CurrentUser’});
$Groups->LimitToUserDefinedGroups();
$Groups->WithMember(PrincipalId =>
$session{‘CurrentUser’}->Id);

my $rows = 10;

my $Queues = RT::Queues->new($session{‘CurrentUser’});
$Queues->UnLimit();

my $QueuesListing = ‘’;

my @ids;
my @idsName;
my $Group;

while ( $Group = $Groups->Next ) {
push @ids, $Group->Id;
push @idsName, $Group->Name;
}

while (my $queue = $Queues->Next) {
next unless
($queue->CurrentUserHasRight(‘ShowTicket’));
if ($QueuesListing ne ‘’) {
$QueuesListing .= " OR Queue = ";
} else {
$QueuesListing = “Queue = “;
}
$QueuesListing .= “’”.$queue->Name.”’”;
}

my @Queries;
my @QStrings;
my $i = 0;
my $size = @ids;

while ( $i < $size) {
my $Query = “
Requestor != '”.$session{‘CurrentUser’}->Id."'
AND ( Status = ‘new’ OR Status = ‘open’ OR Status =
‘stalled’ )
AND ( RequestorGroup = ‘$ids[$i]’ )
AND ( " . $QueuesListing . " )
";
push @Queries, $Query;

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

push @QStrings, $QueryString;

$i = $i + 1;

}

</%init>

#-------------END------------------------------

Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com

You should add this to the wiki (wiki.bestpractical.com) under
Contributions.

Joby Walker
ITI SSG, University of Washington

Weqaar Janjua wrote: