[rt-users] Searching by CurrentUser with QueryBuilder
Ole Craig
ocraig at stillsecure.com
Fri Jul 21 03:23:31 EDT 2006
On Wed, 2006-07-19 at 10:50 -0600, Ole Craig wrote:
> On Tue, 2006-07-11 at 10:13 -0400, Drew Taylor wrote:
> > Thanks! That did the trick.
> >
> [...]
> > > I have a fresh 3.6.0 installation we're customizing. We'd like to
> > > create a saved search that searches for "Owner = '$RT::CurrentUser'"
> > > (as opposed to a static username like "Owner = 'drew'"), but this
> > > particular syntax doesn't work. Is this possible? If not, where would
> > > I start to add this feature - we'd REALLY like to have it. :-)
> > >
> >
> > Try: Owner = '__CurrentUser__'
>
> I just created a test search under 3.6.0, and it doesn't seem to be
> giving me joy. Am I missing something here? The only search term is
>
>
> Owner = '__CurrentUser__'
>
> and I get zero results.
>
> (I own 20+ open tickets at the moment.)
>
> This system was upgraded from 3.6.0rc0 through pre1/pre2/pre3 before
> getting to the release version (I was impatient :-) so I suppose
> something may have gotten bollixed during one of the upgrades... any
> ideas where I should be checking?
The only place in the entire tree where __CurrentUser__ crops up
(aside from initialdata) is in /share/html/Elements/ShowSearch, which
only seems to be used for building the RT-at-a-glance page. In order to
get what I wanted working for my installation, I had to make the
following changes, and after playing with it for awhile I can't
understand how the previous posters are getting results at all...
---- cut here 8< ----
diff -NauBb share/html/Search/Results.html local/html/Search/Results.html
--- share/html/Search/Results.html 2006-01-19 20:50:58.000000000 -0700
+++ local/html/Search/Results.html 2006-07-20 22:53:43.000000000 -0600
@@ -54,7 +54,7 @@
OrderBy => $OrderBy,
Order => $Order &>
<& /Elements/TicketList,
- Query => $Query,
+ Query => $NewQuery,
AllowSorting => 1,
OrderBy => $OrderBy,
Order => $Order,
@@ -113,11 +114,14 @@
$Rows ||= 50;
}
+# use __CurrentUser__ in searches without clobbering the original string
+my $NewQuery;
+($NewQuery = $Query) =~ s/__CurrentUser__/$session{'CurrentUser'}->Name/ge;
my ($title, $ticketcount);
$session{'i'}++;
$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ;
-$session{'tickets'}->FromSQL($Query) if ($Query);
+$session{'tickets'}->FromSQL($NewQuery) if ($NewQuery);
if ($OrderBy =~ /\|/) {
# Multiple Sorts
---- cut here 8< ----
--
/Ole Craig
Security Engineer
303-381-3802 (main support hotline)
303-381-3824 (my direct line)
303-381-3801 (fax)
www.stillsecure.com
. . .
More information about the rt-users
mailing list