[Rt-commit] rtir branch, 2.9-trunk, updated. 2.6.1rc1-286-g0856505

Ruslan Zakirov ruz at bestpractical.com
Fri Aug 19 16:48:37 EDT 2011


The branch, 2.9-trunk has been updated
       via  0856505bdf77a27630c5a8737de74e6da3cbe911 (commit)
       via  aa7393ca452aa771cf0f7da5455c2a4d81e88896 (commit)
       via  f5f83ccb29df03afc522509eac6e44a019866311 (commit)
       via  c890825de4bf499dbb2c3ac9692a731136a1c2ac (commit)
       via  4d39134fc09eb9b2f8443e3ea6bc38a0dd385638 (commit)
       via  ce5c5fd26eea4e743bd5fe209dd4440b205bd2b4 (commit)
       via  055870e80905b2add683ede8ee33eaac5df069bd (commit)
       via  70cb9222f1d2fc99f85620aefe52cbf4af662a55 (commit)
       via  fefad442bf5a1bd11e93b9a77cb4f11744942797 (commit)
       via  f2019d27554f88908a65c3dfc8df66f995be55a2 (commit)
       via  e15cf462050503351043ea3ee79437e09c920df8 (commit)
       via  b0fd36a746821b1bdb111891e79b7650b283180a (commit)
       via  d5530f6c4a1e28430a92e431b40c7dfb7b70fbb1 (commit)
       via  55a05fa15a3ee494e23a47b4975b7e98128c6abd (commit)
       via  d94b43dea58bab38e6ef4592a147af803f8ef907 (commit)
       via  e0112b52f061b005f1c25afbd0037ecac194608e (commit)
       via  2d05a6d9899b6eb1d2e648713c7a6a5fe3aef340 (commit)
       via  f43078a9fe6444ea4d7ed3b6b8188a088d1c070a (commit)
       via  38ed15f88ee93b4169a10edad87f036f4b4d47a1 (commit)
      from  3a0ae38c53ec34aeaba7f4064691c08574ed49b1 (commit)

Summary of changes:
 TODO.porting_over_RT4                              |   14 +--
 .../Elements/EditCustomFields/MassageCustomFields  |    3 -
 html/RTIR/Create.html                              |    2 +-
 html/RTIR/Elements/AddWatchers                     |    6 +-
 html/RTIR/Elements/ChildSummary                    |    3 +-
 html/RTIR/Elements/DueIncidents                    |    4 +-
 html/RTIR/Elements/IncidentSummary                 |    3 +-
 html/RTIR/Elements/MergeWith                       |    4 +-
 html/RTIR/Elements/NewReports                      |    7 +-
 html/RTIR/Elements/NobodyDueIncidents              |    8 +-
 html/RTIR/Elements/QueueSummary                    |    5 +-
 html/RTIR/Elements/ShowChildren                    |    8 +-
 html/RTIR/Elements/States                          |    3 -
 html/RTIR/Elements/Type                            |   54 ------
 html/RTIR/Elements/UserDueIncidents                |    8 +-
 html/RTIR/Forward.html                             |    6 +-
 html/RTIR/Incident/BulkAbandon.html                |    6 +-
 html/RTIR/Incident/Children/Refine.html            |    2 +-
 html/RTIR/Incident/Children/index.html             |   27 ++--
 html/RTIR/Incident/Display.html                    |    2 +-
 html/RTIR/Incident/Elements/ShowChildren           |   28 ++--
 html/RTIR/Incident/Reply.html                      |   10 +-
 html/RTIR/Link/FromIncident/Refine.html            |    2 +-
 html/RTIR/Link/FromIncident/index.html             |    4 +-
 html/RTIR/Link/ToIncident/Refine.html              |    2 +-
 html/RTIR/Link/ToIncident/index.html               |    4 +-
 html/RTIR/Merge/Refine.html                        |    2 +-
 html/RTIR/Merge/index.html                         |    4 +-
 html/RTIR/Report/BulkReject.html                   |    4 +-
 html/RTIR/Search/Reporting.html                    |    4 +-
 html/RTIR/Search/Results.html                      |    4 +-
 html/RTIR/Split.html                               |    2 +-
 html/RTIR/Tools/Elements/ToolFormIframe            |    2 +-
 html/RTIR/Tools/Elements/ToolFormTraceroute        |    2 +-
 html/RTIR/Tools/Elements/ToolFormWhois             |    2 +-
 html/RTIR/Tools/ScriptedAction.html                |    6 +-
 html/RTIR/index.html                               |   11 +-
 lib/RT/Action/RTIR_OpenParent.pm                   |   15 +-
 lib/RT/IR.pm                                       |  169 +++++++-------------
 39 files changed, 154 insertions(+), 298 deletions(-)
 delete mode 100644 html/RTIR/Elements/States
 delete mode 100644 html/RTIR/Elements/Type

- Log -----------------------------------------------------------------
commit 38ed15f88ee93b4169a10edad87f036f4b4d47a1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 18 22:28:54 2011 +0400

    make sure all <input>s have type attribute

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index f2c69da..53db5e0 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -79,7 +79,7 @@
 % } else {
   <tr class="incident">
     <td class="label"><&|/l&>Incident</&>:</td>
-    <td class="value"><input name="Incident" size="16" maxsize="16" value="<% $Incident || '' %>" /></td>
+    <td class="value"><input type="text" name="Incident" size="16" maxsize="16" value="<% $Incident || '' %>" /></td>
   </tr>
   <tr>
     <td class="label">&nbsp;</td>
diff --git a/html/RTIR/Elements/AddWatchers b/html/RTIR/Elements/AddWatchers
index b6389a5..c88a3cf 100644
--- a/html/RTIR/Elements/AddWatchers
+++ b/html/RTIR/Elements/AddWatchers
@@ -46,13 +46,13 @@
 <tr><td><&|/l&>Type</&></td><td><&|/l&>Email</&></td></tr>
 
 <tr><td><& /Elements/SelectWatcherType, Name => "WatcherTypeEmail1" &></td>
-<td><input name="WatcherAddressEmail1" size="15" /></td></tr>
+<td><input type="text" name="WatcherAddressEmail1" size="15" /></td></tr>
 
 <tr><td><& /Elements/SelectWatcherType, Name => "WatcherTypeEmail2" &></td>
-<td><input name="WatcherAddressEmail2" size="15" /></td></tr>
+<td><input type="text" name="WatcherAddressEmail2" size="15" /></td></tr>
 
 <tr><td><& /Elements/SelectWatcherType, Name => "WatcherTypeEmail3" &></td>
-<td><input name="WatcherAddressEmail3" size="15" /></td></tr>
+<td><input type="text" name="WatcherAddressEmail3" size="15" /></td></tr>
 
 </table>
 
diff --git a/html/RTIR/Forward.html b/html/RTIR/Forward.html
index 9a5ade8..e945f7d 100644
--- a/html/RTIR/Forward.html
+++ b/html/RTIR/Forward.html
@@ -13,13 +13,13 @@
 <td><% $TicketObj->Subject %></td></tr>
 
 <tr><td align="right"><&|/l&>To</&>:</td>
-<td><input name="To" size="60" value="<% $ARGS{'To'} %>" /></td></tr>
+<td><input type="text" name="To" size="60" value="<% $ARGS{'To'} %>" /></td></tr>
 
 <tr><td align="right"><&|/l&>Cc</&>:</td>
-<td><input name="Cc" size="60" value="<% $ARGS{'Cc'} %>" /></td></tr>
+<td><input type="text" name="Cc" size="60" value="<% $ARGS{'Cc'} %>" /></td></tr>
 
 <tr><td align="right"><&|/l&>BCc</&>:</td>
-<td><input name="Bcc" size="60" value="<% $ARGS{'Bcc'} %>" /></td></tr>
+<td><input type="text" name="Bcc" size="60" value="<% $ARGS{'Bcc'} %>" /></td></tr>
 
 </table>
 
diff --git a/html/RTIR/Tools/Elements/ToolFormIframe b/html/RTIR/Tools/Elements/ToolFormIframe
index 3c650ec..884dafc 100644
--- a/html/RTIR/Tools/Elements/ToolFormIframe
+++ b/html/RTIR/Tools/Elements/ToolFormIframe
@@ -2,7 +2,7 @@
   <input type="hidden" name="ticket" value="<% $TicketObj->id %>" />
     <span class="label"><%loc('Research Tool')%>:</span>
     <span class="input">
-      <input size="30" name="q" value="<% $q %>" /> at
+      <input type="text" size="30" name="q" value="<% $q %>" /> at
       <select name="ResearchTool">
 % for my $tool (grep {defined } keys %$research_tools) {
         <option value="<%$tool%>" <%$tool eq $ResearchTool ? 'SELECTED' : ''%>><% $research_tools->{$tool}->{FriendlyName} %></option>
diff --git a/html/RTIR/Tools/Elements/ToolFormTraceroute b/html/RTIR/Tools/Elements/ToolFormTraceroute
index a405e20..335f1c4 100644
--- a/html/RTIR/Tools/Elements/ToolFormTraceroute
+++ b/html/RTIR/Tools/Elements/ToolFormTraceroute
@@ -1,6 +1,6 @@
 <form action="Traceroute.html" method="get" target="_blank">
     <span class="label">Traceroute to:</span>
-    <span class="input"><input size="30" name="q" value="<% $q %>" /></span>
+    <span class="input"><input type="text" size="30" name="q" value="<% $q %>" /></span>
     <input type="submit" value="<%loc('Go')%>" />
 </form>
 <%args>
diff --git a/html/RTIR/Tools/Elements/ToolFormWhois b/html/RTIR/Tools/Elements/ToolFormWhois
index 6dac889..ffddb54 100644
--- a/html/RTIR/Tools/Elements/ToolFormWhois
+++ b/html/RTIR/Tools/Elements/ToolFormWhois
@@ -3,7 +3,7 @@
   <tr>
     <span class="label">WHOIS:</span>
     <span class="input">
-      <input size="30" name="q" value="<% $q %>" /> at 
+      <input type="text" size="30" name="q" value="<% $q %>" /> at 
       <select name="server">
 <%PERL>
 foreach my $s ( sort grep $servers->{ $_ }, keys %{ $servers } ) {
diff --git a/html/RTIR/Tools/ScriptedAction.html b/html/RTIR/Tools/ScriptedAction.html
index 26eae2d..ffbb380 100644
--- a/html/RTIR/Tools/ScriptedAction.html
+++ b/html/RTIR/Tools/ScriptedAction.html
@@ -83,7 +83,7 @@ foreach my $entry ( map $whois_servers->{ $_ }, sort keys %{$whois_servers} ) {
       <&|/l&>Contact Field</&>:
     </td>
     <td>
-      <input name="field" value="<% $ARGS{'field'} %>" />
+      <input type="text" name="field" value="<% $ARGS{'field'} %>" />
     </td>
   </tr>
   <tr>
@@ -125,7 +125,7 @@ foreach my $entry ( map $whois_servers->{ $_ }, sort keys %{$whois_servers} ) {
     <&|/l&>Argument</&>:
   </td>
   <td>
-    <input name="TemplateArg" size="60" value="<% $ARGS{'TemplateArg'} %>" />
+    <input type="text" name="TemplateArg" size="60" value="<% $ARGS{'TemplateArg'} %>" />
   </td>
 </tr>
   <tr>
@@ -160,7 +160,7 @@ foreach my $entry ( map $whois_servers->{ $_ }, sort keys %{$whois_servers} ) {
       <&|/l&>Subject</&>:
     </td>
     <td>
-      <input size="60" name="Subject" value="<%$ARGS{'Subject'} || $Incident->Subject%>" />
+      <input type="text" size="60" name="Subject" value="<%$ARGS{'Subject'} || $Incident->Subject%>" />
     </td>
   </tr>
 % }

commit f43078a9fe6444ea4d7ed3b6b8188a088d1c070a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 18 23:38:11 2011 +0400

    update todo

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index c9aa5f3..df38110 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -32,8 +32,6 @@
 
 * scan code for hardcoded statuses
 
-* use ShowSimplifiedRecipients
-
 * tranasaction custom fields
 
 * protection from mail loops by filtering watchers' email addresses on
@@ -68,19 +66,13 @@
 
 * html/RTIR/Forward.html still uses plain inputs for addresses
 
-* make sure all <input> tags have type
-
 * re-use CSS squishing
 
-=== INVESTIGATE
+* Elements/ChildSummary and Elements/IncidentSummary share the same query
 
-* we use different components for EditCustomFields
+* use latest simple search API in html/RTIR/index.html
 
-* we pass OnCreate inconsistently into EditCustomFields
-
-* Suspect that failed custom field validation check
-  or gnupg error that returns back to create page will
-  dropp fields to defaults
+=== INVESTIGATE
 
 * Rename some fields to variants with spaces
 

commit 2d05a6d9899b6eb1d2e648713c7a6a5fe3aef340
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 18 23:57:20 2011 +0400

    use NewQuery method, we deleted the component

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index d205a04..84910eb 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -81,7 +81,7 @@
 </table>
 
 <%INIT>
-my $Query = $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue);
+my $Query = RT::IR->NewQuery( Queue => $Queue );
 my @conditions = ();
 my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 49161c5..2f60b00 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -89,7 +89,7 @@ while ( my $Ticket = $session{'tickets'}->Next ) {
     }
 }
 
-my $Query = $m->comp('/RTIR/Elements/NewQuery', Queue => 'Incidents');
+my $Query = RT::IR->NewQuery(Queue => 'Incidents');
 my @conditions = ();
 my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
diff --git a/html/RTIR/Elements/NobodyDueIncidents b/html/RTIR/Elements/NobodyDueIncidents
index 0f5c79f..0001b86 100644
--- a/html/RTIR/Elements/NobodyDueIncidents
+++ b/html/RTIR/Elements/NobodyDueIncidents
@@ -2,7 +2,7 @@
 <%INIT>
 my $Title = loc( "Most due unowned incidents" );
 unless ( $Query ) {
-    $Query = $m->comp( '/RTIR/Elements/NewQuery', Queue => 'Incidents' );
+    $Query = RT::IR->NewQuery( Queue => 'Incidents' );
     $Query = join ' AND ', map "( $_ )", grep $_,
              $Query,
              '( Owner.id = '. $RT::Nobody->id .' )';
diff --git a/html/RTIR/Elements/UserDueIncidents b/html/RTIR/Elements/UserDueIncidents
index c63d0ff..8db180b 100644
--- a/html/RTIR/Elements/UserDueIncidents
+++ b/html/RTIR/Elements/UserDueIncidents
@@ -2,7 +2,7 @@
 <%INIT>
 my $Title = loc( "Most due incidents owned by [_1]", $Owner->Name );
 unless ( $Query ) {
-    $Query = $m->comp( '/RTIR/Elements/NewQuery', Queue => 'Incidents' );
+    $Query = RT::IR->NewQuery( Queue => 'Incidents' );
     $Query = join ' AND ', map "( $_ )", grep $_,
              $Query,
              '( Owner.id = '. $Owner->id .')';
diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index 39aab11..d82034f 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -156,8 +156,8 @@ my $BaseURL = "RTIR/Incident/BulkAbandon.html?"
 $Status          => 'abandoned'
 $Queue           => 'Incidents'
 
-$Query           => $m->comp( '/RTIR/Elements/NewQuery', Queue => $Queue );
-$Format          => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'};
+$Query           => RT::IR->NewQuery( Queue => $Queue )
+$Format          => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'}
 $Rows            => 50
 $Page            => 1
 $OrderBy         => 'id'
diff --git a/html/RTIR/Link/FromIncident/index.html b/html/RTIR/Link/FromIncident/index.html
index 17e2b7c..1de360f 100644
--- a/html/RTIR/Link/FromIncident/index.html
+++ b/html/RTIR/Link/FromIncident/index.html
@@ -51,7 +51,7 @@
 $id          => undef
 $Queue       => undef
 
-$Query       => $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue)
+$Query       => RT::IR->NewQuery( Queue => $Queue )
 $Format      => RT->Config->Get('RTIRSearchResultFormats')->{'LinkChildren'}
 $Rows        => 50
 $Page        => 1
diff --git a/html/RTIR/index.html b/html/RTIR/index.html
index dc12311..41e60a4 100644
--- a/html/RTIR/index.html
+++ b/html/RTIR/index.html
@@ -80,7 +80,7 @@ if ( $ARGS{'q'} ) {
         # Any search on queue name or subject will be for new/open tickets only.
         $query = join ' AND ',
                  "Subject LIKE '$query'",
-                 $m->comp( '/RTIR/Elements/NewQuery', Queue => 'Incidents' );
+                 RT::IR->NewQuery( Queue => 'Incidents' );
     }
     return $m->comp(
         '/RTIR/Search/Results.html',

commit e0112b52f061b005f1c25afbd0037ecac194608e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 00:35:48 2011 +0400

    delete unused code

diff --git a/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields b/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
index 66bba5b..f487169 100644
--- a/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
+++ b/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
@@ -7,11 +7,8 @@ $QueueObj => undef
 my $queue = $QueueObj || $TicketObj->QueueObj;
 return unless RT::IR->OurQueue( $queue );
 
-my $on_create = $QueueObj && !($TicketObj && $TicketObj->id);
-
 # We never want to see the RTIR custom fields State and Constituency in the edity ui
 $CustomFields->_OpenParen('RTIR');
-# $CustomFields->Limit( SUBCLAUSE => 'RTIR', ENTRYAGGREGATOR => 'AND', FIELD => 'Name', OPERATOR => '!=', VALUE => 'State');
 $CustomFields->Limit( SUBCLAUSE => 'RTIR', ENTRYAGGREGATOR => 'AND', FIELD => 'Name', OPERATOR => '!=', VALUE => 'Constituency');
 $CustomFields->_CloseParen('RTIR');
 </%init>

commit d94b43dea58bab38e6ef4592a147af803f8ef907
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 00:36:43 2011 +0400

    State and Type in elements are not used anymore

diff --git a/html/RTIR/Elements/States b/html/RTIR/Elements/States
deleted file mode 100644
index 9331e30..0000000
--- a/html/RTIR/Elements/States
+++ /dev/null
@@ -1,3 +0,0 @@
-<%INIT>
-return RT::IR::States( %ARGS );
-</%INIT>
diff --git a/html/RTIR/Elements/Type b/html/RTIR/Elements/Type
deleted file mode 100644
index 7862da5..0000000
--- a/html/RTIR/Elements/Type
+++ /dev/null
@@ -1,54 +0,0 @@
-%# BEGIN LICENSE BLOCK
-%# 
-%# Copyright (c) 1996-2002 Jesse Vincent <jesse at bestpractical.com>
-%# 
-%# (Except where explictly superceded by other copyright notices)
-%# 
-%# 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.
-%# 
-%# 
-%# Unless otherwise specified, all modifications, corrections or
-%# extensions to this work which alter its source code become the
-%# property of Best Practical Solutions, LLC when submitted for
-%# inclusion in the work.
-%# 
-%# 
-%# END LICENSE BLOCK
-<%ONCE>
-my %type = (
-    'Incidents'        => 'Incident',
-    'Incident Reports' => 'Report',
-    'Investigations'   => 'Investigation',
-    'Blocks'           => 'Block',
-);
-</%ONCE>
-<%INIT>
-
-unless( $Queue ) {
-    $TicketObj = LoadTicket($Ticket) if $Ticket && !$TicketObj;
-    if( $TicketObj ) {
-        $Queue = $TicketObj->QueueObj->Name;
-    } else {
-        return ('');
-    }
-}
-
-my $type = $type{$Queue} || '';
-my @states = RT::IR::States( Queue => $Queue );
-return ($type, @states);
-
-</%INIT>
-
-<%ARGS>
-$Ticket => undef
-$TicketObj => undef
-$Queue => undef
-</%ARGS>

commit 55a05fa15a3ee494e23a47b4975b7e98128c6abd
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 00:45:48 2011 +0400

    s/RT::IR::States/RT::IR->Statuses/
    
    * separate initial and active
    * support Queue argument as object or list of objects

diff --git a/html/RTIR/Elements/QueueSummary b/html/RTIR/Elements/QueueSummary
index 6c74ee2..2b563a3 100644
--- a/html/RTIR/Elements/QueueSummary
+++ b/html/RTIR/Elements/QueueSummary
@@ -42,9 +42,8 @@ Description => loc('RTIR queues summary')
 my @queues = ('Incidents', 'Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('DisableBlocksQueue');
 my %states;
-$states{$_} = [ RT::IR::States( Queue => $_ ) ] foreach @queues;
-my %seen;
-my @states = sort grep !$seen{$_}++, map @$_, values %states;
+$states{$_} = [ RT::IR->Statuses( Queue => $_ ) ] foreach @queues;
+my @states = RT::IR->Statuses( Queue => \@queues );
 </%ONCE>
 <%INIT>
 my $Tickets = RT::Tickets->new($session{'CurrentUser'});
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index b50c471..4d1bb18 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -37,8 +37,8 @@ return if $Queue eq 'Blocks' && RT->Config->Get('RTIR_DisableBlocksQueue');
 my $id = $IncidentObj->id;
 my $EscapedQueue = $m->interp->apply_escapes( $Queue, 'u' );
 
-my @active_states = RT::IR::States( Queue => $Queue );
-my @inactive_states = RT::IR::States( Queue => $Queue, Active => 0, Inactive => 1 );
+my @active_states = RT::IR->Statuses( Queue => $Queue );
+my @inactive_states = RT::IR->Statuses( Queue => $Queue, Initial => 0, Active => 0, Inactive => 1 );
 
 my $active = RT::Tickets->new( $session{'CurrentUser'} );
 $active->FromSQL(
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index efea732..cc939f6 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -132,9 +132,9 @@ if ($DefaultStatus eq 'resolved') {
 my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
-my $ActiveStatesQuery =
-    join ' OR ', map "Status = '$_'",
-    RT::IR::States( Queue => \@queues );
+my $ActiveStatesQuery = RT::IR->BaseQuery(
+    Status => [ RT::IR->Statuses( Queue => \@queues ) ],
+);
 
 $Query ||= "( $ActiveStatesQuery )";
 
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 911caa9..b9e7a3d 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -55,6 +55,7 @@ our $VERSION = '2.6.1rc1';
 
 use Business::Hours;
 use Business::SLA;
+use Scalar::Util qw(blessed);
 
 
 # XXX: we push config metadata into RT, but we need
@@ -184,48 +185,52 @@ sub TicketType {
     return;
 }
 
-=head2 States
+=head2 Statuses
 
-Return sorted list of unique states for one, many or all RTIR queues.
+Return sorted list of unique statuses for one, many or all RTIR queues.
 
 Takes arguments 'Queue', 'Active' and 'Inactive'. By default returns
-only active states. Queue can be an array reference to list several
+initial and active statuses. Queue can be an array reference to list several
 queues.
 
 Examples:
 
-    States()
-    States( Queue => 'Blocks' );
-    States( Queue => [ 'Blocks', 'Incident Reports' ] );
-    States( Active => 0, Inactive => 1 );
+    RT::IR->Statuses()
+    RT::IR->Statuses( Queue => 'Blocks' );
+    RT::IR->Statuses( Queue => [ 'Blocks', 'Incident Reports' ] );
+    RT::IR->Statuses( Active => 0, Inactive => 1 );
 
 =cut
 
-sub States {
-    my %arg = ( Queue => undef, Active => 1, Inactive => 0, @_ );
-
-    my @queues = !$arg{'Queue'} ? (@QUEUES)
-        : ref $arg{'Queue'}? @{ $arg{'Queue'} } : ( $arg{'Queue'} );
-    
-    my @states;
-    foreach my $name (@queues) {
-        my $queue = RT::Queue->new($RT::SystemUser);
-        $queue->Load($name);
-        if ( $queue->id ) {
-            push @states, $queue->Lifecycle->Valid('initial', 'active')
-                if $arg{'Active'};
-            push @states, $queue->Lifecycle->Inactive
-                if $arg{'Inactive'};
-        }
-        else {
-            $RT::Logger->error( "failed to load queue $name" );
+sub Statuses {
+    my $self = shift;
+    my %arg = ( Queue => undef, Initial => 1, Active => 1, Inactive => 0, @_ );
+
+    my @queues = !$arg{'Queue'} 
+        ? (@QUEUES)
+        : ref $arg{'Queue'} && !blessed $arg{'Queue'}
+        ? @{ $arg{'Queue'} }
+        : ( $arg{'Queue'} );
+
+    my (@initial, @active, @inactive);
+    foreach my $queue (@queues) {
+        unless ( blessed $queue ) {
+            my $tmp = RT::Queue->new($RT::SystemUser);
+            $tmp->Load( $queue );
+            $RT::Logger->error( "failed to load queue $queue" )
+                unless $tmp->id;
+            $queue = $tmp;
         }
+        next unless $queue->id;
 
+        my $cycle = $queue->Lifecycle;
+        push @initial, $cycle->Initial if $arg{'Initial'};
+        push @active, $cycle->Active if $arg{'Active'};
+        push @inactive, $cycle->Inactive if $arg{'Inactive'};
     }
 
     my %seen = ();
-    @states = sort grep !$seen{$_}++, @states;
-    return @states;
+    return grep !$seen{$_}++, @initial, @active, @inactive;
 }
 
 sub NewQuery {
@@ -239,7 +244,7 @@ sub NewQuery {
     my @states = ref $args{'states'}? @{ $args{'states'} } : ( $args{'states'} );
     @states = grep $_, @states;
     unless( @states ) {
-        @states = RT::IR::States( %args );
+        @states = $self->Statuses( %args );
     }
 
     my @add_states = ref $args{'add_states'}? @{ $args{'add_states'} } : ( $args{'add_states'} );
@@ -260,6 +265,7 @@ sub BaseQuery {
         Queue        => undef,
         Status       => undef,
         Active       => undef,
+        Inactive     => undef,
         Exclude      => undef,
         HasMember    => undef,
         HasNoMember  => undef,

commit d5530f6c4a1e28430a92e431b40c7dfb7b70fbb1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 01:03:23 2011 +0400

    support Initial/Active/Inactive in BaseQuery

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index b9e7a3d..e96b28e 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -278,24 +278,9 @@ sub BaseQuery {
     if ( $args{'Queue'} ) {
         my $qname = ref $args{'Queue'} ? $args{'Queue'}->Name : $args{'Queue'};
         $res = "Queue = '$qname'";
-        if ( defined $args{'Active'} ) {
-            my $queue = $args{'Queue'};
-            unless ( ref $args{'Queue'} ) {
-                my $queue = RT::Queue->new( RT->SystemUser );
-                $queue->Load( $args{'Queue'} );
-                unless ( $queue->id ) {
-                    $RT::Logger->error("Couldn't load queue '$args{Queue}'");
-                    $queue = undef;
-                }
-            }
-
-            if ( $queue ) {
-                my @statuses = $args{'Active'}
-                    ? $queue->ActiveStatusArray
-                    : $queue->InactiveStatusArray;
-                $res .= ' AND ('. join( ' OR ', map "Status = '$_'", @statuses ) .')';
-            }
-        }
+    }
+    if ( !$args{'Status'} && ( $args{'Initial'} || $args{'Active'} || $args{'Inactive'} ) ) {
+        $args{'Status'} = [ $self->Statuses( %args ) ];
     }
     if ( my $s = $args{'Status'} ) {
         $res .= ' AND ' if $res;

commit b0fd36a746821b1bdb111891e79b7650b283180a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 01:05:16 2011 +0400

    delete RT::IR->ChildrenQuery

diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index 4f6ea2f..b313e07 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -74,10 +74,10 @@ my $Type = RT::IR::TicketType( Queue => $Queue );
 $Format ||= RT->Config->Get('RTIRSearchResultFormats')->{'Child' . $Type};
 
 my $children = RT::Tickets->new( $session{'CurrentUser'} );
-$children->FromSQL( RT::IR->ChildrenQuery(
-    Queue  => $Queue,
-    Ticket => $Ticket,
-    States => [@States],
+$children->FromSQL( RT::IR->BaseQuery(
+    Queue    => $Queue,
+    MemberOf => $Ticket,
+    Status   => [@States],
 ));
 
 </%INIT>
diff --git a/html/RTIR/Incident/Children/index.html b/html/RTIR/Incident/Children/index.html
index 312781f..85e9e5f 100644
--- a/html/RTIR/Incident/Children/index.html
+++ b/html/RTIR/Incident/Children/index.html
@@ -73,31 +73,24 @@ unless ( $Incident->CurrentUserHasRight('ShowTicket') ) {
     Abort("No permission to view ticket");
 }
 
-my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
-$QueueObj->Load( $Queue );
-unless ( $QueueObj->id ) {
-    Abort("Couldn't load queue '$Queue'");
-}
-
- at States = $QueueObj->Lifecycle->Valid('initial', 'active')
-    unless @States;
-
 my $Title = loc("$Queue for Incident #[_1]: [_2]", $id, $Incident->Subject);
 
 my $delete = $Incident->CurrentUserHasRight('ModifyTicket') ? 1: 0;
 
+ at States = RT::IR->Statuses( Queue => $Queue )
+    unless @States;
+
 my $children = RT::Tickets->new( $session{'CurrentUser'} );
-$children->FromSQL( RT::IR->ChildrenQuery(
-    Queue  => $Queue,
-    Ticket => $Incident,
-    States => [@States],
+$children->FromSQL( RT::IR->BaseQuery(
+    Queue    => $Queue,
+    MemberOf => $Incident,
+    Status   => [@States],
 ) );
 
 my $all_children = RT::Tickets->new( $session{'CurrentUser'} );
-$all_children->FromSQL( RT::IR->ChildrenQuery(
-    Queue  => $Queue,
-    Ticket => $Incident,
-    States => [ $QueueObj->Lifecycle->Valid ],
+$all_children->FromSQL( RT::IR->BaseQuery(
+    Queue    => $Queue,
+    MemberOf => $Incident,
 ) );
 </%INIT>
 <%ARGS>
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index 4d1bb18..4ac4d9b 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -41,22 +41,18 @@ my @active_states = RT::IR->Statuses( Queue => $Queue );
 my @inactive_states = RT::IR->Statuses( Queue => $Queue, Initial => 0, Active => 0, Inactive => 1 );
 
 my $active = RT::Tickets->new( $session{'CurrentUser'} );
-$active->FromSQL(
-    RT::IR->ChildrenQuery(
-        Queue  => $Queue,
-        Ticket => $IncidentObj,
-        States => [ @active_states ],
-    )
-);
+$active->FromSQL( RT::IR->BaseQuery(
+    Queue    => $Queue,
+    MemberOf => $IncidentObj,
+    Status   => \@active_states,
+));
 
 my $inactive = RT::Tickets->new( $session{'CurrentUser'} );
-$inactive->FromSQL(
-    RT::IR->ChildrenQuery(
-        Queue  => $Queue,
-        Ticket => $IncidentObj,
-        States => [ @inactive_states ],
-    )
-);
+$inactive->FromSQL( RT::IR->BaseQuery(
+    Queue    => $Queue,
+    MemberOf => $IncidentObj,
+    Status   => \@inactive_states,
+));
 
 my $total_count = $active->CountAll + $inactive->CountAll;
 
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index e96b28e..7651116 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -321,24 +321,6 @@ sub BaseQuery {
     return $res;
 }
 
-sub ChildrenQuery {
-    my $self = shift;
-    my %args = (
-        @_
-    );
-
-    my @parts;
-    push @parts, $self->NewQuery(
-        Queue  => $args{'Queue'},
-        states => $args{'States'},
-        add_states => $args{'AddStates'},
-    );
-    push @parts, $self->BaseQuery( Queue => $args{'Queue'} );
-    push @parts, "MemberOf = ". $args{'Ticket'}->id if $args{'Ticket'};
-
-    return join " AND ", map "($_)", @parts;
-}
-
 =head2 Incidents
 
 Takes a ticket and returns collection of all incidents this ticket

commit e15cf462050503351043ea3ee79437e09c920df8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 01:15:45 2011 +0400

    according to RTIR's logic IR stays initial until linking
    
    so we don't need MemberOf IS NULL and can use BaseQuery

diff --git a/html/RTIR/Elements/NewReports b/html/RTIR/Elements/NewReports
index 158abef..20f4729 100644
--- a/html/RTIR/Elements/NewReports
+++ b/html/RTIR/Elements/NewReports
@@ -47,10 +47,7 @@
 <%INIT>
 my $title = loc("New unlinked Incident Reports...");
 
-unless( $Query ) {
-    $Query = RT::IR->NewQuery( Queue => $Queue, states => [ 'new' ] );
-    $Query = join ' AND ', $Query, 'MemberOf IS NULL';
-}
+$Query ||= RT::IR->BaseQuery( Queue => $Queue, Initial => 1 );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Queue   => $Queue,

commit f2019d27554f88908a65c3dfc8df66f995be55a2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:02:41 2011 +0400

    replace direct lifecycle load with Inactive argument

diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index 90e77b7..72f983d 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -70,7 +70,7 @@ sub Commit {
     $parents->FromSQL( RT::IR->BaseQuery(
         Queue     => 'Incidents',
         HasMember => $ticket,
-        Status    => [ RT::Lifecycle->Load('incidents')->Inactive ],
+        Inactive  => 1,
     ) );
     my ($set_to) = RT::Lifecycle->Load('incidents')->Active;
     while (my $member = $parents->Next) {

commit fefad442bf5a1bd11e93b9a77cb4f11744942797
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:03:22 2011 +0400

    use FirstActiveStatus method in OpenParent action

diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index 72f983d..f305611 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -72,10 +72,13 @@ sub Commit {
         HasMember => $ticket,
         Inactive  => 1,
     ) );
-    my ($set_to) = RT::Lifecycle->Load('incidents')->Active;
-    while (my $member = $parents->Next) {
-        my ($res, $msg) = $member->SetStatus( $set_to );
-        $RT::Logger->info("Couldn't open incident: $msg") unless $res;
+    while ( my $parent = $parents->Next ) {
+        my $status = $parent->FirstActiveStatus;
+        next unless $status;
+
+        my ($res, $msg) = $parent->SetStatus( $status );
+        $RT::Logger->info("Couldn't open incident: $msg")
+            unless $res;
     }
     return 1;
 }

commit 70cb9222f1d2fc99f85620aefe52cbf4af662a55
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:05:01 2011 +0400

    add And argument in BaseQuery

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 7651116..29533bd 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -272,6 +272,7 @@ sub BaseQuery {
         MemberOf     => undef,
         NotMemberOf  => undef,
         Constituency => undef,
+        And          => undef,
         @_
     );
     my $res = '';
@@ -318,6 +319,10 @@ sub BaseQuery {
         $res .= ' AND ' if $res;
         $res .= "CustomField.{Constituency} = '". $t->FirstCustomFieldValue('Constituency') ."'";
     }
+    if ( my $c = $args{'And'} ) {
+        $res .= ' AND ' if $res;
+        $res .= join ' AND ', ref $c? @$c : ($c);
+    }
     return $res;
 }
 

commit 055870e80905b2add683ede8ee33eaac5df069bd
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:05:21 2011 +0400

    simplify NewQuery to mean initial and active tickets
    
    we don't have code that uses it differently

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 29533bd..4455aa4 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -234,31 +234,9 @@ sub Statuses {
 }
 
 sub NewQuery {
-    my $self = shift;
-    my %args = (
-        Queue => undef,
-        states => undef,
-        add_states => undef,
-        @_,
-    );
-    my @states = ref $args{'states'}? @{ $args{'states'} } : ( $args{'states'} );
-    @states = grep $_, @states;
-    unless( @states ) {
-        @states = $self->Statuses( %args );
-    }
-
-    my @add_states = ref $args{'add_states'}? @{ $args{'add_states'} } : ( $args{'add_states'} );
-    my %seen = ();
-    @states =  grep !$seen{$_}++, map lc, grep $_, @states, @add_states;
-
-    my $query = join " OR ",
-                map "'Status' = '$_'",
-                @states;
-    $query = "( $query )" if $query;
-    return $query;
+    return (shift)->BaseQuery( Initial => 1, Active => 1, @_ );
 }
 
-
 sub BaseQuery {
     my $self = shift;
     my %args = (
@@ -338,7 +316,7 @@ sub Incidents {
     my $ticket = shift;
 
     my $res = RT::Tickets->new( $ticket->CurrentUser );
-    $res->FromSQL( "Queue = 'Incidents' AND HasMember = " . $ticket->id );
+    $res->FromSQL( $self->BaseQuery( Queue => 'Incidents', HasMember => $ticket ) );
     return $res;
 }
 

commit ce5c5fd26eea4e743bd5fe209dd4440b205bd2b4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:18:32 2011 +0400

    use array in BaseQuery instead of string, join later

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 4455aa4..7ab845d 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -253,37 +253,31 @@ sub BaseQuery {
         And          => undef,
         @_
     );
-    my $res = '';
+    my @res;
     if ( $args{'Queue'} ) {
         my $qname = ref $args{'Queue'} ? $args{'Queue'}->Name : $args{'Queue'};
-        $res = "Queue = '$qname'";
+        push @res, "Queue = '$qname'";
     }
     if ( !$args{'Status'} && ( $args{'Initial'} || $args{'Active'} || $args{'Inactive'} ) ) {
         $args{'Status'} = [ $self->Statuses( %args ) ];
     }
     if ( my $s = $args{'Status'} ) {
-        $res .= ' AND ' if $res;
-        $res .= '('. join( ' OR ', map "Status = '$_'", ref $s? (@$s) : ($s) ) .')';
+        push @res, '('. join( ' OR ', map "Status = '$_'", ref $s? (@$s) : ($s) ) .')';
     }
     if ( my $t = $args{'Exclude'} ) {
-        $res .= ' AND ' if $res;
-        $res .= '('. join( ' AND ', map "id != '$_'", map int $_, ref $t? (@$t) : ($t) ) .')';
+        push @res, '('. join( ' AND ', map "id != '$_'", map int $_, ref $t? (@$t) : ($t) ) .')';
     }
     if ( my $t = $args{'HasMember'} ) {
-        $res .= ' AND ' if $res;
-        $res .= 'HasMember = '. (ref $t? $t->id : int $t);
+        push @res, 'HasMember = '. (ref $t? $t->id : int $t);
     }
     if ( my $t = $args{'HasNoMember'} ) {
-        $res .= ' AND ' if $res;
-        $res .= 'HasMember != '. (ref $t? $t->id : int $t);
+        push @res, 'HasMember != '. (ref $t? $t->id : int $t);
     }
     if ( my $t = $args{'NotMemberOf'} ) {
-        $res .= ' AND ' if $res;
-        $res .= 'MemberOf != '. (ref $t? $t->id : int $t);
+        push @res, 'MemberOf != '. (ref $t? $t->id : int $t);
     }
     if ( my $t = $args{'MemberOf'} ) {
-        $res .= ' AND ' if $res;
-        $res .= 'MemberOf = '. (ref $t? $t->id : int $t);
+        push @res, 'MemberOf = '. (ref $t? $t->id : int $t);
     }
     if (
         my $t = $args{'Constituency'}
@@ -294,14 +288,12 @@ sub BaseQuery {
             $tmp->Load( $t );
             $t = $tmp;
         }
-        $res .= ' AND ' if $res;
-        $res .= "CustomField.{Constituency} = '". $t->FirstCustomFieldValue('Constituency') ."'";
+        push @res, "CustomField.{Constituency} = '". $t->FirstCustomFieldValue('Constituency') ."'";
     }
     if ( my $c = $args{'And'} ) {
-        $res .= ' AND ' if $res;
-        $res .= join ' AND ', ref $c? @$c : ($c);
+        push @res, ref $c? @$c : ($c);
     }
-    return $res;
+    return join ' AND ', @res;
 }
 
 =head2 Incidents

commit 4d39134fc09eb9b2f8443e3ea6bc38a0dd385638
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:20:47 2011 +0400

    support multiple queues in BaseQuery

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 7ab845d..5f76697 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -255,8 +255,13 @@ sub BaseQuery {
     );
     my @res;
     if ( $args{'Queue'} ) {
-        my $qname = ref $args{'Queue'} ? $args{'Queue'}->Name : $args{'Queue'};
-        push @res, "Queue = '$qname'";
+        my @queues = ref $arg{'Queue'} && !blessed $arg{'Queue'}
+            ? @{ $arg{'Queue'} }
+            : ( $arg{'Queue'} )
+        ;
+        push @res, map "($_)", join ' OR ', map "Queue = '$_'",
+            map blessed $_? $_->Name : $_,
+            @queues;
     }
     if ( !$args{'Status'} && ( $args{'Initial'} || $args{'Active'} || $args{'Inactive'} ) ) {
         $args{'Status'} = [ $self->Statuses( %args ) ];

commit c890825de4bf499dbb2c3ac9692a731136a1c2ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 19 04:32:10 2011 +0400

    use new API in NewQuery and BaseQuery

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index 84910eb..051ef1f 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -81,7 +81,6 @@
 </table>
 
 <%INIT>
-my $Query = RT::IR->NewQuery( Queue => $Queue );
 my @conditions = ();
 my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
@@ -97,7 +96,7 @@ if ( defined $q && length $q ) {
         push @conditions, "Content LIKE '$q'";
     }
 }
-$Query = join ' AND ', map "( $_ )", grep $_, $Query, @conditions;
+my $Query = RT::IR->NewQuery( Queue => $Queue, And => \@conditions );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Query   => $Query,
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 2f60b00..c20db64 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -89,7 +89,6 @@ while ( my $Ticket = $session{'tickets'}->Next ) {
     }
 }
 
-my $Query = RT::IR->NewQuery(Queue => 'Incidents');
 my @conditions = ();
 my $lookup_cf_not_applies = 0;
 if ( defined $q && length $q ) {
@@ -105,7 +104,7 @@ if ( defined $q && length $q ) {
         push @conditions, "Content LIKE '$q'";
     }
 }
-$Query = join ' AND ', map "( $_ )", grep $_, $Query, @conditions;
+my $Query = RT::IR->NewQuery( Queue => 'Incidents', And => \@conditions );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Query => $Query,
diff --git a/html/RTIR/Elements/NobodyDueIncidents b/html/RTIR/Elements/NobodyDueIncidents
index 0001b86..ca398bb 100644
--- a/html/RTIR/Elements/NobodyDueIncidents
+++ b/html/RTIR/Elements/NobodyDueIncidents
@@ -1,13 +1,7 @@
 <& /RTIR/Elements/DueIncidents, %ARGS, Title => $Title, Query => $Query &>
 <%INIT>
 my $Title = loc( "Most due unowned incidents" );
-unless ( $Query ) {
-    $Query = RT::IR->NewQuery( Queue => 'Incidents' );
-    $Query = join ' AND ', map "( $_ )", grep $_,
-             $Query,
-             '( Owner.id = '. $RT::Nobody->id .' )';
-}
-
+$Query ||= RT::IR->NewQuery( Queue => 'Incidents', And => 'Owner.id = '. $RT::Nobody->id );
 </%INIT>
 <%ARGS>
 $Query => undef
diff --git a/html/RTIR/Elements/UserDueIncidents b/html/RTIR/Elements/UserDueIncidents
index 8db180b..01d7b38 100644
--- a/html/RTIR/Elements/UserDueIncidents
+++ b/html/RTIR/Elements/UserDueIncidents
@@ -1,13 +1,7 @@
 <& /RTIR/Elements/DueIncidents, %ARGS, Title => $Title, Query => $Query &>
 <%INIT>
 my $Title = loc( "Most due incidents owned by [_1]", $Owner->Name );
-unless ( $Query ) {
-    $Query = RT::IR->NewQuery( Queue => 'Incidents' );
-    $Query = join ' AND ', map "( $_ )", grep $_,
-             $Query,
-             '( Owner.id = '. $Owner->id .')';
-}
-
+$Query ||= RT::IR->NewQuery( Queue => 'Incidents', And => 'Owner.id = '. $Owner->id );
 </%INIT>
 <%ARGS>
 $Owner => $session{'CurrentUser'}
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index cc939f6..3d32915 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -132,9 +132,7 @@ if ($DefaultStatus eq 'resolved') {
 my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
-my $ActiveStatesQuery = RT::IR->BaseQuery(
-    Status => [ RT::IR->Statuses( Queue => \@queues ) ],
-);
+my $ActiveStatesQuery = RT::IR->NewQuery( Queue => \@queues );
 
 $Query ||= "( $ActiveStatesQuery )";
 
diff --git a/html/RTIR/Split.html b/html/RTIR/Split.html
index bd25adc..4c63ec5 100644
--- a/html/RTIR/Split.html
+++ b/html/RTIR/Split.html
@@ -55,7 +55,7 @@ if ( $m->comp_exists("/RTIR/$Type/Split.html") ) {
 
 my $incident;
 my $incidents = RT::Tickets->new( $session{'CurrentUser'} );
-$incidents->FromSQL( RT::IR->BaseQuery( Queue => 'Incidents', Active => 1 ) );
+$incidents->FromSQL( RT::IR->NewQuery( Queue => 'Incidents', HasMember => $TicketObj ) );
 if ( my $obj = $incidents->First ) {
     $incident = $obj->id;
 }
diff --git a/html/RTIR/index.html b/html/RTIR/index.html
index 41e60a4..fb32109 100644
--- a/html/RTIR/index.html
+++ b/html/RTIR/index.html
@@ -68,9 +68,10 @@ if ( $ARGS{'q'} ) {
         $query ||= 'id = 0';
     }
     elsif ( $query =~ /^\s*($RE{net}{IPv4})\s*$/o && RT::IR->CustomFields('IP') ) {
-
-        $query = join ' OR ', map "Queue = '$_'", ('Incidents', 'Incident Reports', 'Investigations', 'Blocks');
-        $query = "($query) AND 'CustomField.{IP}' = '$1'";
+        $query = RT::IR->BaseQuery(
+            Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
+            And => "'CustomField.{IP}' = '$1'",
+        );
         return $m->comp(
             '/RTIR/Search/Results.html',
             Query => $query,
@@ -78,9 +79,7 @@ if ( $ARGS{'q'} ) {
     }
     else {
         # Any search on queue name or subject will be for new/open tickets only.
-        $query = join ' AND ',
-                 "Subject LIKE '$query'",
-                 RT::IR->NewQuery( Queue => 'Incidents' );
+        $query = RT::IR->NewQuery( Queue => 'Incidents', And => "Subject LIKE '$query'" );
     }
     return $m->comp(
         '/RTIR/Search/Results.html',

commit f5f83ccb29df03afc522509eac6e44a019866311
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 00:37:54 2011 +0400

    typos

diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index 21322b9..aecf135 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -86,7 +86,7 @@
 % foreach my $queue ( 'Incident Reports', 'Investigations', 'Blocks' ) {
 <& /RTIR/Incident/Elements/ShowChildren,
     IncidentObj => $TicketObj,
-    Queue       => $Queue,
+    Queue       => $queue,
 &>
 % }
 
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 5f76697..d3f40da 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -255,9 +255,9 @@ sub BaseQuery {
     );
     my @res;
     if ( $args{'Queue'} ) {
-        my @queues = ref $arg{'Queue'} && !blessed $arg{'Queue'}
-            ? @{ $arg{'Queue'} }
-            : ( $arg{'Queue'} )
+        my @queues = ref $args{'Queue'} && !blessed $args{'Queue'}
+            ? @{ $args{'Queue'} }
+            : ( $args{'Queue'} )
         ;
         push @res, map "($_)", join ' OR ', map "Queue = '$_'",
             map blessed $_? $_->Name : $_,

commit aa7393ca452aa771cf0f7da5455c2a4d81e88896
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 00:46:27 2011 +0400

    rename BaseQuery and NewQuery methods

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index 051ef1f..67f4e0c 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -96,7 +96,7 @@ if ( defined $q && length $q ) {
         push @conditions, "Content LIKE '$q'";
     }
 }
-my $Query = RT::IR->NewQuery( Queue => $Queue, And => \@conditions );
+my $Query = RT::IR->ActiveQuery( Queue => $Queue, And => \@conditions );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Query   => $Query,
diff --git a/html/RTIR/Elements/DueIncidents b/html/RTIR/Elements/DueIncidents
index b1b004d..2515fcb 100644
--- a/html/RTIR/Elements/DueIncidents
+++ b/html/RTIR/Elements/DueIncidents
@@ -59,8 +59,8 @@ my $QueryString = $m->comp('/Elements/QueryString',
 </%INIT>
 <%ARGS>
 $Title           => loc("Most due incidents")
-$BaseQuery       => RT::IR->BaseQuery( Queue => 'Incidents' )
-$Query           => RT::IR->NewQuery( Queue => 'Incidents' )
+$BaseQuery       => RT::IR->Query( Queue => 'Incidents' )
+$Query           => RT::IR->ActiveQuery( Queue => 'Incidents' )
 $Format          => RT->Config->Get('RTIRSearchResultFormats')->{'DueIncidents'}
 $Rows            => RT->Config->Get('DefaultSummaryRows', $session{'CurrentUser'})
 $Page            => 1
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index c20db64..8420ce5 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -104,7 +104,7 @@ if ( defined $q && length $q ) {
         push @conditions, "Content LIKE '$q'";
     }
 }
-my $Query = RT::IR->NewQuery( Queue => 'Incidents', And => \@conditions );
+my $Query = RT::IR->ActiveQuery( Queue => 'Incidents', And => \@conditions );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Query => $Query,
diff --git a/html/RTIR/Elements/MergeWith b/html/RTIR/Elements/MergeWith
index a17ece8..b79d71e 100644
--- a/html/RTIR/Elements/MergeWith
+++ b/html/RTIR/Elements/MergeWith
@@ -16,8 +16,8 @@
 my $Type = RT::IR::TicketType( Queue => $Queue );
 $Title ||= $Type .'s';
 
-$Query ||= RT::IR->NewQuery( Queue => $Queue );
-$BaseQuery ||= RT::IR->BaseQuery( Queue => $Queue, Exclude => $id, Constituency => $Ticket );
+$Query ||= RT::IR->ActiveQuery( Queue => $Queue );
+$BaseQuery ||= RT::IR->Query( Queue => $Queue, Exclude => $id, Constituency => $Ticket );
 
 </%INIT>
       
diff --git a/html/RTIR/Elements/NewReports b/html/RTIR/Elements/NewReports
index 20f4729..f1f227e 100644
--- a/html/RTIR/Elements/NewReports
+++ b/html/RTIR/Elements/NewReports
@@ -47,7 +47,7 @@
 <%INIT>
 my $title = loc("New unlinked Incident Reports...");
 
-$Query ||= RT::IR->BaseQuery( Queue => $Queue, Initial => 1 );
+$Query ||= RT::IR->Query( Queue => $Queue, Initial => 1 );
 
 my $QueryString = $m->comp('/Elements/QueryString',
     Queue   => $Queue,
@@ -70,7 +70,7 @@ my $BulkQS = $m->comp('/Elements/QueryString',
 
 <%ARGS>
 $Queue     => 'Incident Reports'
-$BaseQuery => RT::IR->BaseQuery( Queue => $Queue )
+$BaseQuery => RT::IR->Query( Queue => $Queue )
 $Query     => undef
 $Format    => RT->Config->Get('RTIRSearchResultFormats')->{'NewReports'}
 $Rows      => RT->Config->Get('DefaultSummaryRows', $session{'CurrentUser'})
diff --git a/html/RTIR/Elements/NobodyDueIncidents b/html/RTIR/Elements/NobodyDueIncidents
index ca398bb..7e45668 100644
--- a/html/RTIR/Elements/NobodyDueIncidents
+++ b/html/RTIR/Elements/NobodyDueIncidents
@@ -1,7 +1,7 @@
 <& /RTIR/Elements/DueIncidents, %ARGS, Title => $Title, Query => $Query &>
 <%INIT>
 my $Title = loc( "Most due unowned incidents" );
-$Query ||= RT::IR->NewQuery( Queue => 'Incidents', And => 'Owner.id = '. $RT::Nobody->id );
+$Query ||= RT::IR->ActiveQuery( Queue => 'Incidents', And => 'Owner.id = '. $RT::Nobody->id );
 </%INIT>
 <%ARGS>
 $Query => undef
diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index b313e07..1734593 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -74,7 +74,7 @@ my $Type = RT::IR::TicketType( Queue => $Queue );
 $Format ||= RT->Config->Get('RTIRSearchResultFormats')->{'Child' . $Type};
 
 my $children = RT::Tickets->new( $session{'CurrentUser'} );
-$children->FromSQL( RT::IR->BaseQuery(
+$children->FromSQL( RT::IR->Query(
     Queue    => $Queue,
     MemberOf => $Ticket,
     Status   => [@States],
diff --git a/html/RTIR/Elements/UserDueIncidents b/html/RTIR/Elements/UserDueIncidents
index 01d7b38..d796585 100644
--- a/html/RTIR/Elements/UserDueIncidents
+++ b/html/RTIR/Elements/UserDueIncidents
@@ -1,7 +1,7 @@
 <& /RTIR/Elements/DueIncidents, %ARGS, Title => $Title, Query => $Query &>
 <%INIT>
 my $Title = loc( "Most due incidents owned by [_1]", $Owner->Name );
-$Query ||= RT::IR->NewQuery( Queue => 'Incidents', And => 'Owner.id = '. $Owner->id );
+$Query ||= RT::IR->ActiveQuery( Queue => 'Incidents', And => 'Owner.id = '. $Owner->id );
 </%INIT>
 <%ARGS>
 $Owner => $session{'CurrentUser'}
diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index d82034f..5f6aa0f 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -35,7 +35,7 @@
 my $result_set = $m->scomp('/RTIR/Search/Elements/ShowResults',
     Queue         => $Queue,
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->BaseQuery( Queue => $Queue ),
+    BaseQuery     => RT::IR->Query( Queue => $Queue ),
     Query         => $Query,
     DisplayFormat => "__CheckBox__, $Format",
     Format        => $Format,
@@ -156,7 +156,7 @@ my $BaseURL = "RTIR/Incident/BulkAbandon.html?"
 $Status          => 'abandoned'
 $Queue           => 'Incidents'
 
-$Query           => RT::IR->NewQuery( Queue => $Queue )
+$Query           => RT::IR->ActiveQuery( Queue => $Queue )
 $Format          => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'}
 $Rows            => 50
 $Page            => 1
diff --git a/html/RTIR/Incident/Children/Refine.html b/html/RTIR/Incident/Children/Refine.html
index f87fbbd..afd0121 100644
--- a/html/RTIR/Incident/Children/Refine.html
+++ b/html/RTIR/Incident/Children/Refine.html
@@ -5,7 +5,7 @@ return $m->comp(
     ResultPage => 'RTIR/Incident/Children/?'. $m->comp('/Elements/QueryString',
         id => $ARGS{'id'}, Queue => $ARGS{'Queue'},
     ),
-    BaseQuery => RT::IR->BaseQuery(
+    BaseQuery => RT::IR->Query(
         Queue    => $ARGS{'Queue'},
         MemberOf => $ARGS{'id'},
     ),
diff --git a/html/RTIR/Incident/Children/index.html b/html/RTIR/Incident/Children/index.html
index 85e9e5f..ec7fd32 100644
--- a/html/RTIR/Incident/Children/index.html
+++ b/html/RTIR/Incident/Children/index.html
@@ -81,14 +81,14 @@ my $delete = $Incident->CurrentUserHasRight('ModifyTicket') ? 1: 0;
     unless @States;
 
 my $children = RT::Tickets->new( $session{'CurrentUser'} );
-$children->FromSQL( RT::IR->BaseQuery(
+$children->FromSQL( RT::IR->Query(
     Queue    => $Queue,
     MemberOf => $Incident,
     Status   => [@States],
 ) );
 
 my $all_children = RT::Tickets->new( $session{'CurrentUser'} );
-$all_children->FromSQL( RT::IR->BaseQuery(
+$all_children->FromSQL( RT::IR->Query(
     Queue    => $Queue,
     MemberOf => $Incident,
 ) );
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index 4ac4d9b..ddb9203 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -41,14 +41,14 @@ my @active_states = RT::IR->Statuses( Queue => $Queue );
 my @inactive_states = RT::IR->Statuses( Queue => $Queue, Initial => 0, Active => 0, Inactive => 1 );
 
 my $active = RT::Tickets->new( $session{'CurrentUser'} );
-$active->FromSQL( RT::IR->BaseQuery(
+$active->FromSQL( RT::IR->Query(
     Queue    => $Queue,
     MemberOf => $IncidentObj,
     Status   => \@active_states,
 ));
 
 my $inactive = RT::Tickets->new( $session{'CurrentUser'} );
-$inactive->FromSQL( RT::IR->BaseQuery(
+$inactive->FromSQL( RT::IR->Query(
     Queue    => $Queue,
     MemberOf => $IncidentObj,
     Status   => \@inactive_states,
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 3d32915..7631645 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -43,7 +43,7 @@
 <& /RTIR/Search/Elements/ShowResults,
     Queue         => 'Incident Reports',
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->BaseQuery(Queue => 'Incident Reports', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Queue => 'Incident Reports', MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedReports}__, $Format",
     Format        => $Format,
@@ -58,7 +58,7 @@
 <& /RTIR/Search/Elements/ShowResults,
     Queue         => 'Investigations',
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->BaseQuery(Queue => 'Investigations', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Queue => 'Investigations', MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedInvestigations}__, $Format",
     Format        => $Format,
@@ -73,7 +73,7 @@
 <& /RTIR/Search/Elements/ShowResults,
     Queue         => 'Investigations',
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->BaseQuery(Queue => 'Blocks', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Queue => 'Blocks', MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedBlocks}__, $Format",
     Format        => $Format,
@@ -132,7 +132,7 @@ if ($DefaultStatus eq 'resolved') {
 my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
-my $ActiveStatesQuery = RT::IR->NewQuery( Queue => \@queues );
+my $ActiveStatesQuery = RT::IR->ActiveQuery( Queue => \@queues );
 
 $Query ||= "( $ActiveStatesQuery )";
 
diff --git a/html/RTIR/Link/FromIncident/Refine.html b/html/RTIR/Link/FromIncident/Refine.html
index f77168b..5b3e6ab 100644
--- a/html/RTIR/Link/FromIncident/Refine.html
+++ b/html/RTIR/Link/FromIncident/Refine.html
@@ -7,7 +7,7 @@ return $m->comp(
         id    => $ARGS{'id'},
         Queue => $ARGS{'Queue'},
     ),
-    BaseQuery => RT::IR->BaseQuery(
+    BaseQuery => RT::IR->Query(
         Queue       => $ARGS{'Queue'},
         NotMemberOf => $ARGS{'id'},
         Costituency => $ARGS{'id'},
diff --git a/html/RTIR/Link/FromIncident/index.html b/html/RTIR/Link/FromIncident/index.html
index 1de360f..0cd09f3 100644
--- a/html/RTIR/Link/FromIncident/index.html
+++ b/html/RTIR/Link/FromIncident/index.html
@@ -51,7 +51,7 @@
 $id          => undef
 $Queue       => undef
 
-$Query       => RT::IR->NewQuery( Queue => $Queue )
+$Query       => RT::IR->ActiveQuery( Queue => $Queue )
 $Format      => RT->Config->Get('RTIRSearchResultFormats')->{'LinkChildren'}
 $Rows        => 50
 $Page        => 1
@@ -66,7 +66,7 @@ $ARGS{'id'} = $id = $IncidentObj->id;
 my $Type = RT::IR::TicketType( Queue => $Queue );
 my $title = loc("Link selected [_1] to Incident #[_2]", $Type, $id);
 
-my $BaseQuery = RT::IR->BaseQuery(
+my $BaseQuery = RT::IR->Query(
     Queue => $Queue,
     NotMemberOf => $id,
     Constituency => $IncidentObj,
diff --git a/html/RTIR/Link/ToIncident/Refine.html b/html/RTIR/Link/ToIncident/Refine.html
index e285529..acd703b 100644
--- a/html/RTIR/Link/ToIncident/Refine.html
+++ b/html/RTIR/Link/ToIncident/Refine.html
@@ -3,7 +3,7 @@ return $m->comp(
     '/RTIR/Search/Elements/RefinePage',
     %ARGS,
     ResultPage => 'RTIR/Link/ToIncident/?id='. $ARGS{'id'},
-    BaseQuery => RT::IR->BaseQuery(
+    BaseQuery => RT::IR->Query(
         Queue => 'Incidents',
         HasNoMember => $ARGS{'id'},
         Costituency => $ARGS{'id'},
diff --git a/html/RTIR/Link/ToIncident/index.html b/html/RTIR/Link/ToIncident/index.html
index 67e8744..891d4c8 100644
--- a/html/RTIR/Link/ToIncident/index.html
+++ b/html/RTIR/Link/ToIncident/index.html
@@ -64,12 +64,12 @@ $m->callback(CallbackName => 'Initial', %ARGS, Ticket => $Ticket);
 my $Type = RT::IR::TicketType( Ticket => $Ticket );
 my $title = loc( "Link [_1] #[_2] to selected Incident", $Type, $id );
 
-my $BaseQuery = RT::IR->BaseQuery(
+my $BaseQuery = RT::IR->Query(
     Queue => 'Incidents',
     HasNoMember => $id,
     Costituency => $Ticket,
 );
-$Query ||= RT::IR->NewQuery( Queue => 'Incidents' );
+$Query ||= RT::IR->ActiveQuery( Queue => 'Incidents' );
 
 </%INIT>
 <%ARGS>
diff --git a/html/RTIR/Merge/Refine.html b/html/RTIR/Merge/Refine.html
index ac2cecd..d34829d 100644
--- a/html/RTIR/Merge/Refine.html
+++ b/html/RTIR/Merge/Refine.html
@@ -5,7 +5,7 @@ return $m->comp(
     ResultPage => 'RTIR/Merge/?'. $m->comp('/Elements/QueryString',
         id => $ARGS{'id'},
     ),
-    BaseQuery => RT::IR->BaseQuery(
+    BaseQuery => RT::IR->Query(
         Queue        => $ARGS{'Queue'},
         Exclude      => $ARGS{'id'},
         Constituency => $ARGS{'id'},
diff --git a/html/RTIR/Merge/index.html b/html/RTIR/Merge/index.html
index 9ece1cc..4a687f3 100644
--- a/html/RTIR/Merge/index.html
+++ b/html/RTIR/Merge/index.html
@@ -121,8 +121,8 @@ my $Queue = $Ticket->QueueObj->Name;
 
 my $title = loc("Merge [_1] #[_2]: [_3]", $Type, $id, $Ticket->Subject);
 
-$Query      ||= RT::IR->NewQuery( Queue => $Queue );
-my $BaseQuery = RT::IR->BaseQuery( Queue => $Queue, Exclude => $id, Constituency => $Ticket );
+$Query      ||= RT::IR->ActiveQuery( Queue => $Queue );
+my $BaseQuery = RT::IR->Query( Queue => $Queue, Exclude => $id, Constituency => $Ticket );
 
 my %defaults = (
     Format  => $Format,
diff --git a/html/RTIR/Report/BulkReject.html b/html/RTIR/Report/BulkReject.html
index cec61a4..270ae73 100644
--- a/html/RTIR/Report/BulkReject.html
+++ b/html/RTIR/Report/BulkReject.html
@@ -139,8 +139,8 @@ my $BaseURL = "RTIR/Report/BulkReject.html?"
 $Status              => 'rejected'
 $Queue               => 'Incident Reports'
 
-$BaseQuery           => RT::IR->BaseQuery( Queue => $Queue )
-$Query               => RT::IR->NewQuery( Queue => $Queue )
+$BaseQuery           => RT::IR->Query( Queue => $Queue )
+$Query               => RT::IR->ActiveQuery( Queue => $Queue )
 $Format              => RT->Config->Get('RTIRSearchResultFormats')->{'RejectReports'}
 $Rows                => 50
 $Page                => 1
diff --git a/html/RTIR/Search/Reporting.html b/html/RTIR/Search/Reporting.html
index 5444dc1..575c234 100644
--- a/html/RTIR/Search/Reporting.html
+++ b/html/RTIR/Search/Reporting.html
@@ -52,8 +52,8 @@ $ShowChart      => 0
 
 $Queue     => ''
 
-$BaseQuery => RT::IR->BaseQuery( Queue => $Queue )
-$Query     => RT::IR->NewQuery( Queue => $Queue )
+$BaseQuery => RT::IR->Query( Queue => $Queue )
+$Query     => RT::IR->ActiveQuery( Queue => $Queue )
 $Format    => undef
 $Rows      => 50
 $Page      => 1
diff --git a/html/RTIR/Search/Results.html b/html/RTIR/Search/Results.html
index 7120aef..6fa21af 100644
--- a/html/RTIR/Search/Results.html
+++ b/html/RTIR/Search/Results.html
@@ -69,8 +69,8 @@ my $title = loc("Results");
 my $Type = RT::IR::TicketType( Queue => $Queue ) || '';
 $Format ||= RT->Config->Get('RTIRSearchResultFormats')->{ $Type . 'Default' };
 if ( $Type ) {
-    $BaseQuery ||= RT::IR->BaseQuery( Queue => $Queue );
-    $Query     ||= RT::IR->NewQuery( Queue => $Queue );
+    $BaseQuery ||= RT::IR->Query( Queue => $Queue );
+    $Query     ||= RT::IR->ActiveQuery( Queue => $Queue );
 }
 
 my $BaseURL = "RTIR/Search/Results.html";
diff --git a/html/RTIR/Split.html b/html/RTIR/Split.html
index 4c63ec5..768a8c8 100644
--- a/html/RTIR/Split.html
+++ b/html/RTIR/Split.html
@@ -55,7 +55,7 @@ if ( $m->comp_exists("/RTIR/$Type/Split.html") ) {
 
 my $incident;
 my $incidents = RT::Tickets->new( $session{'CurrentUser'} );
-$incidents->FromSQL( RT::IR->NewQuery( Queue => 'Incidents', HasMember => $TicketObj ) );
+$incidents->FromSQL( RT::IR->ActiveQuery( Queue => 'Incidents', HasMember => $TicketObj ) );
 if ( my $obj = $incidents->First ) {
     $incident = $obj->id;
 }
diff --git a/html/RTIR/index.html b/html/RTIR/index.html
index fb32109..7d52b8c 100644
--- a/html/RTIR/index.html
+++ b/html/RTIR/index.html
@@ -68,7 +68,7 @@ if ( $ARGS{'q'} ) {
         $query ||= 'id = 0';
     }
     elsif ( $query =~ /^\s*($RE{net}{IPv4})\s*$/o && RT::IR->CustomFields('IP') ) {
-        $query = RT::IR->BaseQuery(
+        $query = RT::IR->Query(
             Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
             And => "'CustomField.{IP}' = '$1'",
         );
@@ -79,7 +79,7 @@ if ( $ARGS{'q'} ) {
     }
     else {
         # Any search on queue name or subject will be for new/open tickets only.
-        $query = RT::IR->NewQuery( Queue => 'Incidents', And => "Subject LIKE '$query'" );
+        $query = RT::IR->ActiveQuery( Queue => 'Incidents', And => "Subject LIKE '$query'" );
     }
     return $m->comp(
         '/RTIR/Search/Results.html',
diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index f305611..541bec0 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -67,7 +67,7 @@ sub Commit {
     return 1 if $ticket->QueueObj->Lifecycle->IsInactive( $txn->NewValue );
 
     my $parents = RT::Tickets->new( $txn->CurrentUser );
-    $parents->FromSQL( RT::IR->BaseQuery(
+    $parents->FromSQL( RT::IR->Query(
         Queue     => 'Incidents',
         HasMember => $ticket,
         Inactive  => 1,
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index d3f40da..ec2cc61 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -233,11 +233,11 @@ sub Statuses {
     return grep !$seen{$_}++, @initial, @active, @inactive;
 }
 
-sub NewQuery {
-    return (shift)->BaseQuery( Initial => 1, Active => 1, @_ );
+sub ActiveQuery {
+    return (shift)->Query( Initial => 1, Active => 1, @_ );
 }
 
-sub BaseQuery {
+sub Query {
     my $self = shift;
     my %args = (
         Queue        => undef,
@@ -313,7 +313,7 @@ sub Incidents {
     my $ticket = shift;
 
     my $res = RT::Tickets->new( $ticket->CurrentUser );
-    $res->FromSQL( $self->BaseQuery( Queue => 'Incidents', HasMember => $ticket ) );
+    $res->FromSQL( $self->Query( Queue => 'Incidents', HasMember => $ticket ) );
     return $res;
 }
 
@@ -354,7 +354,7 @@ sub IsLinkedToActiveIncidents {
     my $parent = shift;
 
     my $tickets = RT::Tickets->new( $child->CurrentUser );
-    $tickets->FromSQL( $self->BaseQuery(
+    $tickets->FromSQL( $self->Query(
         Queue     => 'Incidents',
         Status    => [ RT::Lifecycle->Load('incidents')->Valid('initial', 'active') ],
         HasMember => $child,

commit 0856505bdf77a27630c5a8737de74e6da3cbe911
Merge: f43078a aa7393c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 00:47:32 2011 +0400

    Merge branch '3.0/queries-generators' into 2.9-trunk


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


More information about the Rt-commit mailing list