[rt-users] Top N lists

Colmer, Philip Philip.Colmer at proquest.co.uk
Wed Aug 13 10:29:09 EDT 2003


I've tried to do some more research into why my "Top N unassigned" module
doesn't work properly if you don't have access to all of the queues on the
system.

Here is the test scenario:

2 queues
4 tickets - 2 in each queue, alternating IDs
2 groups - one for adminning each queue
3 users - one in each group and a third in both

If you have the Top N module configured to show only 2 jobs:

User		Desired behaviour		Actual behaviour
Both		Show top 2 jobs		Shows top 2 jobs
Q1		Show top 2 Q1 jobs	Shows first Q1 job
Q2		Show top 2 Q2 jobs	Shows first Q2 job

I hope that is clear :-)

My initial thinking was that RT::Tickets wasn't limiting the set of tickets
to those that the current user could admin, but further checking of the code
shows that it doesn't work like that.

The filtering of which tickets the user sees is actually done by the Next
method. The next ticket is retrieved through $self->SUPER::Next(); and then
checked. If the user has "ShowTicket" rights, the ticket is returned
otherwise the method recurses to get the next ticket that the user can see
or the end of the line.

It is the recursion that is where this appears to go wrong. By adding
debugging to the code, it looks as if the next ticket retrieved through the
recursion process doesn't work and it just returns undef. By comparison, if
you comment out the permission testing, all records do get returned (albeit
some of them aren't accessible by the user because of permissions).

Unfortunately, my Perl isn't up to figuring out why the recursion isn't
working, so I'm hoping that someone can help me out here!

I also had an idea that I might be able to solve the problem by using
"LimitQueue" first off to explicitly restrict the ticket list by specifying
which queues the user has access to, but that doesn't work either!

I've tried adding this to the INIT code for the module:

My $MyQueues;
$RT::Logger->debug("Checking queues\n");
$MyQueues = new RT::Queues ($session{'CurrentUser'});
while (my $Queue = $MyQueues->Next) {
        $RT::Logger->debug("Got queue ".$Queue->Name);
}

But the debugging code that says "Got queue" is never used. The only way I
can get any names out is by adding

$MyQueues->UnLimit

before the while loop, but then it outputs ALL of the queue names,
regardless of whether or not you've got See Queue permission.

Am I overlooking something or is there a problem with the RT code?

--Philip

--
Philip Colmer, MBCS CEng CCSE           Tel: 01223 271223
I.T. Manager                            Fax: 01223 215513
ProQuest Information & Learning
The Quorum, Barnwell Road, Cambridge, CB5 8SW




More information about the rt-users mailing list