[rt-users] CONTRIB: Add Search links to Search Listings

Jim Meyer purp at wildbrain.com
Fri May 3 17:39:31 EDT 2002


Howdy!

May I again say that RT is one finely-architected piece of software?

While looking at another question asked on rt-devel, I stumbled over a
to-do in config.pm that wanted the ability to click the Owner's name in
a search listing and be transported to a search listing showing tickets
owned by that owner. That sounded really useful and, an hour or so
later, here we are. =]

Attached is a copy of the revised TicketCell which now understands how
to perform simple searches based on what felt like a reasonable
imitation of the TicketLink syntax. Here's an example from my current
config.pm %WebOptions:

       { 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'
         },

       # TODO: It would be nice with a link here to the Owner and all
       # other request owned by this Owner.
       { Header => 'Owner', 
         TicketAttribute => 'OwnerObj->RealName',
         SearchLink => 1,
         SearchType => 'Owner',
         SearchAttribute => 'OwnerObj->Name',
         SearchOperator => '%3D',
         ExtraLinks =>
           '&StatusOp=%21%3D&ValueOfStatus=dead&ValueOfStatus=resolved'
       },

BTW, note that TicketAttribute has been changed in both entries above to
show real name (not email or username). That's where this all started.
=]

TO INSTALL THIS: Copy it to
/path/to/rt/local/WebRT/html/Search/TicketCell. It should just work from
there. Remember that when you change your config.pm, you must restart
your webserver or the changes won't take effect.

Cheers!

--j
-- 
Jim Meyer, Geek At Large                              purp at wildbrain.com
-------------- next part --------------
%#$Header: /raid/cvsroot/rt/webrt/Search/TicketCell,v 1.2 2001/11/06 23:07:01 jesse Exp $
<% $link |n%><%$Column->{Constant} || eval("\$Ticket->$Column->{TicketAttribute}") || "-" %><% $endlink|n %>
<%INIT>

my $link = "";
my $endlink = "";
if ($Column->{TicketLink}) {
	$link = "<A HREF=\"";
	if ($Column->{TicketLink} == 1 ) {
		$link .= "../Ticket/Display.html?";
	} else {
		$link .= $Column->{TicketLink};
	}

	$link .= "id=".$Ticket->Id . $Column->{ExtraLinks};

	if ($session{NewWindowOption}) {
		$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>";
}
</%INIT>
<%ARGS>
$Ticket => undef
$Column => undef
</%ARGS>


More information about the rt-users mailing list