[Rt-commit] r2777 - in rt/branches/QUEBEC-EXPERIMENTAL: .
html/Search lib/RT/Search lib/t/regression
jesse at bestpractical.com
jesse at bestpractical.com
Mon Apr 18 17:58:33 EDT 2005
Author: jesse
Date: Mon Apr 18 17:58:32 2005
New Revision: 2777
Modified:
rt/branches/QUEBEC-EXPERIMENTAL/ (props changed)
rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Simple.html
rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Search/Googleish.pm
rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/19quicksearch.t
Log:
r13255 at hualien: jesse | 2005-04-18 17:48:18 -0400
* Quicksearch updates to add Status search and Switch content
searches to subject searches
Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Simple.html
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Simple.html (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Simple.html Mon Apr 18 17:58:32 2005
@@ -51,8 +51,8 @@
<DIV align="center">
<FORM ACTION="Simple.html" METHOD="GET">
-<p>Search for tickets. Enter <b>id</b> numbers,<b>queues</b> by name, Owners by <b>username</b> and Requestors by <b>email address</b>.</p>
-<p>RT will look for anything else you enter in ticket bodies and attachments.</p>
+<p><&|/l&>Search for tickets. Enter <b>id</b> numbers,<b>queues</b> by name, ticket statuses by <b>name</b>, owners by <b>username</b> and requestors by <b>email address</b>.</&></p>
+<p><&|/l&>RT will look for anything else you enter in ticket subjects.</&></p>
<br>
<br>
Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Search/Googleish.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Search/Googleish.pm (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Search/Googleish.pm Mon Apr 18 17:58:32 2005
@@ -81,45 +81,64 @@
# {{{ sub QueryToSQL
sub QueryToSQL {
- my $self = shift;
- my $query = shift || $self->Argument;
- my @keywords = split /\s+/, $query;
- my (@tql_clauses, @owner_clauses, @queue_clauses, @user_clauses, @id_clauses);
- my ($Queue, $User);
- for my $key (@keywords) {
- # Is this a ticket number? If so, go to it.
- if ($key =~ m/^\d+$/) {
- push @id_clauses, "id = '$key'";
- }
-
- elsif ($key =~ /\w+\@\w+/) {
- push @user_clauses, "Requestor LIKE '$key'";
+ my $self = shift;
+ my $query = shift || $self->Argument;
+ my @keywords = split /\s+/, $query;
+ my (
+ @tql_clauses, @owner_clauses, @queue_clauses,
+ @user_clauses, @id_clauses, @status_clauses
+ );
+ my ( $Queue, $User );
+ for my $key (@keywords) {
+
+ # Is this a ticket number? If so, go to it.
+ if ( $key =~ m/^\d+$/ ) {
+ push @id_clauses, "id = '$key'";
+ }
+
+ elsif ( $key =~ /\w+\@\w+/ ) {
+ push @user_clauses, "Requestor LIKE '$key'";
+ }
+
+ # Is there a status with this name?
+ elsif (
+ $Queue = RT::Queue->new( $self->TicketsObj->CurrentUser )
+ and $Queue->IsValidStatus($key)
+ )
+ {
+ push @status_clauses, "Status = '" . $key . "'";
+ }
+
+ # Is there a owner named $key?
+ # Is there a queue named $key?
+ elsif ( $Queue = RT::Queue->new( $self->TicketsObj->CurrentUser )
+ and $Queue->Load($key) )
+ {
+ push @queue_clauses, "Queue = '" . $Queue->Name . "'";
+ }
+
+ # Is there a owner named $key?
+ elsif ( $User = RT::User->new( $self->TicketsObj->CurrentUser )
+ and $User->Load($key)
+ and $User->Privileged )
+ {
+ push @owner_clauses, "Owner = '" . $User->Name . "'";
+ }
+
+ # Else, content must contain $key
+ else {
+ $key =~ s/['\\].*//;
+ push @tql_clauses, "Subject LIKE '$key'";
+ }
}
- # Is there a queue named $key?
- elsif ($Queue = RT::Queue->new($self->TicketsObj->CurrentUser)
- and $Queue->Load($key)) {
- push @tql_clauses, "Queue = '". $Queue->Name. "'";
- }
- # Is there a owner named $key?
- elsif ($User = RT::User->new($self->TicketsObj->CurrentUser)
- and $User->Load($key)
- and $User->Privileged) {
- push @owner_clauses, "Owner = '". $User->Name. "'";
- }
- # Else, content must contain $key
- else {
- $key =~ s/['\\].*//;
- push @tql_clauses, "Content LIKE '$key'";
- }
- }
-
- push @tql_clauses, join( " OR " , @id_clauses);
- push @tql_clauses, join( " OR " , @owner_clauses);
- push @tql_clauses, join( " OR " , @user_clauses);
- push @tql_clauses, join( " OR " , @queue_clauses) ;
- @tql_clauses =grep { $_ ? "( $_ )" : undef } @tql_clauses;
- return join " AND ", @tql_clauses;
+ push @tql_clauses, join( " OR ", @id_clauses );
+ push @tql_clauses, join( " OR ", @owner_clauses );
+ push @tql_clauses, join( " OR ", @status_clauses );
+ push @tql_clauses, join( " OR ", @user_clauses );
+ push @tql_clauses, join( " OR ", @queue_clauses );
+ @tql_clauses = grep { $_ ? "( $_ )" : undef } @tql_clauses;
+ return join " AND ", @tql_clauses;
}
# }}}
Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/19quicksearch.t
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/19quicksearch.t (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/19quicksearch.t Mon Apr 18 17:58:32 2005
@@ -29,8 +29,8 @@
my @tests = (
$queue => "Queue = '$queue'",
"root $queue" => "Queue = '$queue' AND Owner = 'root'",
- "notauser $queue" => "Content LIKE 'notauser' AND Queue = '$queue'",
- "notauser $queue root" => "Content LIKE 'notauser' AND Queue = '$queue'".
+ "notauser $queue" => "Subject LIKE 'notauser' AND Queue = '$queue'",
+ "notauser $queue root" => "Subject LIKE 'notauser' AND Queue = '$queue'".
" AND Owner = 'root'"
);
More information about the Rt-commit
mailing list