[rt-devel] PATCH: Add SearchLink to config.pm's %WebOptions

Jim Meyer purp at wildbrain.com
Fri May 3 17:54:55 EDT 2002


Howdy!

As previously discussed, here's the patches that allow SearchLink (and
it's various companions) to be specified in config.pm. The syntax of a
config.pm %WebOptions entry which uses this feature is like so:

      { Header => 'Requestor(s)',
         TicketAttribute => 'Requestors->First->OwnerObj->RealName',
         SearchLink => 1,
         SearchType => 'Requestor',
         SearchAttribute => 'Requestors->First->OwnerObj->EmailAddress',
         SearchOperator => 'LIKE',
         ExtraLinks => 
           '&StatusOp=%21%3D&ValueOfStatus=dead&ValueOfStatus=resolved'
         },

The breakdown:

SearchLink: like TicketLink, a value of 1 gets you a base URI beginning;
in this case it's "/Search/Listing.html?NewSearch=1&". Also like
TicketLink, you can set SearchLink to an arbitrary value and that will
be used as the base URI.

SearchType: What type of search you want to do. Valid types are
Priority, Requestor, Queue, Status, Subject, Date and Content; these are
found in the code of RT::Interface::Web.

SearchAttribute: Just like TicketAttribute, this is the evaluable bit
that supplies the proper term to search for. For example, if you're
looking to search on owner, the proper term is OwnerObj->Name; if you're
looking to search on requestor, the proper term is
Requestors->First->OwnerObj->EmailAddress. There is an implied $Ticket->
which is prepended at eval time.

SearchOperator: The usual SQL operator; again you must match it to the
field you're searching on. I've used escaped bits for mine (e.g. %3D
instead of =) but I'm not sure it's necessary and I'm too lazy to test.

ExtraLinks behaves just as before, e.g. it gets pasted onto the end.

Hope this is useful. =]

--j
-- 
Jim Meyer, Geek At Large                              purp at wildbrain.com
-------------- next part --------------
--- WebRT/html/Search/TicketCell	Tue Nov  6 15:07:01 2001
+++ local/WebRT/html/Search/TicketCell	Fri May  3 14:08:55 2002
@@ -7,17 +7,38 @@
 if ($Column->{TicketLink}) {
 	$link = "<A HREF=\"";
 	if ($Column->{TicketLink} == 1 ) {
 		$link .= "../Ticket/Display.html?";
-	}
-	else {
+	} else {
 		$link .= $Column->{TicketLink};
 	}
 
 	$link .= "id=".$Ticket->Id . $Column->{ExtraLinks};
 
 	if ($session{NewWindowOption}) {
-		$link .= "TARGET=\"TicketDisplay".$session{AlwaysNewWindowOption} && (time() . rand(1024))."\" ";
+		$link .= "TARGET=\"TicketDisplay".$session{AlwaysNewWindowOption} && 
+			(time() . rand(1024))."\" ";
+	}
+	$link .= "\">";
+	$endlink = "</a>";
+} elsif ($Column->{SearchLink}) {
+	$link = "<A HREF=\"";
+	if ($Column->{SearchLink} == 1 ) {
+		$link .= "../Search/Listing.html?NewSearch=1&";
+	} else {
+		$link .= $Column->{SearchLink};
+	}
+
+	$Column->{SearchType} = ucfirst($Column->{SearchType});
+
+	$link .= "ValueOf" .$Column->{SearchType}. "=" ;
+	$link .= eval("\$Ticket->$Column->{SearchAttribute}") ;
+	$link .= "&" . $Column->{SearchType} . "Op=" . $Column->{SearchOperator};
+	$link .= $Column->{ExtraLinks};
+
+	if ($session{NewWindowOption}) {
+		$link .= "TARGET=\"TicketDisplay".$session{AlwaysNewWindowOption} && 
+			(time() . rand(1024))."\" ";
 	}
 	$link .= "\">";
 	$endlink = "</a>";
 }


More information about the Rt-devel mailing list