[Rt-commit] r2722 - in rt/branches/PLATANO-EXPERIMENTAL-CSS: . html/Search lib/RT/Search

jesse at bestpractical.com jesse at bestpractical.com
Sat Apr 16 04:19:08 EDT 2005


Author: jesse
Date: Sat Apr 16 04:19:08 2005
New Revision: 2722

Modified:
   rt/branches/PLATANO-EXPERIMENTAL-CSS/   (props changed)
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Simple.html
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Search/Quick.pm
Log:
 r13111 at hualien:  jesse | 2005-04-16 03:12:30 -0400
  r13010 at hualien:  jesse | 2005-04-16 02:27:19 -0400
   r12751 at hualien:  jesse | 2005-04-12 09:50:05 -0400
   checkpoint
  
 


Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Simple.html
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Simple.html	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Simple.html	Sat Apr 16 04:19:08 2005
@@ -43,32 +43,20 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title &>
+<& /Elements/Header, title => $title &>
 <& /Ticket/Elements/Tabs, 
-    current_tab => "Search/Quick.html?q=".$ARGS{"q"}, 
+    current_tab => "Search/Simple.html"
 &>
 
 <DIV align="center">
 
-<& /Elements/TitleBoxStart, width=> "40%", titleright => loc("RT [_1]", $RT::VERSION), title => loc('Search') , contentbg=>"#cccccc" &>
-<FORM ACTION="Quick.html">
-<table width="100%" cellpadding="5">
-    <tr>
-        <td width="100%">
-            <input name="q">
-        </td>
-    </tr>
-    <tr>
-        <td align="right">
-            <input type="submit" Value="<&|/l&>Search</&>">
-        </td>
-    </td>
-</table>
+<FORM ACTION="Simple.html" METHOD="GET">
+            <input name="q" size="60"><input type="submit" Value="<&|/l&>Search</&>">
 </FORM>
-<&/Elements/TitleBoxEnd&>
+</&>
 
 <%INIT>
-my $title = loc("Quick Search");
+my $title = loc("Search for tickets");
 use RT::Search::Quick;
 
 if ( $ARGS{"q"}) {
@@ -77,6 +65,7 @@
                                          TicketsObj => $tickets);
 
     $m->comp( "Results.html", Query   => $search->QueryToSQL());
+    $m->comp( "/Elements/Footer" );
     $m->abort();
 }
 </%INIT>

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Search/Quick.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Search/Quick.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Search/Quick.pm	Sat Apr 16 04:19:08 2005
@@ -84,17 +84,20 @@
   my $self = shift;
   my $query = shift || $self->Argument;
   my @keywords = split /\s+/, $query;
-  my @tql_clauses;
+  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+$/) {
-      #    $self->TicketsObj->Limit(FIELD => "id", VALUE => $key);
-      #    last;
-      #}
+   if ($key =~ m/^\d+$/) {
+        push @id_clauses, "id = '$key'";
+   }
+
+    elsif ($key =~ /\w+\@\w+/) {
+        push @user_clauses, "Requestor LIKE '$key'";
+    }
 
       # Is there a queue named $key?
-      if ($Queue =  RT::Queue->new($self->TicketsObj->CurrentUser) 
+      elsif ($Queue =  RT::Queue->new($self->TicketsObj->CurrentUser) 
               and $Queue->Load($key)) {
           push @tql_clauses, "Queue = '". $Queue->Name. "'";
       } 
@@ -102,7 +105,7 @@
       elsif ($User = RT::User->new($self->TicketsObj->CurrentUser)
               and $User->Load($key)
               and $User->Privileged) {
-          push @tql_clauses, "Owner = '". $User->Name. "'";
+          push @owner_clauses, "Owner = '". $User->Name. "'";
       } 
       # Else, content must contain $key
       else {
@@ -110,6 +113,12 @@
           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;
 }
 # }}}
@@ -118,6 +127,9 @@
 sub Prepare  {
   my $self = shift;
   my $tql = $self->QueryToSQL($self->Argument);
+
+  $RT::Logger->crit($tql);
+
   $self->TicketsObj->FromSQL($tql);
   return(1);
 }


More information about the Rt-commit mailing list