rt 4.0.23
[freeside.git] / rt / share / html / Elements / QueueSummaryByLifecycle
index 1410e82..da31ebb 100644 (file)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -66,20 +66,16 @@ for my $queue (@queues) {
     next if lc($queue->{Lifecycle} || '') ne lc $lifecycle->Name;
 
     $i++;
-    my $name = $queue->{Name};
-    $name =~ s/(['\\])/\\$1/g;
-    my $queue_cond = "Queue = '$name' AND ";
-    my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", @cur_statuses ) . ')';
 </%PERL>
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 
 <td>
-    <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+    <a href="<% $link_all->($queue, \@cur_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
 </td>
 
 %   for my $status (@cur_statuses) {
 <td align="right">
-    <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
+    <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{lc $status} || '-' %></a>
 </td>
 %   }
 </tr>
@@ -87,6 +83,31 @@ for my $queue (@queues) {
 </table>
 % }
 <%INIT>
+my $build_search_link = sub {
+    my ($queue_name, $extra_query) = @_;
+    $queue_name =~ s/(['\\])/\\$1/g; #'
+
+    return RT->Config->Get('WebPath')
+         . "/Search/Results.html?Query="
+         . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u');
+};
+
+my $link_all = sub {
+    my ($queue, $all_statuses) = @_;
+    return $build_search_link->($queue->{Name}, "(".join(" OR ", map "Status = '$_'", @$all_statuses).")");
+};
+
+my $link_status = sub {
+    my ($queue, $status) = @_;
+    return $build_search_link->($queue->{Name}, "Status = '$status'");
+};
+
+$m->callback(
+    CallbackName        => 'LinkBuilders',
+    build_search_link   => \$build_search_link,
+    link_all            => \$link_all,
+    link_status         => \$link_status,
+);
 
 my $Queues = RT::Queues->new( $session{'CurrentUser'} );
 $Queues->UnLimit();