[rt-users] Searching by CurrentUser with QueryBuilder

Todd Chapman todd at chaka.net
Mon Jul 31 23:51:51 EDT 2006


In RT::Tickets::_WatcherLimit, try changing:

$o->Load($value);

to:

$o->Load( $value =~ /__CurrentUser__/ ? $self->CurrentUser->UserObj->Name : $value );


(that's in lib/RT/Tickets_Ovelay.pm)

-Todd

On Mon, Jul 31, 2006 at 08:37:50PM -0700, David Smithson wrote:
> And I was just about to say that I only found the regexp in ShowSearch:
> 
> $SearchArg->{'Query'} =~
> s/__CurrentUser__/$session{'CurrentUser'}->Id/ge;
> 
> I confirmed that you are right.  The saved search *does* work from the
> ataglance page.
> 
> I was actually trying to do some customization of the Quicksearch doodad
> which resulted in lots of trying and nothing doing -- if that makes any
> sense.  Clearly I have to put some thought into the context before I go
> mucking about.  So, in /Elements/Quicksearch under local, I have this:
> 
> <div class="ticket-overview">
> <&|/Widgets/TitleBox, title => loc("Quick search"), bodyclass => "",
>    titleright => loc("Edit"), titleright_href =>
> $RT::WebPath.'/Prefs/Quicksearch.html' &>
> <& /Elements/QueueSummary,
>    cache => 'quick_search_queues',
>    queue_filter => sub { $_->CurrentUserHasRight('ShowTicket') &&
> !exists $unwanted->{$_->Name} },
>    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 => "Owner = '__CurrentUser__'", name => loc
> ('mine') } ] &>
> </&>
> </div>
> <%INIT>
> my $unwanted =
> $session{'CurrentUser'}->UserObj->Preferences('QuickSearch', {});
> </%INIT>
> 
> Hah!  If only it were that simple.
> 
> David Smithson
> ________________________________
> 
> CLICK HERE FOR ONLINE SUPPORT
> 
> -----Original Message-----
> From: Todd Chapman [mailto:todd at chaka.net] 
> Sent: Monday, July 31, 2006 8:30 PM
> To: David Smithson
> Cc: Drew Taylor; rt-users at lists.bestpractical.com
> Subject: Re: [rt-users] Searching by CurrentUser with QueryBuilder
> 
> I think the problem is that the replacement of __CurrentUser__
> with the user id is done in /Elements/ShowSearch. That is
> only used for showing searches on the RT homepage. The link
> at the top of the search is to the query builder with the
> value replaced. Loading it from saved searches isn't going to
> work.
> 
> It would be better if the replacement was done in the
> TicketSQL parser.
> 
> -Todd
> 
> On Mon, Jul 31, 2006 at 08:17:03PM -0700, David Smithson wrote:
> > Hey, why isn't "Owner = '__CurrentUser__'" working for me?  I can't
> > figure this one out.  It's pretty simple it seems, but __CurrentUser__
> > isn't getting replaced in the query:
> > 
> > Queue = 'General' AND Owner = '__CurrentUser__'
> > 
> > What am I missing?
> > 
> > David Smithson
> > ________________________________
> > 



More information about the rt-users mailing list