rt 4.2.16
[freeside.git] / rt / share / html / Elements / ShowRelationLabel
index 3b045e7..3447f08 100644 (file)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<a href="<%$SearchURL |n %>"><%$Label%></a>
+% if ($SearchURL) {
+<a href="<% $SearchURL %>"><% $Label %></a>
+% } else {
+<% $Label %>
+% }
 <%INIT>
-my $typemap = RT::Ticket->LINKTYPEMAP->{$Relation};
+my $typemap = $RT::Link::TYPEMAP{$Relation};
 my $search_mode = $typemap->{Mode};
 my $search_type = $typemap->{Type};
-my $search_relation = RT::Ticket->LINKDIRMAP->{$search_type}{$search_mode};
+my $search_relation = $RT::Link::DIRMAP{$search_type}->{$search_mode};
+my $SearchURL;
 
-my $Query = $search_relation . ' = ' . $id;
-my $SearchURL = RT->Config->Get('WebPath') . '/Search/Results.html?' . $m->comp('/Elements/QueryString', Query => $Query);
+if ($Object and $Object->id) {
+    my $id = $Object->id;
+
+    if ($Object->isa("RT::Ticket")) {
+        $SearchURL = RT->Config->Get('WebPath')
+            . '/Search/Results.html?'
+            . $m->comp('/Elements/QueryString', Query => "$search_relation = $id");
+    }
+}
+
+$m->callback(
+    CallbackName    => "ModifySearchURL",
+    SearchURL       => \$SearchURL,
+    ARGSRef         => \%ARGS,
+);
 </%INIT>
 <%ARGS>
-$id
+$Object => undef
 $Label
 $Relation
 </%ARGS>