[rt-users] Solution to displaying tickets requested by user's groups

Weqaar Janjua weqaar at yahoo.com
Wed Oct 19 15:28:10 EDT 2005


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__</a>/TITLE:#',

	'<a
href=\"$RT::WebPath/Ticket/Display.html?id=__id__\">__Subject__</a>/TITLE:Subject',

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

<BR>

% $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



More information about the rt-users mailing list