[Rt-commit] rtir branch, 5.0/migrate-to-rt-search, created. 4.0.1rc1-154-g6c975f66

? sunnavy sunnavy at bestpractical.com
Fri May 29 17:16:58 EDT 2020


The branch, 5.0/migrate-to-rt-search has been created
        at  6c975f66c67cb4d197045021e8ba60869eed3259 (commit)

- Log -----------------------------------------------------------------
commit a14a438ebf441501e54bebbd7841cfcdd47cb269
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 3 03:23:55 2020 +0800

    Check lifecycles to identify if it's an RTIR search or not

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index ac869791..f3bf0b4e 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -494,15 +494,26 @@ sub OurQuery {
     $ticket_sql_parser->walk(
         RT::SQL::ParseToArray( $query ),
         { operand => sub {
-            # XXX TODO  also pull out lifecycle keys
-            return undef unless $_[0]->{'key'} =~ /^Queue(?:\z|\.)/;
-            my $queue = RT::Queue->new( RT->SystemUser );
-            $queue->Load( $_[0]->{'value'} );
-            my $our = $self->OurQueue( $queue );
+            return undef unless $_[0]->{'key'} =~ /^(Queue(?:\z|\.)|Lifecycle)/;
+            my $key = $1;
+
             my ($negative) = ( $_[0]->{'op'} eq '!=' || $_[0]->{'op'} =~ /\bNOT\b/i );
+            my ( $our, $lifecycle );
+
+            if ( $key eq 'Lifecycle' ) {
+                $our = $self->OurLifecycle( $_[0]->{'value'} );
+                $lifecycle = $_[0]->{'value'};
+            }
+            else {
+                my $queue = RT::Queue->new( RT->SystemUser );
+                $queue->Load( $_[0]->{'value'} );
+                $our = $self->OurQueue( $queue );
+                $lifecycle = $queue->Lifecycle;
+            }
+
             if ( $our && !$negative ) {
                 $has_our = 1;
-                push @lifecycles, $queue->Lifecycle;
+                push @lifecycles, $lifecycle;
             } else {
                 $has_other = 1;
             }

commit 110afa8dd926b262dff13db6920600b999fd5dae
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Apr 6 14:56:55 2020 +0800

    Migrate to RT Lifecycle select

diff --git a/html/Callbacks/RTIR/Search/Elements/PickBasics/Default b/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
index 426d0e0f..6b9d6a10 100644
--- a/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
+++ b/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
@@ -66,21 +66,11 @@ foreach( @$Conditions ) {
                 [RT::Lifecycle->Load($m->request_args->{'Lifecycle'})]
         } 
     }
+    elsif ( ( $_->{'Name'} || '' ) eq 'Lifecycle' ) {
+        $_->{'Value'}{'Arguments'}{'Lifecycles'} = [ RT::IR->Lifecycles ];
+    }
 }
 
-unshift @$Conditions, {
-        Name => 'Lifecycle',
-        Field => loc('Lifecycle'),
-        Op => {
-            Type => 'component',
-            Path => '/Elements/SelectBoolean',
-            Arguments => { TrueVal=> '=', FalseVal => '!=' },
-        },    
-        Value =>  {Type => 'component',
-                     Path => '/RTIR/Elements/SelectRTIRLifecycle',
-                    Arguments => { ShowNullOption => 1 }}
-
-};
 </%INIT>
 <%ARGS>
 $Conditions => [],
diff --git a/html/RTIR/Elements/SelectRTIRLifecycle b/html/RTIR/Elements/SelectRTIRLifecycle
deleted file mode 100644
index 75ece975..00000000
--- a/html/RTIR/Elements/SelectRTIRLifecycle
+++ /dev/null
@@ -1,67 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<select name="<%$Name%>" class="<%$Class%>">
-%     if ($ShowNullOption) {
-  <option value=""><% $DefaultLabel %></option>
-%     }
-%     for my $lifecycle (RT::IR->Lifecycles) {
-  <option value="<% $lifecycle %>"\
-% if ($lifecycle eq ($Default||'')) {
- selected="selected"\
-% }
-><%RT::IR::FriendlyLifecycle($lifecycle) %>\
-</option>
-%     }
-</select>
-<%args>
-$ShowNullOption => 0
-$Name => undef
-$DefaultLabel => "-"
-$Default => 0
-$Class => 'select-lifecycle'
-</%args>

commit 0c779a6a5403a3b9b16d832e40952a314ecbdc43
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Jun 16 00:24:54 2018 +0800

    Migrate to RT search to reduce code duplication

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 7532e80d..7684c2c6 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -56,54 +56,117 @@ my $query_string = sub {
 
 my $args = $DECODED_ARGS;
 
-my @query_fields = qw(Query Format RowsPerPage Page OrderBy Order);
+my @query_fields = qw(Query Format RowsPerPage Page OrderBy Order ExtraQueryParams);
 
 my $search_arguments = sub {
     my %res = ();
     my $caller_args = $m->caller_args(1);
     if ( $caller_args->{'SearchArgs'} ) {
         @res{ @query_fields } = @{ $caller_args->{'SearchArgs'} }{ @query_fields };
+        if ( $res{ExtraQueryParams} ) {
+            $res{$_} = $caller_args->{'SearchArgs'}{$_}
+              for ref $res{ExtraQueryParams} ? @{ $res{ExtraQueryParams} } : $res{ExtraQueryParams};
+        }
     } else {
         @res{ @query_fields } = @{ $args }{ @query_fields };
+        if ( $res{ExtraQueryParams} ) {
+            $res{$_} = $args->{$_}
+              for ref $res{ExtraQueryParams} ? @{ $res{ExtraQueryParams} } : $res{ExtraQueryParams};
+        }
     }
+
     delete $res{$_} foreach grep !defined $res{$_}, keys %res;
     return %res;
 };
 
+if ( $m->request_comp->path =~ m{^/Search/} ) {
+    my %args;
+    if ( $ARGS{ARGSRef}{QueryArgs} ) {
+        %args = %{ $ARGS{ARGSRef}{QueryArgs} };
+    }
+    else {
+        %args = %$DECODED_ARGS;
+    }
+
+    my $rtir_search;
+    ( $rtir_search, my @lifecycles ) = RT::IR->OurQuery( $args{'Query'} ) if $args{Query};
+    $rtir_search ||= $args{RTIR};
+    if ( $rtir_search ) {
+        my $lifecycle = '';
+        $lifecycle = $lifecycles[ 0 ] if @lifecycles == 1;
+
+        if ( $args{Query} ) {
+            PageMenu()->child(
+                new_search => title => loc( 'New Search' ),
+                path       => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1',
+            );
+        }
+
+        if ( $lifecycle eq RT::IR->lifecycle_incident ) {
+            PageMenu()->child(
+                report     => title => loc( 'Report' ),
+                path       => RT::IR->HREFTo( "Reporting/", IncludeWebPath => 0 ),
+            );
+
+            PageMenu()->child(
+                abandon => title => loc( 'Bulk Abandon' ),
+                path => RT::IR->HREFTo( "Incident/BulkAbandon.html?" . $query_string->( %args ), IncludeWebPath => 0 ),
+            );
+        }
+        elsif ( $lifecycle eq RT::IR->lifecycle_report ) {
+            PageMenu()->child(
+                reject => title => loc( 'Bulk Reject' ),
+                path   => RT::IR->HREFTo( "Report/BulkReject.html?" . $query_string->( %args ), IncludeWebPath => 0 ),
+            );
+        }
+
+        if ( $args{Query} ) {
+            PageMenu()->child( 'more' )->{sort_order} = 99;
+        }
+    }
+}
+
 my $root = Menu->child( rtir => title => loc('RTIR'), path => '/RTIR/' );
 
 my $search = $root->child( search => title => loc('Search'), path => RT::IR->HREFTo('', IncludeWebPath => 0) );
-$search->child( new => title => loc('New Search'), path => RT::IR->HREFTo('Search/?NewQuery=1', IncludeWebPath => 0) );
+$search->child( new => title => loc('New Search'), path => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1' );
 
 {
 my $current_search = $session{'CurrentSearchHash'} ? { map { $_ => $session{'CurrentSearchHash'}{$_} } @query_fields } : {};
+
+if ( my $extra_params = $current_search->{ExtraQueryParams} ) {
+    for my $param ( ref $extra_params eq 'ARRAY' ? @$extra_params : $extra_params ) {
+        $current_search->{$param} = $session{'CurrentSearchHash'}{$param};
+    }
+}
+
 my $has_query = 1 if ( $args->{'Query'} or $current_search->{'Query'} );
 
 if ( $has_query ) {
-    $search->child( build => title => loc('Edit Search'), path => RT::IR->HREFTo('Search/', IncludeWebPath => 0) );
+    $search->child( build => title => loc('Edit Search'), path => '/Search/Build.html', );
     $search->child( results => title => loc('Show Results'),
-                    path =>RT::IR->HREFTo('Search/Results.html?', IncludeWebPath => 0).
+                    path =>'/Search/Results.html?'.
                     $query_string->( $args->{'Query'} ? $search_arguments->() : %$current_search ) );
 }
 }
 
 $root->child(
     incidents => title => loc('Incidents'),
-    path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0)
+    path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_incident,
 )->child(
     create => title => loc('Create'),
     path => RT::IR->HREFTo('Incident/Create.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0),
 );
 $root->child(
     reports => title => loc('Incident Reports'),
-    path => RT::IR->HREFTo('Search/Results.html?Lifecycle='. RT::IR->lifecycle_report, IncludeWebPath => 0)
+    path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='. RT::IR->lifecycle_report,
 )->child(
     create => title => loc('Create'),
     path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_report, IncludeWebPath => 0),
 );
 $root->child(
     investigations => title => loc('Investigations'),
-    path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0)
+    path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_investigation,
 )->child(
     launch => title => loc('Launch'),
     path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0),
@@ -111,7 +174,7 @@ $root->child(
 unless ( RT->Config->Get('RTIR_DisableCountermeasures') ) {
     $root->child(
         countermeasures => title => loc('Countermeasures'),
-        path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0)
+        path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_countermeasure,
     )->child(
         create => title => loc('Create'),
         path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0),
@@ -317,6 +380,8 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
         $search_arguments->(),
         id => $id,
         Lifecycle => $lifecycle,
+        ExtraQueryParams => [ 'RTIR', 'id', 'Lifecycle' ],
+        RTIR => 1,
     );
 
     PageMenu()->child(
@@ -325,7 +390,7 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     );
     PageMenu()->child(
         edit_search => title => loc('Edit Search'),
-        path => RT::IR->HREFTo("Link/$direction/Refine.html?". $query_string->( %args ), IncludeWebPath => 0),
+        path => '/Search/Build.html?' . $query_string->( %args, ResultPage => RT::IR->HREFTo("Link/$direction/") ),
     );
     PageMenu()->child(
         new => title => loc("New [_1]", RT::IR::TicketType( Lifecycle => $lifecycle || RT::IR->lifecycle_incident ) ),
@@ -365,7 +430,13 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
 
     my %args = (
         $search_arguments->(),
-        id => $id,
+        id    => $id,
+        Query => RT::IR->Query(
+            Lifecycle => $ARGS{'Lifecycle'},
+            Exclude   => $ARGS{'id'},
+        ),
+        ExtraQueryParams => [ 'RTIR', 'id' ],
+        RTIR             => 1,
     );
 
     PageMenu()->child(
@@ -374,7 +445,7 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     );
     PageMenu()->child(
         edit_search => title => loc('Edit Search'),
-        path => RT::IR->HREFTo("Merge/Refine.html?". $query_string->( %args, Lifecycle => $ticket->QueueObj->Lifecycle ), IncludeWebPath => 0),
+        path => '/Search/Build.html?' . $query_string->( %args, ResultPage => RT::IR->HREFTo("Merge/") ),
     );
     PageMenu()->child(
         back => title => loc('Back to [_1] #[_2]', lc RT::IR::TicketType( Lifecycle => $ticket->QueueObj->Lifecycle), $id),
@@ -391,7 +462,9 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
         All => $args->{'All'},
         Status => $args->{'Status'},
         Action => $args->{'Action'},
-        map { $_ => $DECODED_ARGS->{$_} } grep { /Selected\w+All/ } keys %$DECODED_ARGS,
+        map( { $_ => $DECODED_ARGS->{$_} } grep { /Selected\w+All/ } keys %$DECODED_ARGS ),
+        ExtraQueryParams => [ 'RTIR', 'id', 'All', grep { /Selected\w+All/ } keys %$DECODED_ARGS ],
+        RTIR             => 1,
     );
 
     PageMenu()->child(
@@ -400,13 +473,13 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     );
     PageMenu()->child(
         edit_search => title => loc('Edit Search'),
-        path => RT::IR->HREFTo("Incident/Reply/Refine.html?". $query_string->( %args ), IncludeWebPath => 0),
+        path => '/Search/Build.html?' . $query_string->( %args, ResultPage => RT::IR->HREFTo('Incident/Reply/') ),
     );
     PageMenu()->child(
         back => title => loc('Back to [_1] #[_2]', lc RT::IR::TicketType(Lifecycle => $ticket->QueueObj->Lifecycle), $id),
         path => RT::IR->HREFTo("Display.html?id=$id", IncludeWebPath => 0),
     );
-} elsif ( $request_path =~ m{(?:$re_rtir_path)(Search/?|Incident/BulkAbandon\.html$|Report/BulkReject\.html$)} ) {
+} elsif ( $request_path =~ m{(?:$re_rtir_path)(Incident/BulkAbandon\.html$|Report/BulkReject\.html$)} ) {
     my %args = $search_arguments->();
 
     my $lifecycle = $args->{'Lifecycle'} || '';
@@ -428,7 +501,7 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     if ( $args{'Query'} ) {
         PageMenu()->child(
             link => title => loc('Show Results'),
-            path => RT::IR->HREFTo("Search/Results.html?". $query_string->( %args ), IncludeWebPath => 0),
+            path => "/Search/Results.html?". $query_string->( %args ),
         );
     }
 
@@ -436,16 +509,16 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     # full RTIR Search UI, only from the Bulk screens.
     my $bulk_path = 1 if $request_path =~ m{(?:$re_rtir_path)(Incident/BulkAbandon\.html$|Report/BulkReject\.html$)};
 
+    $search->child( build => title => loc('Edit Search'), path => '/Search/Build.html?RTIR=1', );
     PageMenu()->child(
         edit_search => title => loc('Edit Search'),
-        path => RT::IR->HREFTo("Search/" .
-                    ($bulk_path ? "Refine.html?" : "?") .
-                    $query_string->( %args ), IncludeWebPath => 0),
+        path => '/Search/Build.html?' . $query_string->( %args ),
     );
     if ( $args{'Query'} && !$bulk_path ) {
+        $search->child( new => title => loc('New Search'), path => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1' );
         PageMenu()->child(
             new_search => title => loc('New Search'),
-            path => RT::IR->HREFTo("Search/?NewQuery=1", IncludeWebPath => 0)
+            path => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1'
         );
     }
 
@@ -468,11 +541,6 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     }
 
     if ( $args{'Query'} ) {
-        PageMenu()->child(
-            chart => title => loc('Chart'),
-            path => RT::IR->HREFTo("Search/Reporting.html?". $query_string->( %args ), IncludeWebPath => 0),
-        );
-
         my $more = PageMenu->child( more => title => loc('Feeds') );
         $more->child(
                 spreadsheet => title => loc('Spreadsheet'),
diff --git a/html/Callbacks/RTIR/Search/Build.html/BeforeDisplay b/html/Callbacks/RTIR/Search/Build.html/BeforeDisplay
new file mode 100644
index 00000000..147e9adb
--- /dev/null
+++ b/html/Callbacks/RTIR/Search/Build.html/BeforeDisplay
@@ -0,0 +1,27 @@
+<%INIT>
+
+if ( !$ARGSRef->{RTIR} && RT->Config->Get( 'RTIR_RedirectOnSearch' ) && $Query->{Query} ) {
+    my ( $rtir ) = RT::IR->OurQuery( $Query->{'Query'} );
+    if ( $rtir ) {
+        RT::Interface::Web::Redirect( RT->Config->Get( 'WebURL' )
+              . 'Search/Build.html?'
+              . $m->comp( '/Elements/QueryString', %$ARGSRef, ExtraQueryParams => 'RTIR', RTIR => 1 ) );
+    }
+}
+
+if ( $ARGSRef->{RTIR} ) {
+    if ( my %params = RTIRDefaultSearchParams(ARGSRef => $ARGSRef) ) {
+        $Query->{$_} ||= $params{$_} for keys %params;
+    }
+}
+
+# $DECODED_ARGS->{RTIR} is the flag we use to filter lifecycle/queue
+# options. When we access current search(i.e. /Search/Builder.html without
+# parameters), $DECODED_ARGS->{RTIR} is false even if it's an RTIR search.
+$DECODED_ARGS->{RTIR} ||= 1 if $Query->{RTIR};
+</%INIT>
+
+<%ARGS>
+$ARGSRef
+$Query
+</%ARGS>
diff --git a/html/Callbacks/RTIR/Search/Elements/PickBasics/Default b/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
index 6b9d6a10..ce6a710a 100644
--- a/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
+++ b/html/Callbacks/RTIR/Search/Elements/PickBasics/Default
@@ -46,8 +46,8 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
-my $path = $r->path_info;
-return unless $path =~ m{^/RTIR};
+return unless $DECODED_ARGS->{RTIR};
+
 foreach( @$Conditions ) {
     if (($_->{'Name'}||'') eq 'Queue' ) {
     $_->{'Value'}{'Path'} = '/RTIR/Elements/SelectRTIRQueue';
diff --git a/html/Callbacks/RTIR/Search/Results.html/Initial b/html/Callbacks/RTIR/Search/Results.html/Initial
index 01221c55..5da98675 100644
--- a/html/Callbacks/RTIR/Search/Results.html/Initial
+++ b/html/Callbacks/RTIR/Search/Results.html/Initial
@@ -49,20 +49,11 @@
 $ARGSRef => {}
 </%ARGS>
 <%INIT>
-return unless RT->Config->Get('RTIR_RedirectOnSearch');
-
-# this callback redirects search results from a standard 
-# RT search results page to the RTIR search results page
-# if it's actually a search for RTIR tickets.
-# XXX TODO: this may be obsolete
-my ($our, @lifecycles) = RT::IR->OurQuery( $ARGSRef->{'Query'} );
-return unless $our;
-
-RT::Interface::Web::Redirect( RT::IR->HREFTo('Search/Results.html?'
-    . $m->comp(
-        '/Elements/QueryString',
-        %$ARGSRef,
-        @lifecycles == 1? (Lifecycle => $lifecycles[0]) : (Lifecycle => undef)
-    ))
-);
+if ( $ARGSRef->{RTIR} ) {
+    if ( my %params = RTIRDefaultSearchParams(ARGSRef => $ARGSRef) ) {
+        RT::Interface::Web::Redirect( RT->Config->Get('WebURL')
+                . 'Search/Results.html?'
+                . $m->comp( '/Elements/QueryString', %$ARGSRef, %params, ) );
+    }
+}
 </%INIT>
diff --git a/html/RTIR/Elements/DueIncidents b/html/RTIR/Elements/DueIncidents
index 1a0e1c3a..90d52efa 100644
--- a/html/RTIR/Elements/DueIncidents
+++ b/html/RTIR/Elements/DueIncidents
@@ -49,7 +49,7 @@
 Description => loc('Due Incidents')
 </%ATTR>
 <&| /Widgets/TitleBox,
-	title_href  => RT::IR->HREFTo("Search/Results.html?Lifecycle=incidents&$QueryString"),
+	title_href  => RT->Config->Get('WebPath') . "/Search/Results.html?Lifecycle=incidents&$QueryString",
     title => $Title,
 &>
 
@@ -81,6 +81,8 @@ my $QueryString = $m->comp('/Elements/QueryString',
     Page    => $Page,
     OrderBy => $OrderBy,
     Order   => $Order,
+    ExtraQueryParams => 'RTIR',
+    RTIR    => 1,
 );
 
 </%INIT>
diff --git a/html/RTIR/Elements/NewReports b/html/RTIR/Elements/NewReports
index a0adb165..12a8f3a6 100644
--- a/html/RTIR/Elements/NewReports
+++ b/html/RTIR/Elements/NewReports
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <&| /Widgets/TitleBox, 
-    title_href      => RT::IR->HREFTo("Search/Results.html?$QueryString"),
+    title_href      => RT->Config->Get('WebPath') . "/Search/Results.html?$QueryString",
     title           => $title,
     titleright      => loc("Bulk Reject"),
     titleright_href => RT::IR->HREFTo("Report/BulkReject.html?$BulkQS"),
@@ -82,6 +82,8 @@ my $QueryString = $m->comp('/Elements/QueryString',
     Page    => $Page,
     OrderBy => $OrderBy,
     Order   => $Order,
+    ExtraQueryParams => 'RTIR',
+    RTIR    => 1,
 );
 
 my $BulkQS = $m->comp('/Elements/QueryString',
diff --git a/html/RTIR/Elements/QueueSummary b/html/RTIR/Elements/QueueSummary
index dc40dc81..3bcc09ed 100644
--- a/html/RTIR/Elements/QueueSummary
+++ b/html/RTIR/Elements/QueueSummary
@@ -118,9 +118,8 @@ my $build_search_link = sub {
     my ($queue_name, $extra_query) = @_;
     $queue_name =~ s/(['\\])/\\$1/g; #'
 
-    RT::IR->HREFTo(
-          "Search/Results.html?Query="
-         . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u'));
+    return RT->Config->Get('WebPath') . "/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Query="
+         . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u');
 };
 
 my $link_all = sub {
diff --git a/html/RTIR/Incident/Reply/Refine.html b/html/RTIR/Incident/Reply/Refine.html
deleted file mode 100644
index 549c2d73..00000000
--- a/html/RTIR/Incident/Reply/Refine.html
+++ /dev/null
@@ -1,71 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-my @lifecycles = (RT::IR->lifecycle_report);
-push @lifecycles, RT::IR->lifecycle_investigation if $ARGS{'All'};
-push @lifecycles, RT::IR->lifecycle_countermeasure if $ARGS{'All'} && !RT->Config->Get('RTIR_DisableCountermeasures');
-
-return $m->comp(
-    '/RTIR/Search/Elements/RefinePage',
-    %ARGS,
-    ResultPage => 'RTIR/Incident/Reply/?'. $m->comp('/Elements/QueryString',
-        id => $ARGS{'id'}, All => $ARGS{'All'},
-        Status => $ARGS{'Status'}, Action => $ARGS{'Action'},
-        SelectedReportsAll => $ARGS{'SelectedReportsAll'},
-        SelectedInvestigationsAll => $ARGS{'SelectedInvestigationsAll'},
-        SelectedCountermeasuresAll => $ARGS{'SelectedCountermeasuresAll'},
-    ),
-    BaseQuery => RT::IR->Query(
-    Lifecycle    => \@lifecycles,
-        MemberOf => $ARGS{'id'},
-    ),
-    ExtraQueryParams => [qw(SelectedReportsAll SelectedInvestigationsAll
-                            All Status Action SelectedCountermeasuresAll)],
-
-);
-</%INIT>
diff --git a/html/RTIR/Link/FromIncident/Refine.html b/html/RTIR/Link/FromIncident/Refine.html
deleted file mode 100644
index 5d72d67e..00000000
--- a/html/RTIR/Link/FromIncident/Refine.html
+++ /dev/null
@@ -1,63 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-return $m->comp(
-    '/RTIR/Search/Elements/RefinePage',
-    %ARGS,
-    ResultPage => 'RTIR/Link/FromIncident/?'. $m->comp(
-        '/Elements/QueryString',
-        id    => $ARGS{'id'},
-        Lifecycle => $ARGS{'Lifecycle'},
-    ),
-    BaseQuery => RT::IR->Query(
-        Lifecycle       => $ARGS{'Lifecycle'},
-        NotMemberOf => $ARGS{'id'},
-    ),
-    ExtraQueryParams => [ 'Lifecycle' ],
-);
-</%INIT>
diff --git a/html/RTIR/Link/ToIncident/Refine.html b/html/RTIR/Link/ToIncident/Refine.html
deleted file mode 100644
index 21f56009..00000000
--- a/html/RTIR/Link/ToIncident/Refine.html
+++ /dev/null
@@ -1,59 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-return $m->comp(
-    '/RTIR/Search/Elements/RefinePage',
-    %ARGS,
-    ResultPage => RT::IR->HREFTo('Link/ToIncident/?id='. $ARGS{'id'}),
-    BaseQuery => RT::IR->Query(
-        Lifecycle => 'incidents',
-        HasNoMember => $ARGS{'id'},
-    ),
-);
-</%INIT>
-
diff --git a/html/RTIR/Merge/Refine.html b/html/RTIR/Merge/Refine.html
deleted file mode 100644
index 6e799a00..00000000
--- a/html/RTIR/Merge/Refine.html
+++ /dev/null
@@ -1,59 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-return $m->comp(
-    '/RTIR/Search/Elements/RefinePage',
-    %ARGS,
-    ResultPage => RT::IR->HREFTo('Merge/?'. $m->comp('/Elements/QueryString', id => $ARGS{'id'},
-    ),
-    BaseQuery => RT::IR->Query(
-        Lifecycle        => $ARGS{'Lifecycle'},
-        Exclude      => $ARGS{'id'},
-    )),
-);
-</%INIT>
diff --git a/html/RTIR/Search/Elements/BuildQuery b/html/RTIR/Search/Elements/BuildQuery
deleted file mode 100644
index 7430def8..00000000
--- a/html/RTIR/Search/Elements/BuildQuery
+++ /dev/null
@@ -1,114 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-%#
-%# 
-%# XXX TODO - this really ought to use HREFTo, but to do that
-%# we'd need to strip off the RTIR UIR prefix
-<div class="search-form">
-<form method="post" action="<% RT->Config->Get('WebPath') %><% $r->path_info %>" name="BuildQuery" id="BuildQuery">
-<input type="hidden" class="hidden" name="SavedSearchId" value="<% $saved_search{'Id'} %>" />
-<input type="hidden" class="hidden" name="ResultPage" value="<% $ResultPage %>" />
-<input type="hidden" class="hidden" name="BaseQuery" value="<% $BaseQuery %>" />
-
-% if ( $DECODED_ARGS->{id} ) {
-    <input type="hidden" class="hidden" name="id" value="<% $DECODED_ARGS->{id} %>" />
-% }
-
-% for my $input ( @ExtraQueryParams ) {
-%   if ( $DECODED_ARGS->{$input} ) {
-<input type="hidden" class="hidden" name="<% $input %>" value="<% $DECODED_ARGS->{$input} %>" />
-%   }
-% }
-
-<input type="hidden" class="hidden" name="Query" value="<% $query{'Query'} %>" />
-<input type="hidden" class="hidden" name="Format" value="<% $query{'Format'} %>" />
-
-<div id="pick-criteria"><& /Search/Elements/PickCriteria, queues => $queues &></div>
-
-<& /Elements/Submit, Label => loc('Add these terms'), Name => 'AddClause' &>
-<& /Elements/Submit, Label => loc('Add these terms and Search'), Name => 'DoSearch' &>
-
-<div id="editquery">
-<& /Search/Elements/EditQuery,
-    %ARGS,
-    actions => \@actions,
-    optionlist => $optionlist,
-    Description => $saved_search{'Description'},
-&>
-</div>
-
-<div id="editsearches">
-<& /Search/Elements/EditSearches, %saved_search, CurrentSearch => \%query &>
-</div>
-
-<span id="display-options">
-<& /Search/Elements/DisplayOptions, %ARGS, %query, queues => $queues &>
-</span>
-
-<& /Elements/Submit,
-    Label => loc('Update format and Search'),
-    Name => 'DoSearch',
-    id => "formatbuttons",
-&>
-
-</form>
-</div>
-<%ARGS>
-$BaseQuery    => ''
-%query        => ()
-%saved_search => ()
-
-$queues => undef
- at actions => ()
-$optionlist => undef
-$dirty => undef
-$AvailableColumns => undef
-$CurrentFormat => undef
-$ResultPage => undef
- at ExtraQueryParams => ()
-</%ARGS>
diff --git a/html/RTIR/Search/Elements/ProcessQuery b/html/RTIR/Search/Elements/ProcessQuery
deleted file mode 100644
index b32d562c..00000000
--- a/html/RTIR/Search/Elements/ProcessQuery
+++ /dev/null
@@ -1,253 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-# XXX: This is almost complete copy&paste of the /Search/Build.html INIT section
-# XXX: Last synchronized on 2015-03-15
-
-use RT::Interface::Web::QueryBuilder;
-use RT::Interface::Web::QueryBuilder::Tree;
-
-my @actions;
-
-my %query;
-for( qw(Query Format OrderBy Order RowsPerPage) ) {
-    $query{$_} = $ARGS{$_};
-}
-
-my %saved_search;
-push @actions, $m->comp( '/Search/Elements/EditSearches:Init', %ARGS, Query => \%query, SavedSearch => \%saved_search );
-
-if ( $NewQuery ) {
-
-    # Wipe all data-carrying variables clear if we want a new
-    # search, or we're deleting an old one..
-    %query = ();
-    %saved_search = ( Id => 'new' );
-
-    # ..then wipe the session out..
-    delete $session{'CurrentSearchHash'};
-
-    # ..and the search results.
-    $session{'tickets'}->CleanSlate if defined $session{'tickets'};
-}
-
-{ # Attempt to load what we can from the session and preferences, set defaults
-
-    my $current = $session{'CurrentSearchHash'};
-    my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
-    my $default = { Query => '',
-                    Format => '',
-                    OrderBy => RT->Config->Get('DefaultSearchResultOrderBy'),
-                    Order => RT->Config->Get('DefaultSearchResultOrder'),
-                    RowsPerPage => 50 };
-
-    for( qw(Query Format OrderBy Order RowsPerPage) ) {
-        $query{$_} = $current->{$_} unless defined $query{$_};
-        $query{$_} = $prefs->{$_} unless defined $query{$_};
-        $query{$_} = $default->{$_} unless defined $query{$_};
-    }
-
-    for( qw(Order OrderBy) ) {
-        if (ref $query{$_} eq "ARRAY") {
-            $query{$_} = join( '|', @{ $query{$_} } );
-        }
-    }
-    if ( $query{'Format'} ) {
-        # Clean unwanted junk from the format
-        $query{'Format'} = $m->comp( '/Elements/ScrubHTML', Content => $query{'Format'} );
-    }
-}
-
-my $ParseQuery = sub {
-    my ($string, $results) = @_;
-
-    my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
-    @$results = $tree->ParseSQL( Query => $string, CurrentUser => $session{'CurrentUser'} );
-
-    return $tree;
-};
-
-my @parse_results;
-my $tree = $ParseQuery->( $query{'Query'}, \@parse_results );
-
-# if parsing went poorly, send them to the edit page to fix it
-if ( @parse_results ) {
-    # XXX: we have no Advanced Query Builder in RTIR, so just push errors into results
-    # return $m->comp( "Edit.html", Query => $query{'Query'}, actions => \@actions );
-    push @actions, @parse_results;
-}
-
-my @options = $tree->GetDisplayedNodes;
-my @current_values = grep defined, @options[@clauses];
-my @new_values = ();
-
-my $cf_field_names =
-    join "|",
-     map quotemeta,
-    grep { $RT::Tickets::FIELD_METADATA{$_}->[0] eq 'CUSTOMFIELD' }
-    sort keys %RT::Tickets::FIELD_METADATA;
-
-# Try to find if we're adding a clause
-foreach my $arg ( keys %ARGS ) {
-    next unless $arg =~ m/^ValueOf(\w+|($cf_field_names).\{.*?\})$/
-                && ( ref $ARGS{$arg} eq "ARRAY"
-                     ? grep $_ ne '', @{ $ARGS{$arg} }
-                     : $ARGS{$arg} ne '' );
-
-    # We're adding a $1 clause
-    my $field = $1;
-
-    my ($op, $value);
-
-    #figure out if it's a grouping
-    my $keyword = $ARGS{ $field . "Field" } || $field;
-
-    my ( @ops, @values );
-    if ( ref $ARGS{ 'ValueOf' . $field } eq "ARRAY" ) {
-        # we have many keys/values to iterate over, because there is
-        # more than one CF with the same name.
-        @ops    = @{ $ARGS{ $field . 'Op' } };
-        @values = @{ $ARGS{ 'ValueOf' . $field } };
-    }
-    else {
-        @ops    = ( $ARGS{ $field . 'Op' } );
-        @values = ( $ARGS{ 'ValueOf' . $field } );
-    }
-    $RT::Logger->error("Bad Parameters passed into Query Builder")
-        unless @ops == @values;
-
-    for ( my $i = 0; $i < @ops; $i++ ) {
-        my ( $op, $value ) = ( $ops[$i], $values[$i] );
-        next if !defined $value || $value eq '';
-
-        my $clause = {
-            Key   => $keyword,
-            Op    => $op,
-            Value => $value,
-        };
-
-        push @new_values, RT::Interface::Web::QueryBuilder::Tree->new($clause);
-    }
-}
-
-
-push @actions, $m->comp('/Search/Elements/EditQuery:Process',
-    %ARGS,
-    Tree => $tree,
-    Selected => \@current_values,
-    New => \@new_values,
-);
-
-# Rebuild $Query based on the additions / movements
-
-my $optionlist_arrayref;
-($query{'Query'}, $optionlist_arrayref) = $tree->GetQueryAndOptionList(\@current_values);
-
-my $optionlist = join "\n", map { qq(<option value="$_->{INDEX}" $_->{SELECTED}>) 
-                                  . (" " x (5 * $_->{DEPTH}))
-                                  . $m->interp->apply_escapes($_->{TEXT}, 'h') . qq(</option>) } @$optionlist_arrayref;
-
-
-my $queues = $tree->GetReferencedQueues;
-
-# Parse queues from BaseQuery
-if ( $BaseQuery ) {
-    my ($tree) = $ParseQuery->( $BaseQuery );
-    $queues = { %$queues, %{ $tree->GetReferencedQueues } };
-}
-
-# {{{ Deal with format changes
-my ( $AvailableColumns, $CurrentFormat );
-( $query{'Format'}, $AvailableColumns, $CurrentFormat ) = $m->comp(
-    '/Search/Elements/BuildFormatString',
-    %ARGS,
-    queues => $queues,
-    Format => $query{'Format'},
-);
-
-
-# if we're asked to save the current search, save it
-push @actions, $m->comp( '/Search/Elements/EditSearches:Save', %ARGS, Query => \%query, SavedSearch => \%saved_search );
-
-# {{{ Push the updates into the session so we don't loose 'em
-
-$session{'CurrentSearchHash'} = {
-    %query,
-    SearchId    => $saved_search{'Id'},
-    Object      => $saved_search{'Object'},
-    Description => $saved_search{'Description'},
-};
-
-
-# {{{ Show the results, if we were asked.
-if ( $ARGS{"DoSearch"} ) {
-    $ResultPage .= $ResultPage =~ /\?/? '&': '?';
-    $ResultPage .= $m->comp('/Elements/QueryString', %query );
-    return RT::Interface::Web::Redirect( $ResultPage );
-}
-# }}}
-
-return (
-    query            => \%query,
-    saved_search     => \%saved_search,
-    results          => \@actions,
-    optionlist       => $optionlist,
-    queues           => $queues,
-    AvailableColumns => $AvailableColumns,
-    CurrentFormat    => $CurrentFormat,
-);
-
-</%INIT>
-
-<%ARGS>
-$NewQuery  => 0
- at clauses   => ()
-
-$BaseQuery => ''
-$ResultPage => RT::IR->HREFTo("Search/Results.html")
-</%ARGS>
diff --git a/html/RTIR/Search/Elements/RefinePage b/html/RTIR/Search/Elements/RefinePage
deleted file mode 100644
index 109130cd..00000000
--- a/html/RTIR/Search/Elements/RefinePage
+++ /dev/null
@@ -1,77 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<& /RTIR/Elements/Header, Title => $Title &>
-<& /Elements/Tabs, SearchArgs => $query_state{query}  &>
-<& BuildQuery,
-    %query_state,
-
-    BaseQuery  => $BaseQuery,
-    ResultPage => $ResultPage,
-
-    actions    => \@results, 
-
-    ExtraQueryParams => \@ExtraQueryParams,
-&>
-
-<%INIT>
-my %query_state = $m->comp('ProcessQuery',
-    %ARGS,
-    BaseQuery  => $BaseQuery,
-    ResultPage => $ResultPage,
-);
-
-my @results = @{ delete $query_state{'results'} };
-
-my $QueryString = $m->comp( '/Elements/QueryString', %{ $query_state{'query'} } );
-</%INIT>
-<%ARGS>
-$Title => loc("Refine Search")
-$ResultPage => RT::IR->HREFTo('Search/Results.html'),
-$BaseQuery => '',
- at ExtraQueryParams => ()
-</%ARGS>
diff --git a/html/RTIR/Search/Elements/ShowResults b/html/RTIR/Search/Elements/ShowResults
index d0b4f650..fde028ac 100644
--- a/html/RTIR/Search/Elements/ShowResults
+++ b/html/RTIR/Search/Elements/ShowResults
@@ -104,7 +104,7 @@ $Page            => 1
 $OrderBy         => RT->Config->Get('DefaultSearchResultOrderBy')
 $Order           => RT->Config->Get('DefaultSearchResultOrder')
 
-$BaseURL         => RT::IR->HREFTo("Search/Results.html?")
+$BaseURL         => RT->Config->Get('WebPath') . '/Search/Results.html'
 
 $ShowEmpty       => 0
 $EmptyLabel      => ''
diff --git a/html/RTIR/Search/Refine.html b/html/RTIR/Search/Refine.html
deleted file mode 100644
index b58ca3e4..00000000
--- a/html/RTIR/Search/Refine.html
+++ /dev/null
@@ -1,50 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%INIT>
-return $m->comp( 'Elements/RefinePage' => %ARGS );
-</%INIT>
diff --git a/html/RTIR/Search/Reporting.html b/html/RTIR/Search/Reporting.html
deleted file mode 100644
index e692e70b..00000000
--- a/html/RTIR/Search/Reporting.html
+++ /dev/null
@@ -1,229 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%init>
-my $default_value = {
-    Query => RT::IR->ActiveQuery( Lifecycle => $ARGS{Lifecycle} ) || RT::IR->Query( Lifecycle => $ARGS{Lifecycle}) || 'id > 0',
-    GroupBy => ['Status'],
-    ChartStyle => 'bar+table+sql',
-    ChartFunction => ['COUNT'],
-};
-
-$m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
-
-my $title = loc( "Grouped search results");
-
-my @search_fields = qw(Query GroupBy ChartStyle ChartFunction Width Height);
-my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
-    SearchType   => 'Chart',
-    SearchFields => [@search_fields],
-);
-
-my @actions = $m->comp( '/Widgets/SavedSearch:process',
-    args     => \%ARGS,
-    defaults => $default_value,
-    self     => $saved_search,
-);
-
-my %query;
-
-{
-    if ($saved_search->{'CurrentSearch'}->{'Object'}) {
-        foreach my $search_field (@{ $saved_search->{'SearchFields'} }) {
-            $query{$search_field} = $saved_search->{'CurrentSearch'}->{'Object'}->Content->{$search_field};
-        }
-    }
-
-    my $current = $session{'CurrentSearchHash'};
-
-    my @session_fields = qw(
-        Lifecycle
-        Query
-        SavedChartSearchId
-        SavedSearchDescription
-        SavedSearchLoad
-        SavedSearchLoadButton
-        SavedSearchOwner
-    );
-
-    for(@session_fields) {
-        $query{$_} = $DECODED_ARGS->{$_} unless defined $query{$_};
-        $query{$_} = $current->{$_} unless defined $query{$_};
-    }
-
-    if ($DECODED_ARGS->{'SavedSearchLoadSubmit'}) {
-        $query{'SavedChartSearchId'} = $DECODED_ARGS->{'SavedSearchLoad'};
-    }
-
-    if ($DECODED_ARGS->{'SavedSearchSave'}) {
-        $query{'SavedChartSearchId'} = $saved_search->{'SearchId'};
-    }
-
-}
-
-foreach (@search_fields) {
-    if ( ref $default_value->{$_} ) {
-        $query{$_} = ref $ARGS{$_} ? $ARGS{$_} : [ $ARGS{$_} ];
-        $query{$_} = $default_value->{$_}
-            unless defined $query{$_} && defined $query{$_}[0];
-    }
-    else {
-        $query{$_} = ref $ARGS{$_} ? $ARGS{$_} : $ARGS{$_};
-        $query{$_} = $default_value->{$_}
-            unless defined $query{$_};
-    }
-}
-
-$m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
-
-</%init>
-<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs, QueryArgs => \%query &>
-<& /Elements/ListActions, actions => \@actions &>
-
-% $m->callback( ARGSRef => \%ARGS, CallbackName => 'BeforeChart' );
-
-<& /Search/Elements/Chart, %ARGS &>
-
-% $m->callback( ARGSRef => \%ARGS, CallbackName => 'AfterChart' );
-
-<div class="chart-meta">
-<div class="chart-type">
-
-<form method="get" action="<% RT->Config->Get('WebPath') %>/RTIR/Search/Reporting.html">
-<input type="hidden" class="hidden" name="Lifecycle" value="<% $query{Lifecycle} // '' %>" />
-<input type="hidden" class="hidden" name="Query" value="<% $query{Query} // '' %>" />
-<input type="hidden" class="hidden" name="SavedChartSearchId" value="<% $saved_search->{SearchId} || 'new' %>" />
-
-<&| /Widgets/TitleBox, title => loc('Group by'), class => "chart-group-by" &>
-<fieldset><legend><% loc('Group tickets by') %></legend>
-<& /Search/Elements/SelectGroupBy,
-    Name => 'GroupBy',
-    Query => $query{Query},
-    Default => $query{'GroupBy'}[0],
-    &>
-</fieldset>
-<fieldset><legend><% loc('and then') %></legend>
-<& /Search/Elements/SelectGroupBy,
-    Name => 'GroupBy',
-    Query => $query{Query},
-    Default => $query{'GroupBy'}[1] // q{},
-    ShowEmpty => 1,
-    &>
-</fieldset>
-<fieldset><legend><% loc('and then') %></legend>
-<& /Search/Elements/SelectGroupBy,
-    Name => 'GroupBy',
-    Query => $query{Query},
-    Default => $query{'GroupBy'}[2] // q{},
-    ShowEmpty => 1,
-    &>
-</fieldset>
-</&>
-
-<&| /Widgets/TitleBox, title => loc("Calculate"), class => "chart-calculate" &>
-
-<fieldset><legend><% loc('Calculate values of') %></legend>
-<& /Search/Elements/SelectChartFunction, Default => $query{'ChartFunction'}[0] &>
-</fieldset>
-<fieldset><legend><% loc('and then') %></legend>
-<& /Search/Elements/SelectChartFunction, Default => $query{'ChartFunction'}[1] // q{}, ShowEmpty => 1 &>
-</fieldset>
-<fieldset><legend><% loc('and then') %></legend>
-<& /Search/Elements/SelectChartFunction, Default => $query{'ChartFunction'}[2] // q{}, ShowEmpty => 1 &>
-</fieldset>
-
-</&>
-
-<&| /Widgets/TitleBox, title => loc('Picture'), class => "chart-picture" &>
-<input name="ChartStyle" type="hidden" value="<% $query{ChartStyle} %>" />
-<label><% loc('Style') %>: <& /Search/Elements/SelectChartType, Default => $query{ChartStyle} =~ /^(pie|bar|table)\b/ ? $1 : undef &></label>
-<span class="width">
-<label><% loc("Width") %>: <input type="text" name="Width" value="<% $query{'Width'} || q{} %>"> <% loc("px") %></label>
-</span>
-<span class="height">
-  &#x00d7;
-  <label><% loc("Height") %>: <input type="text" name="Height" value="<% $query{'Height'} || q{} %>"> <% loc("px") %></label>
-</span>
-<div class="include-table">
-    <input type="checkbox" name="ChartStyleIncludeTable" <% $query{ChartStyle} =~ /\btable\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include data table') %>
-</div>
-<div class="include-sql">
-    <input type="checkbox" name="ChartStyleIncludeSQL" <% $query{ChartStyle} =~ /\bsql\b/ ? 'checked="checked"' : '' |n %>> <% loc('Include TicketSQL query') %>
-</div>
-</&>
-<script type="text/javascript">
-var updateChartStyle = function() {
-    var val = jQuery(".chart-picture [name=ChartType]").val();
-    if ( val != 'table' && jQuery(".chart-picture [name=ChartStyleIncludeTable]").is(':checked') ) {
-        val += '+table';
-    }
-    if ( jQuery(".chart-picture [name=ChartStyleIncludeSQL]").is(':checked') ) {
-        val += '+sql';
-    }
-    jQuery(".chart-picture [name=ChartStyle]").val(val);
-};
-jQuery(".chart-picture [name=ChartType]").change(function(){
-    var t = jQuery(this);
-    t.closest("form").find("[name=Height]").closest(".height").toggle( t.val() == 'bar' );
-    t.closest("form").find("[name=Width]").closest(".width").toggle( t.val() !== 'table' );
-    t.closest("form .chart-picture").find("div.include-table").toggle( t.val() !== 'table' );
-    updateChartStyle();
-}).change();
-
-jQuery(".chart-picture [name=ChartStyleIncludeTable]").change( updateChartStyle );
-jQuery(".chart-picture [name=ChartStyleIncludeSQL]").change( updateChartStyle );
-</script>
-
-<& /Elements/Submit, Label => loc('Update Chart'), Name => 'Update' &>
-</form>
-
-</div>
-<div class="saved-search">
-    <& /Widgets/SavedSearch:show, %ARGS, Action => 'Reporting.html', self => $saved_search, Title => loc('Saved charts') &>
-</div>
-</div>
diff --git a/html/RTIR/Search/Results.html b/html/RTIR/Search/Results.html
deleted file mode 100644
index b081a21b..00000000
--- a/html/RTIR/Search/Results.html
+++ /dev/null
@@ -1,136 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} || 0 &>
-<& /Elements/Tabs &>
-<& /Elements/ListActions &>
-
-<& Elements/ShowResults,
-    %ARGS,
-    Lifecycle      => $Lifecycle,
-    BaseURL        => $BaseURL,
-    BaseQuery      => $BaseQuery,
-    Query          => $Query,
-    Format         => $Format,
-    Rows           => $Rows,
-    Page           => $Page,
-    OrderBy        => $OrderBy,
-    Order          => $Order,
-    ShowNavigation => 1,
-    UpdateSession  => 1,
-&>
-<div align="right">
-
-<%INIT>
-my $title = loc("Results");
-
-# Some queries, like those from the RTIR home page, won't provide Lifecycle
-if ( not $Lifecycle ){
-    my ($our, @lifecycles) = RT::IR->OurQuery( $Query );
-    if ( $our and scalar @lifecycles == 1 ) {
-        # If we found only one lifecycle, set it so we get the right Format below
-        $Lifecycle = $lifecycles[0];
-    }
-}
-
-my $Type = RT::IR::TicketType( Lifecycle => $Lifecycle ) || '';
-$Format ||= RT->Config->Get('RTIRSearchResultFormats')->{ $Type . 'Default' };
-
-# Warn if old CFs are found
-my $location;
-if ($SavedSearchId) {
-    $location = $SavedSearchId eq 'new' ?
-            "an ad-hoc search" : "Saved Search $SavedSearchId";
-    $location .= " executed by ".$session{'CurrentUser'}->Name;
-}
-RT::IR::Config::CheckObsoleteCFSyntax($Format,$location);
-RT::IR::Config::CheckObsoleteCFSyntax($Query,$location);
-
-if ( $Type ) {
-    if ( $Query ) {
-        $BaseQuery ||= RT::IR->Query( Lifecycle => $Lifecycle );
-    }
-    else {
-        $Query = RT::IR->ActiveQuery( Lifecycle => $Lifecycle );
-    }
-}
-
-my $BaseURL = RT::IR->HREFTo("Search/Results.html");
-$BaseURL .= '?'. $m->comp( '/Elements/QueryString', Lifecycle => $Lifecycle )
-    if $Lifecycle;
-
-# Read from user preferences
-my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
-
-$Format      ||= $prefs->{'Format'} || RT->Config->Get('DefaultSearchResultFormat');
-$Order       ||= $prefs->{'Order'} || RT->Config->Get('DefaultSearchResultOrder');
-$OrderBy     ||= $prefs->{'OrderBy'} || RT->Config->Get('DefaultSearchResultOrderBy');
-
-
-if ( !defined($Rows) ) {
-    if (defined $ARGS{'RowsPerPage'} ) {
-        $Rows = $ARGS{'RowsPerPage'};
-    } elsif ( defined $prefs->{'RowsPerPage'} ) {
-        $Rows = $prefs->{'RowsPerPage'};
-    } else {
-        $Rows = 50;
-    }
-}
-
-</%INIT>
-<%ARGS>
-$Lifecycle     => ''
-$BaseQuery => ''
-$Query     => undef
-$Format    => undef
-$Rows      => undef
-$Page      => 1
-$OrderBy   => undef
-$Order     => undef
-$SavedSearchId => undef
-$SavedChartSearchId => undef
-</%ARGS>
diff --git a/html/RTIR/Search/index.html b/html/RTIR/Search/index.html
deleted file mode 100644
index f45fd962..00000000
--- a/html/RTIR/Search/index.html
+++ /dev/null
@@ -1,83 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs, SearchArgs => $query_state{query} &>
-
-<& Elements/BuildQuery,
-    %query_state,
-
-    BaseQuery  => $BaseQuery,
-    ResultPage => $ResultPage,
-
-    actions => \@results, 
-&>
-
-<%INIT>
-
-my %query_state = $m->comp('Elements/ProcessQuery',
-    %ARGS,
-    BaseQuery  => $BaseQuery,
-    ResultPage => $ResultPage,
-);
-
-my @results = @{ delete $query_state{'results'} };
-</%INIT>
-
-<%ARGS>
-$title      => loc("Build Search")
-$ResultPage => RT::IR->HREFTo('Search/Results.html')
-$NewQuery   => 0
-
-$BaseQuery  => ''
-$Query      => ''
-$Format     => undef
-$Rows       => 50
-$Page       => 1
-$OrderBy    => RT->Config->Get('DefaultSearchResultOrderBy')
-$Order      => RT->Config->Get('DefaultSearchResultOrder')
-</%ARGS>
diff --git a/html/RTIR/Tools/Elements/LookupSummary b/html/RTIR/Tools/Elements/LookupSummary
index 91b936af..dfd6abe7 100644
--- a/html/RTIR/Tools/Elements/LookupSummary
+++ b/html/RTIR/Tools/Elements/LookupSummary
@@ -89,10 +89,11 @@ if ( $TicketObj ) {
 my @box_actions;
 push @box_actions, {
     title => loc('Search'),
-    path => RT::IR->HREFTo("Search/Refine.html?". $m->comp('/Elements/QueryString', 
-        Lifecycle => $Lifecycle,
-        Query => $Query,
-    )),
+    path => "/Search/Build.html?". $m->comp('/Elements/QueryString',
+        ExtraQueryParams => 'RTIR',
+        RTIR => 1,
+        Query => join( ' AND ', RT::IR->Query( Lifecycle => $Lifecycle ), "( $Query )" ),
+    ),
 };
 if ( $TicketObj && RT::IR->IsIncidentQueue($TicketObj->QueueObj) 
     && $Lifecycle ne RT::IR->lifecycle_incident
diff --git a/html/RTIR/index.html b/html/RTIR/index.html
index f320d399..77909674 100644
--- a/html/RTIR/index.html
+++ b/html/RTIR/index.html
@@ -72,9 +72,9 @@ if ( defined $q && length $q ) {
     );
 
     return RT::Interface::Web::Redirect(
-        RT::IR->HREFTo('Search/Results.html?Query='
+        RT->Config->Get('WebURL') .  'Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Query='
         . $m->interp->apply_escapes( $query, 'u' )
-    ));
+    );
 }
 
 my @results;
diff --git a/lib/RT/IR/Web.pm b/lib/RT/IR/Web.pm
index 14fd57b0..27b870f4 100644
--- a/lib/RT/IR/Web.pm
+++ b/lib/RT/IR/Web.pm
@@ -59,6 +59,40 @@ package HTML::Mason::Commands;
 #
 $RT::Interface::Web::Scrubber::ALLOWED_ATTRIBUTES{'href'} = '^(?:'.$RT::Interface::Web::Scrubber::ALLOWED_ATTRIBUTES{'href'} . ')|(?:__RTIRTicketURI__)';
 
+sub RTIRDefaultSearchParams {
+    my %args = (
+        ARGSRef => undef,
+        @_,
+    );
+
+    my ( $our, @lifecycles );
+    my $ARGSRef = $args{ARGSRef};
+
+    if ( $ARGSRef->{Query} ) {
+        ( $our, @lifecycles ) = RT::IR->OurQuery( $ARGSRef->{'Query'} );
+    }
+    elsif ( $ARGSRef->{Lifecycle} ) {
+        $our = RT::IR->OurLifecycle( $ARGSRef->{Lifecycle} );
+        push @lifecycles, $ARGSRef->{Lifecycle};
+    }
+
+    return unless $our;
+
+    my $lifecycle;
+    $lifecycle = $lifecycles[0] if @lifecycles == 1;
+
+    my %params;
+    if ( !$ARGSRef->{Format} ) {
+        my $type = RT::IR::TicketType( Lifecycle => $lifecycle ) || '';
+        $params{Format} = RT->Config->Get('RTIRSearchResultFormats')->{ $type . 'Default' };
+    }
+
+    if ( !$ARGSRef->{Query} ) {
+        $params{Query} = RT::IR->ActiveQuery( Lifecycle => $lifecycle );
+    }
+    return %params;
+}
+
 package RT::IR::Web;
 RT::Base->_ImportOverlays();
 1;

commit 5c81bb5640dc1d4941ea595d457de1c6432f1caf
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 3 03:26:48 2020 +0800

    Update tests accordingly as we switched to RT search

diff --git a/t/002-test-reject.t b/t/002-test-reject.t
index d6d7648b..bac39ea8 100644
--- a/t/002-test-reject.t
+++ b/t/002-test-reject.t
@@ -141,7 +141,7 @@ diag "test that after bulk reject links to incidents are still there" if $ENV{'T
     }
 
     $agent->display_ticket( $id);
-    $agent->follow_link_ok({text => "Incident Reports", url_regex => qr/RTIR/}, "Followed 'Incident Reports' link");
+    $agent->follow_link_ok({text => "Incident Reports", url => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle=incident_reports'}, "Followed 'Incident Reports' link");
     while($agent->content() !~ m{Display.html\?id=$id">$id</a>}) {
         last unless $agent->follow_link(text => 'Next');
     }
diff --git a/t/searches/cf.t b/t/searches/cf.t
index 34feda4d..0193f50d 100644
--- a/t/searches/cf.t
+++ b/t/searches/cf.t
@@ -9,7 +9,7 @@ my $m = default_agent();
 $m->create_incident( { Subject => "Spam Incident", }, { ('Classification' => 'Spam') } );
 $m->create_incident( { Subject => "Ham Incident", },  { ('Classification' => 'Query') } );
 
-$m->get_ok('/RTIR/Search/');
+$m->get_ok('/Search/Build.html');
 $m->form_name( 'BuildQuery' );
 
 $m->submit_form(
diff --git a/t/searches/menu.t b/t/searches/menu.t
index 86055538..8402d62d 100644
--- a/t/searches/menu.t
+++ b/t/searches/menu.t
@@ -38,7 +38,7 @@ for my $type ( 'incident', 'ir', 'investigation', 'countermeasure' ) {
 
     }
 
-    $m->follow_link_ok( { text => "Edit Search", $type eq 'incident' ? () : ( n => 2 ) } );
+    $m->follow_link_ok( { text => "Edit Search" } );
     $m->form_name('BuildQuery');
     $m->submit_form_ok(
         {
@@ -76,7 +76,7 @@ for my $type ( 'incident', 'ir', 'investigation', 'countermeasure' ) {
         ok( $m->find_link( url_regex => qr{/RTIR/Incident/Display.html\?id=$incident_id$} ),
             "found link to incident $incident_id" );
     }
-    $m->follow_link_ok( { text => "Edit Search", n => 2 } );
+    $m->follow_link_ok( { text => "Edit Search" } );
     $m->form_name('BuildQuery');
     my ($input_query) = $m->find_all_inputs( name => 'Query' );
     is( $input_query->value, q{( Lifecycle = 'incidents' ) AND Status = 'open' AND HasMember != 2}, 'Query input is correct' );
@@ -111,7 +111,7 @@ for my $type ( 'incident', 'ir', 'investigation', 'countermeasure' ) {
         ok( $m->find_link( url_regex => qr{/RTIR/Display.html\?id=$ir$} ), "found link to incident report $ir" );
     }
 
-    $m->follow_link_ok( { text => "Edit Search", n => 2 } );
+    $m->follow_link_ok( { text => "Edit Search" } );
     $m->form_name('BuildQuery');
     my ($input_query) = $m->find_all_inputs( name => 'Query' );
     is(
@@ -157,7 +157,7 @@ for my $type ( 'incident', 'ir', 'investigation', 'countermeasure' ) {
     my ($checkbox) = $m->find_all_inputs( name => 'SelectedReports' );
     is( $checkbox->value, $ticket{ir}[0], '$ticket{ir}[0] is checked' );
 
-    $m->follow_link_ok( { text => "Edit Search", n => 2 } );
+    $m->follow_link_ok( { text => "Edit Search" } );
     $m->form_name('BuildQuery');
     $m->submit_form_ok(
         {
@@ -202,7 +202,7 @@ for my $type ( 'incident', 'ir', 'investigation', 'countermeasure' ) {
     ($checkbox) = $m->find_all_inputs( name => 'SelectedCountermeasures' );
     is( $checkbox->value, $ticket{countermeasure}[0], '$ticket{countermeasure}[0] is checked' );
 
-    $m->follow_link_ok( { text => "Edit Search", n => 2 } );
+    $m->follow_link_ok( { text => "Edit Search" } );
     $m->form_name('BuildQuery');
     $m->submit_form_ok(
         {

commit 6c975f66c67cb4d197045021e8ba60869eed3259
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 8 06:54:20 2020 +0800

    Drop "New Search" from search page menu
    
    "New Search" was not quite useful considering it's also in top menu. We
    have migrated to RT search, and it's good to keep page menu as
    consistent as possible.

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 7684c2c6..94c4054d 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -95,13 +95,6 @@ if ( $m->request_comp->path =~ m{^/Search/} ) {
         my $lifecycle = '';
         $lifecycle = $lifecycles[ 0 ] if @lifecycles == 1;
 
-        if ( $args{Query} ) {
-            PageMenu()->child(
-                new_search => title => loc( 'New Search' ),
-                path       => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1',
-            );
-        }
-
         if ( $lifecycle eq RT::IR->lifecycle_incident ) {
             PageMenu()->child(
                 report     => title => loc( 'Report' ),

-----------------------------------------------------------------------


More information about the rt-commit mailing list