[Rt-commit] rtir branch, 2.9-trunk, updated. 2548b9999799e618336e7fff135faca235bc0912

Ruslan Zakirov ruz at bestpractical.com
Tue Jul 12 14:58:58 EDT 2011


The branch, 2.9-trunk has been updated
       via  2548b9999799e618336e7fff135faca235bc0912 (commit)
       via  dc3eceb4e87375ea2a3076439e0e4ed452cbc730 (commit)
       via  9d8e1db846cdc1fbf48c1ae8cb782c2181441395 (commit)
       via  e8e87b1417621a9034d199a93c6c67faf9b1462f (commit)
       via  06aeb5ee5dfd72d85d4f7a6e362a9b282d2625d2 (commit)
       via  9f739d17ea5edadc3829385d4672eee1b365e517 (commit)
       via  e082bad994e8153ea7728a195f3bbfa8f2d2e923 (commit)
       via  7781fb1878951eebb5a305ed32a77c31b0fa4761 (commit)
       via  e68e2c57cf12c4e9a00d47ad0f7265f22201c7e8 (commit)
       via  fdfc443f52ef1c9a9b1a9203e355f3621f443f3b (commit)
       via  c6062fbebecd1bd45338ecfe027f2c44626915f9 (commit)
       via  b6f9546cfa0726adcf72ac75c03d5b79d8782873 (commit)
       via  bb9e71a8709b0902891fb5067ca5cbf235905765 (commit)
       via  35a0f586f2d84c2b7514112668e2a59032fcb35c (commit)
       via  92da38ca6ecc7666f66304c15606800f245efa84 (commit)
       via  8e5cdcb844232b22269c4b7f8b950c572952cadf (commit)
       via  e79cb2cb0c5df6fdb0b43f4cdfffc934def9e580 (commit)
       via  d5bb23b68d8f46921d900168f3b331caa263d988 (commit)
       via  273eb9fc1d815cd3dc8e7b32e1ef487a485fab9d (commit)
       via  c97b2aaa3ae5e53ac055586842298a4ab94decb3 (commit)
       via  479056094bb0b3145204bfdc154eb74a4c7169e5 (commit)
       via  98d2bbbcd0898454c09d52bf84548a4fd1fdb7b8 (commit)
       via  a55f93aec24903ececf6525c2c2d8f41d37675f6 (commit)
       via  455776cc3655f6dae78519f1b04207946043b2ff (commit)
       via  93e23e06346079ead8f8921409ec1888a0b49cb0 (commit)
       via  981ce33cc7f6c3bb3923a7dc13b27c1277c4cdd4 (commit)
      from  b34d0c194d4dc0caeb813626cf1215006c8d9a08 (commit)

Summary of changes:
 MANIFEST                                           |    1 -
 TODO.porting_over_RT4                              |    9 ++-
 etc/RTIR_Config.pm                                 |    2 +-
 etc/initialdata                                    |   49 ++++--------
 etc/upgrade/2.9.0/content                          |    5 +-
 .../RTIR/Elements/RT__Ticket/ColumnMap/Once        |   11 +--
 html/Callbacks/RTIR/autohandler/Default            |    1 -
 html/RTIR/Create.html                              |    3 +-
 html/RTIR/Edit.html                                |    7 +-
 html/RTIR/Elements/AttachReports                   |    6 +-
 html/RTIR/Elements/IncidentSummary                 |    4 +-
 html/RTIR/Elements/ShowIncidents                   |    9 +--
 html/RTIR/Incident/BulkAbandon.html                |    2 +-
 html/RTIR/Incident/Reply.html                      |    4 +-
 html/RTIR/Merge/index.html                         |   28 +++----
 html/RTIR/Report/BulkReject.html                   |    8 +--
 html/RTIR/Reporting/Report.html                    |    9 +--
 lib/RT/Action/RTIR.pm                              |   15 +++-
 lib/RT/Action/RTIR_Activate.pm                     |   32 +++++++
 lib/RT/Action/RTIR_ChangeChildOwnership.pm         |   26 +-----
 lib/RT/Action/RTIR_ChangeParentOwnership.pm        |   34 ++------
 lib/RT/Action/RTIR_FindIP.pm                       |   13 +--
 lib/RT/Action/RTIR_MergeIPs.pm                     |   16 +---
 lib/RT/Action/RTIR_OpenParent.pm                   |   52 ++++--------
 lib/RT/Action/RTIR_ResolveChildren.pm              |   18 +---
 ...TIR_SetBlockState.pm => RTIR_SetBlockStatus.pm} |   50 ++++++-----
 lib/RT/Action/RTIR_SetConstituency.pm              |   17 +----
 lib/RT/Action/RTIR_SetConstituencyGroup.pm         |   18 +----
 lib/RT/Action/RTIR_SetDueBySLA.pm                  |   26 +-----
 lib/RT/Action/RTIR_SetDueCorrespond.pm             |   26 +-----
 lib/RT/Action/RTIR_SetDueIncident.pm               |   24 +-----
 lib/RT/Action/RTIR_SetDueReopen.pm                 |   25 +-----
 lib/RT/Action/RTIR_SetDueToNow.pm                  |   17 +----
 lib/RT/Action/RTIR_SetHowReported.pm               |   25 +-----
 lib/RT/Action/RTIR_SetIncidentReportState.pm       |   86 -------------------
 lib/RT/Action/RTIR_SetIncidentResolution.pm        |   19 +----
 lib/RT/Action/RTIR_SetStartedToNow.pm              |   38 ---------
 lib/RT/Action/RTIR_SetStartsByBizHours.pm          |   10 +--
 lib/RT/Action/RTIR_SetStartsToNow.pm               |   10 +--
 lib/RT/Action/RTIR_SetState.pm                     |   48 -----------
 lib/RT/Action/RTIR_UnsetDue.pm                     |   22 +----
 lib/RT/Condition/RTIR.pm                           |    6 +-
 lib/RT/Condition/RTIR_BlockActivation.pm           |    8 +--
 lib/RT/Condition/RTIR_CloseTicket.pm               |   14 +---
 lib/RT/Condition/RTIR_CustomerResponse.pm          |    9 +--
 lib/RT/Condition/RTIR_LinkingToIncident.pm         |   18 ++---
 lib/RT/Condition/RTIR_Merge.pm                     |    8 +--
 lib/RT/Condition/RTIR_ReopenTicket.pm              |   14 +---
 lib/RT/Condition/RTIR_RequireConstituencyChange.pm |   10 +--
 .../RTIR_RequireConstituencyGroupChange.pm         |    9 +--
 lib/RT/Condition/RTIR_RequireDueChange.pm          |   13 +--
 lib/RT/Condition/RTIR_RequireStateChange.pm        |   86 -------------------
 lib/RT/Condition/RTIR_StaffResponse.pm             |   14 +---
 lib/RT/IR.pm                                       |   88 +++++++++++++++++--
 lib/RT/IR/Config.pm                                |    3 +
 lib/RT/IR/Test/Web.pm                              |    3 +-
 lib/RT/IR/Ticket.pm                                |   55 ------------
 t/011-merge.t                                      |    8 +-
 t/report/status.t                                  |   35 ++++++++
 59 files changed, 357 insertions(+), 869 deletions(-)
 create mode 100644 lib/RT/Action/RTIR_Activate.pm
 rename lib/RT/Action/{RTIR_SetBlockState.pm => RTIR_SetBlockStatus.pm} (72%)
 delete mode 100644 lib/RT/Action/RTIR_SetIncidentReportState.pm
 delete mode 100644 lib/RT/Action/RTIR_SetStartedToNow.pm
 delete mode 100644 lib/RT/Action/RTIR_SetState.pm
 delete mode 100644 lib/RT/Condition/RTIR_RequireStateChange.pm
 delete mode 100644 lib/RT/IR/Ticket.pm
 create mode 100644 t/report/status.t

- Log -----------------------------------------------------------------
commit 981ce33cc7f6c3bb3923a7dc13b27c1277c4cdd4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 10:25:15 2011 +0400

    we delete status transactions earlier

diff --git a/etc/upgrade/2.9.0/content b/etc/upgrade/2.9.0/content
index 7dbdd7c..7905d7a 100644
--- a/etc/upgrade/2.9.0/content
+++ b/etc/upgrade/2.9.0/content
@@ -92,10 +92,7 @@ my @OUR_QUEUES = ('Incidents', 'Incident Reports', 'Investigations', 'Blocks');
             my %done; # in case redo search bite
             while ( my $txn = $txns->Next ) {
                 next if $done{$txn->id}++;
-                if ( $txn->Field eq 'Status' ) {
-                    $txn->Delete;
-                }
-                elsif ($txn->Type eq 'CustomField'
+                if ($txn->Type eq 'CustomField'
                     && $txn->Field == $state{ $ticket->QueueObj->Name }->id )
                 {
                     $txn->__Set( Field => 'Type', Value => 'Set' );

commit 93e23e06346079ead8f8921409ec1888a0b49cb0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 10:29:23 2011 +0400

    update TODO

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 0f83343..ee0d456 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -17,8 +17,12 @@
 * make sure we release DBIx::SB with cud-from-select branch
   merged and depend on it
 
+* upgrade script that sets Status in tickets table from state
+  custom field
+
 * upgrade script that turns changes of the State CFs into
   Status changes
+** it's there, but we should make it faster
 
 === BRINGING UP TO DATE
 

commit 455776cc3655f6dae78519f1b04207946043b2ff
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 10:35:59 2011 +0400

    cleanup HasIncident map
    
    * add missing localization
    * move bits around

diff --git a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
index a1fb3b7..8e6a7bc 100644
--- a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
@@ -50,17 +50,17 @@ $COLUMN_MAP->{'HasIncident'} = {
     title => 'Has Incident?',
     value => sub {
         my $t = shift;
-        my $yesno;
 
         my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND Status != 'rejected'";
-        my $incidents = new RT::Tickets($session{'CurrentUser'});
+        my $incidents = RT::Tickets->new($session{'CurrentUser'});
         $incidents->FromSQL($query);
 
+        my $yesno;
         if ($incidents->Count > 0) {
-            $yesno = '<span class="yes">yes</span>';
+            $yesno = '<span class="yes">'. $t->loc('yes') .'</span>';
         }
         else {
-            $yesno = '<span class="no">no</span>';
+            $yesno = '<span class="no">'. $t->loc('no') .'</span>';
         }
 
         return \$yesno;

commit a55f93aec24903ececf6525c2c2d8f41d37675f6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 10:37:04 2011 +0400

    s/rejected/abandoned/
    
    we still have to use hardcoded status here, requested logic for
    HasIncident column map was "all but rejected/abandoned". When
    we were using State+Status and they were in sync, Status was
    rejected and State was abandoned. Now we only use Status and
    it's abandoned.

diff --git a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
index 8e6a7bc..c781a3f 100644
--- a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
@@ -51,7 +51,7 @@ $COLUMN_MAP->{'HasIncident'} = {
     value => sub {
         my $t = shift;
 
-        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND Status != 'rejected'";
+        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND Status != 'abandoned'";
         my $incidents = RT::Tickets->new($session{'CurrentUser'});
         $incidents->FromSQL($query);
 

commit 98d2bbbcd0898454c09d52bf84548a4fd1fdb7b8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 11:00:24 2011 +0400

    extend BaseQuery with new arguments

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 7c1e86e..45652a3 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -252,11 +252,13 @@ sub BaseQuery {
     my $self = shift;
     my %args = (
         Queue        => undef,
+        Status       => undef,
         Active       => undef,
         Exclude      => undef,
+        HasMember    => undef,
         HasNoMember  => undef,
-        NotMemberOf  => undef,
         MemberOf     => undef,
+        NotMemberOf  => undef,
         Constituency => undef,
         @_
     );
@@ -283,10 +285,18 @@ sub BaseQuery {
             }
         }
     }
+    if ( my $s = $args{'Status'} ) {
+        $res .= ' AND ' if $res;
+        $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) ) .')';
     }
+    if ( my $t = $args{'HasMember'} ) {
+        $res .= ' AND ' if $res;
+        $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);

commit 479056094bb0b3145204bfdc154eb74a4c7169e5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 11:13:20 2011 +0400

    switch RTIR_OpenParent action to lifecycles

diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index dddfe05..c7c53a5 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -75,20 +75,23 @@ Re-open the parent incident
 sub Commit {
     my $self = shift;
 
+    my $txn = $self->TransactionObj;
+
     # If the child becomes not-closed, make sure the Incident is re-opened
-    if ($self->TransactionObj->NewValue ne 'rejected' &&
-        $self->TransactionObj->NewValue ne 'resolved')
-    {
-        my $query = "Queue = 'Incidents'"
-                   ." AND HasMember = " . $self->TicketObj->Id
-                   ." AND (Status = 'rejected' OR Status = 'resolved')";
-
-        my $parents = new RT::Tickets($self->TransactionObj->CurrentUser);
-        $parents->FromSQL($query);
-        while (my $member = $parents->Next) {
-            my ($res, $msg) = $member->Open;
-            $RT::Logger->info("Couldn't open ticket: $msg") unless $res;
-        }
+
+    my $ticket = $self->TicketObj;
+    return 1 if $ticket->QueueObj->Lifecycle->IsInactive( $txn->NewValue );
+
+    my $parents = RT::Tickets->new( $txn->CurrentUser );
+    $parents->FromSQL( RT::IR->BaseQuery(
+        Queue     => 'Incidents',
+        HasMember => $ticket,
+        Status    => [ RT::Lifecycle->Load('incidents')->Inactive ],
+    ) );
+    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;
     }
     return 1;
 }

commit c97b2aaa3ae5e53ac055586842298a4ab94decb3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 11:21:18 2011 +0400

    with lifecycles status is abandoned, not rejected

diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index c5a7863..2116563 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -54,8 +54,8 @@
 
 my $count = 0;
 
-my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id . " AND Status != 'rejected'";
-my $incidents = new RT::Tickets($session{'CurrentUser'});
+my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id . " AND Status != 'abandoned'";
+my $incidents = RT::Tickets->new($session{'CurrentUser'});
 $incidents->FromSQL($query);
 
 my $action = '';

commit 273eb9fc1d815cd3dc8e7b32e1ef487a485fab9d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 11:47:55 2011 +0400

    RelevantIncidents method in RT::IR

diff --git a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
index c781a3f..82d8a8c 100644
--- a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
@@ -50,13 +50,8 @@ $COLUMN_MAP->{'HasIncident'} = {
     title => 'Has Incident?',
     value => sub {
         my $t = shift;
-
-        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND Status != 'abandoned'";
-        my $incidents = RT::Tickets->new($session{'CurrentUser'});
-        $incidents->FromSQL($query);
-
         my $yesno;
-        if ($incidents->Count > 0) {
+        if ( RT::IR->RelevantIncidents( $t )->Count ) {
             $yesno = '<span class="yes">'. $t->loc('yes') .'</span>';
         }
         else {
diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index 2116563..c03984d 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -54,9 +54,7 @@
 
 my $count = 0;
 
-my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id . " AND Status != 'abandoned'";
-my $incidents = RT::Tickets->new($session{'CurrentUser'});
-$incidents->FromSQL($query);
+my $incidents = RT::IR->RelevantIncidents( $Ticket );
 
 my $action = '';
 if ( $Ticket->Owner != $session{'CurrentUser'}->Id ) {
diff --git a/html/RTIR/Report/BulkReject.html b/html/RTIR/Report/BulkReject.html
index b8d2ab1..cec61a4 100644
--- a/html/RTIR/Report/BulkReject.html
+++ b/html/RTIR/Report/BulkReject.html
@@ -98,12 +98,8 @@ if ( $BulkReject ) {
             next;
         }
 
-        # warn if this IR has any incidents
-        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND
-            Status != 'rejected'";
-        my $incidents = new RT::Tickets($session{'CurrentUser'});
-        $incidents->FromSQL($query);
-        if ($incidents->Count > 0) {
+        if ( RT::IR->RelevantIncidents( $t )->Count ) {
+            # warn if this IR has any incidents
             push( @tempresults, [ $id, loc("Warning: already has incident") ] );
         }
 
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 45652a3..8c6f432 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -342,6 +342,26 @@ sub ChildrenQuery {
     return join " AND ", map "($_)", @parts;
 }
 
+=head2 RelevantIncidents
+
+Takes a ticket and returns collection of incidents this ticket
+is member of excluding abandoned incidents.
+
+=cut
+
+sub RelevantIncidents {
+    my $self = shift;
+    my $ticket = shift;
+
+    my $query = "Queue = 'Incidents'"
+        ." AND HasMember = " . $ticket->id
+        ." AND Status != 'abandoned'"
+    ;
+    my $res = RT::Tickets->new( $ticket->CurrentUser );
+    $res->FromSQL( $query );
+    return $res;
+}
+
 sub GetCustomField {
     my $field = shift or return;
     return (__PACKAGE__->CustomFields( $field ))[0];

commit d5bb23b68d8f46921d900168f3b331caa263d988
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:03:22 2011 +0400

    s/$self->TransactionObj/$txn/, shorter code

diff --git a/lib/RT/Action/RTIR_ChangeParentOwnership.pm b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
index f47691a..000eb8a 100644
--- a/lib/RT/Action/RTIR_ChangeParentOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
@@ -72,19 +72,21 @@ Change the ownership of parent incident.
 sub Commit {
     my $self = shift;
 
+    my $txn = $self->TransactionObj;
+
     # change owner of parent Incident(s)
     my $query =  "Queue = 'Incidents'"
                 ." AND HasMember = " . $self->TicketObj->Id
-                ." AND Owner != ". $self->TransactionObj->NewValue;
+                ." AND Owner != ". $txn->NewValue;
     my $parents = new RT::Tickets( $self->CreatorCurrentUser );
     $parents->FromSQL($query);
 
     while ( my $incident = $parents->Next ) {
         my ($res, $msg);
-        if ($self->TransactionObj->NewValue == $self->TransactionObj->Creator) {
+        if ($txn->NewValue == $txn->Creator) {
             ($res, $msg) = $incident->Steal;
         } else {
-            ($res, $msg) = $incident->SetOwner($self->TransactionObj->NewValue);
+            ($res, $msg) = $incident->SetOwner($txn->NewValue);
         }
         $RT::Logger->info("Couldn't set owner: $msg") unless $res;
     }

commit e79cb2cb0c5df6fdb0b43f4cdfffc934def9e580
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:10:50 2011 +0400

    RT::IR->Incidents method

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 97cda5a..9799eeb 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -312,8 +312,7 @@ my $parentvalue = '';
 if ( $IncidentObj ) {
     $parentvalue = $IncidentObj->Id;
 } elsif ( $SplitObj ) {
-    my $incidents = RT::Tickets->new( $session{'CurrentUser'} );
-    $incidents->FromSQL( "Queue = 'Incidents' AND HasMember = " . $SplitObj->Id );
+    my $incidents = RT::IR->Incidents( $SplitObj );
     while ( my $incident = $incidents->Next ) {
         $parentvalue .= ' ' if $parentvalue;
         $parentvalue .= $incident->Id;
diff --git a/html/RTIR/Edit.html b/html/RTIR/Edit.html
index 4d8232d..de7d304 100644
--- a/html/RTIR/Edit.html
+++ b/html/RTIR/Edit.html
@@ -158,13 +158,10 @@ $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
 
 my $constituency_cf = RT::IR->CustomFields( Constituency => Ticket => $Ticket );
 my $constituency_propagation = RT->Config->Get('_RTIR_Constituency_Propagation');
+
 my $has_parent = 0;
 if ( $constituency_propagation eq 'reject' ) {
-    my $query = "Queue = 'Incidents' AND HasMember = ". $Ticket->id;
-    my $tickets = RT::Tickets->new( $RT::SystemUser );
-    $tickets->FromSQL( $query );
-    $tickets->RowsPerPage(1);
-    $has_parent = $tickets->First ? 1 : 0;
+    $has_parent = RT::IR->Incidents( $Ticket )->Count;
 }
 
 if ( $SaveChanges && !$OnlySearchForPeople ) {
diff --git a/html/RTIR/Elements/AttachReports b/html/RTIR/Elements/AttachReports
index a04b5b6..60e32cd 100644
--- a/html/RTIR/Elements/AttachReports
+++ b/html/RTIR/Elements/AttachReports
@@ -19,11 +19,7 @@ my $type = RT::IR::TicketType( Ticket => $Ticket );
 if ( $type eq 'Incident' ) {
     push @parents, $Ticket->id;
 } else {
-    my $tickets = RT::Tickets->new( $Ticket->CurrentUser );
-    $tickets->FromSQL( "Queue = 'Incidents' AND HasMember = ". $Ticket->id );
-    while ( my $parent = $tickets->Next ) {
-        push @parents, $parent->id;
-    }
+    push @parents, map $_->id, @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef };
 }
 return unless @parents;
 
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 54af9f7..49161c5 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -82,9 +82,7 @@ while ( my $Ticket = $session{'tickets'}->Next ) {
     if ( $Ticket->QueueObj->Name eq "Incidents" ) {
         $incidents->{ $Ticket->Id } = { Ticket => $Ticket };
     } elsif ( $Ticket->QueueObj->Name eq "Incident Reports" ) {
-        my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id;
-        my $parents = RT::Tickets->new( $session{'CurrentUser'} );
-        $parents->FromSQL( $query );
+        my $parents = RT::IR->Incidents( $Ticket );
         while ( my $parent = $parents->Next ) {
             $incidents->{ $parent->Id } = { Ticket => $parent };
         }
diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index c03984d..a1d4626 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -74,10 +74,7 @@ if ( $Ticket->Owner != $session{'CurrentUser'}->Id ) {
 
 my $show_unlink = !$action;
 if ( $show_unlink && $Ticket->QueueObj->Name eq 'Blocks' ) {
-    my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id;
-    my $incidents = new RT::Tickets( $session{'CurrentUser'} );
-    $incidents->FromSQL( $query );
-    $show_unlink = 0 unless $incidents->Count > 1;
+    $show_unlink = 0 unless RT::IR->Incidents( $Ticket )->Count > 1;
 }
 
 </%INIT>
diff --git a/html/RTIR/Merge/index.html b/html/RTIR/Merge/index.html
index c0a090a..9ece1cc 100644
--- a/html/RTIR/Merge/index.html
+++ b/html/RTIR/Merge/index.html
@@ -134,21 +134,19 @@ my %defaults = (
 
 my $siblings_query = '';
 if ( $Type ne 'Incident' ) {
-    my $parents = RT::Tickets->new( $session{'CurrentUser'} );
-    $parents->FromSQL( "Queue = 'Incidents' AND HasMember = $id" );
-    if ( $parents->Count ) {
-        my $parents_query = '';
-        while ( my $parent = $parents->Next ) {
-            $parents_query .= ' OR ' if $parents_query;
-            $parents_query .= "MemberOf = ". $parent->id;
-        }
-        if ( $parents_query ) {
-            $siblings_query .= "( $parents_query )";
-            my $queue_query = "Queue = '$Queue'";
-            $queue_query .= " OR Queue = 'Investigations'" if $Type eq 'Report';
-            $queue_query .= " OR Queue = 'Incident Reports'" if $Type eq 'Investigation';
-            $siblings_query .= " AND ( $queue_query )";
-        }
+    my $parents_query = '';
+
+    my $parents = RT::IR->Incidents( $Ticket );
+    while ( my $parent = $parents->Next ) {
+        $parents_query .= ' OR ' if $parents_query;
+        $parents_query .= "MemberOf = ". $parent->id;
+    }
+    if ( $parents_query ) {
+        $siblings_query .= "( $parents_query )";
+        my $queue_query = "Queue = '$Queue'";
+        $queue_query .= " OR Queue = 'Investigations'" if $Type eq 'Report';
+        $queue_query .= " OR Queue = 'Incident Reports'" if $Type eq 'Investigation';
+        $siblings_query .= " AND ( $queue_query )";
     }
 }
 
diff --git a/html/RTIR/Reporting/Report.html b/html/RTIR/Reporting/Report.html
index 411fcfd..2b935ad 100644
--- a/html/RTIR/Reporting/Report.html
+++ b/html/RTIR/Reporting/Report.html
@@ -120,12 +120,7 @@ my $get_incident_field = sub {
     my $t = shift;
     my $field = shift;
 
-    # find the parent incident
-    my $query = "Queue = 'Incidents' AND HasMember = ". $t->Id;
-    my $incidents = new RT::Tickets( $session{'CurrentUser'} );
-    $incidents->FromSQL( $query );
-
-    my $parent = $incidents->First;
+    my $parent = RT::IR->Incidents( $t )->First;
     return undef unless $parent;
     return RT::IR::Ticket::FirstCustomFieldValue( $parent, $field );
 };
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index 400936e..70c49db 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -82,8 +82,7 @@ sub Commit {
         return $self->UpdateDue( $uri->Object );
     }
 
-    my $incidents = new RT::Tickets( $self->CurrentUser );
-    $incidents->FromSQL( "Queue = 'Incidents' AND HasMember = " . $self->TicketObj->id );
+    my $incidents = RT::IR->Incidents( $self->TicketObj );
     while ( my $incident = $incidents->Next ) {
         $self->UpdateDue( $incident );
     }
diff --git a/lib/RT/Condition/RTIR_LinkingToIncident.pm b/lib/RT/Condition/RTIR_LinkingToIncident.pm
index f8aebc7..65c0ece 100644
--- a/lib/RT/Condition/RTIR_LinkingToIncident.pm
+++ b/lib/RT/Condition/RTIR_LinkingToIncident.pm
@@ -16,11 +16,7 @@ sub IsApplicable {
 
     my $type = $self->TransactionObj->Type;
     if ( $type eq "Create" ) {
-        my $query = "Queue = 'Incidents'"
-            ." AND HasMember = " . $self->TicketObj->Id;
-        my $parents = RT::Tickets->new( $self->CurrentUser );
-        $parents->FromSQL( $query );
-        return $parents->Count;
+        return RT::IR->Incidents( $self->TicketObj )->Count;
     }
 
     my $field = $self->TransactionObj->Field;
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 8c6f432..71666b3 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -342,6 +342,22 @@ sub ChildrenQuery {
     return join " AND ", map "($_)", @parts;
 }
 
+=head2 Incidents
+
+Takes a ticket and returns collection of all incidents this ticket
+is member of.
+
+=cut
+
+sub Incidents {
+    my $self = shift;
+    my $ticket = shift;
+
+    my $res = RT::Tickets->new( $ticket->CurrentUser );
+    $res->FromSQL( "Queue = 'Incidents' AND HasMember = " . $ticket->id );
+    return $res;
+}
+
 =head2 RelevantIncidents
 
 Takes a ticket and returns collection of incidents this ticket

commit 8e5cdcb844232b22269c4b7f8b950c572952cadf
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:21:32 2011 +0400

    move IsLinkedToActiveIncidents

diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index 251a8b2..39aab11 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -129,7 +129,7 @@ if ( $ARGS{'BulkAbandon'} ) {
             my $members = new RT::Tickets( $t->CurrentUser );
             $members->FromSQL( $query );
             while( my $member = $members->Next ) {
-                next if RT::IR::Ticket::IsLinkedToActiveIncidents( $member, $t );
+                next if RT::IR->IsLinkedToActiveIncidents( $member, $t );
                 push @tmp, $member;
             }
         }
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 5b39aa6..efea732 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -185,7 +185,7 @@ if ( $SubmitTicket && !$checks_failure ) {
         $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
         push @tempresults, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
-        unless ( RT::IR::Ticket::IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
+        unless ( RT::IR->IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
             # XXX: we push into results directly cuz ProcessTicketBasics returns results
             # with leading 'Ticket XX:' string
             push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef
@@ -202,7 +202,7 @@ if ( $SubmitTicket && !$checks_failure ) {
         my $children = RT::Tickets->new( $session{'CurrentUser'} );
         $children->FromSQL( $ActiveChildrenQuery );
         while ( my $child = $children->Next ) {
-            next if RT::IR::Ticket::IsLinkedToActiveIncidents( $child, $IncidentObj );
+            next if RT::IR->IsLinkedToActiveIncidents( $child, $IncidentObj );
             $update_incident_state = 0;
             last;
         }
diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index 1561d46..5b0519c 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -95,7 +95,7 @@ sub Commit {
         my $members = RT::Tickets->new( $self->CurrentUser );
         $members->FromSQL( $query );
         while ( my $member = $members->Next ) {
-            if ( RT::IR::Ticket::IsLinkedToActiveIncidents( $member, $self->TicketObj ) ) {
+            if ( RT::IR->IsLinkedToActiveIncidents( $member, $self->TicketObj ) ) {
                 $member->Comment(Content => <<END);
 
 Linked Incident \#$id was resolved, but ticket still has unresolved linked Incidents.
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 71666b3..d0f0d52 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -378,6 +378,32 @@ sub RelevantIncidents {
     return $res;
 }
 
+=head2 IsLinkedToActiveIncidents $ChildObj [$IncidentObj]
+
+Returns number of active incidents linked to child ticket
+(IR, Investigation, Block or other). If second argument provided
+then it's excluded from count.
+
+When function return zero that means that object has no active
+parent incidents.
+
+=cut
+
+sub IsLinkedToActiveIncidents {
+    my $self = shift;
+    my $child = shift;
+    my $parent = shift;
+
+    my $tickets = RT::Tickets->new( $child->CurrentUser );
+    $tickets->FromSQL( $self->BaseQuery(
+        Queue     => 'Incidents',
+        Status    => [ RT::Lifecycle->Load('incidents')->Valid('initial', 'active') ],
+        HasMember => $child,
+        Exclude   => $parent->id,
+    ) );
+    return $tickets->Count;
+}
+
 sub GetCustomField {
     my $field = shift or return;
     return (__PACKAGE__->CustomFields( $field ))[0];

commit 92da38ca6ecc7666f66304c15606800f245efa84
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:23:43 2011 +0400

    drop last usage of RT::IR::Ticket::FirstCustomFieldValue

diff --git a/html/RTIR/Reporting/Report.html b/html/RTIR/Reporting/Report.html
index 2b935ad..9a4b26b 100644
--- a/html/RTIR/Reporting/Report.html
+++ b/html/RTIR/Reporting/Report.html
@@ -122,7 +122,7 @@ my $get_incident_field = sub {
 
     my $parent = RT::IR->Incidents( $t )->First;
     return undef unless $parent;
-    return RT::IR::Ticket::FirstCustomFieldValue( $parent, $field );
+    return $parent->FirstCustomFieldValue( $field );
 };
 
 my $filter_by_incident_field = sub {

commit 35a0f586f2d84c2b7514112668e2a59032fcb35c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:24:56 2011 +0400

    delete lib/RT/IR/Ticket.pm, we don't use it

diff --git a/MANIFEST b/MANIFEST
index 0e8ca4e..0ce0745 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -197,7 +197,6 @@ lib/RT/IR/Constituencies.pod
 lib/RT/IR/DocIndex.pod
 lib/RT/IR/Test.pm
 lib/RT/IR/Test/Web.pm
-lib/RT/IR/Ticket.pm
 lib/RT/IR/Tutorial.pod
 Makefile.PL
 MANIFEST			This list of files
diff --git a/html/Callbacks/RTIR/autohandler/Default b/html/Callbacks/RTIR/autohandler/Default
index c6bb938..ba3862d 100644
--- a/html/Callbacks/RTIR/autohandler/Default
+++ b/html/Callbacks/RTIR/autohandler/Default
@@ -1,7 +1,6 @@
 <%ONCE>
 eval {
     require RT::IR;
-    require RT::IR::Ticket;
 };
 if ( $@ ) {
     $RT::Logger->crit("System error. Couldn't load RTIR module(s): $@");
diff --git a/lib/RT/IR/Ticket.pm b/lib/RT/IR/Ticket.pm
deleted file mode 100644
index b6cc906..0000000
--- a/lib/RT/IR/Ticket.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-package RT::IR::Ticket;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-RT::IR::Ticket - RTIR's tickets utilities
-
-=head1 FUNCTIONS
-
-=head2 FirstCustomFieldValue $TicketObj, $Field
-
-Returns first RTIR ticket's custom field value. Use it only with RTIR's
-special custom fields like C<State> and other.
-
-=cut
-
-sub FirstCustomFieldValue {
-    my $ticket = shift;
-    my $field = shift;
-    return undef unless $ticket->CurrentUserHasRight('ShowTicket');
-
-    return $ticket->FirstCustomFieldValue( $field );
-}
-
-=head2 IsLinkedToActiveIncidents $ChildObj [$IncidentObj]
-
-Returns number of active incedents linked to child ticket
-(IR, Investigation, Block or other). If second argument provided
-then it's excluded from count.
-
-When function return zero that means that object has no active
-parent incidents.
-
-=cut
-
-sub IsLinkedToActiveIncidents {
-    my $child = shift;
-    my $parent = shift;
-
-    my $query =  "Queue = 'Incidents'"
-                ." AND HasMember = ". $child->id
-                ." AND ( ". join(" OR ", map "Status = '$_'",
-                            RT::Queue->ActiveStatusArray ) ." ) ";
-
-    $query   .= " AND id != ". $parent->Id if $parent;
-
-    my $tickets = new RT::Tickets( $child->CurrentUser );
-    $tickets->FromSQL( $query );
-    return $tickets->Count;
-}
-
-
-1;

commit bb9e71a8709b0902891fb5067ca5cbf235905765
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 9 12:46:15 2011 +0400

    use RT::Base->_ImportOverlays;

diff --git a/lib/RT/Action/RTIR.pm b/lib/RT/Action/RTIR.pm
index e19b1dc..374babf 100644
--- a/lib/RT/Action/RTIR.pm
+++ b/lib/RT/Action/RTIR.pm
@@ -13,5 +13,6 @@ sub CreatorCurrentUser {
     return $user;
 }
 
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_ChangeChildOwnership.pm b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
index c5eea04..21ba5d9 100644
--- a/lib/RT/Action/RTIR_ChangeChildOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
@@ -61,8 +61,6 @@ sub Prepare {
     return 1;
 }
 
-# {{{ sub Commit
-
 =head2 Commit
 
 Change the ownership of children.
@@ -101,11 +99,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_ChangeChildOwnership_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ChangeChildOwnership_Vendor.pm});
-eval "require RT::Action::RTIR_ChangeChildOwnership_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ChangeChildOwnership_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_ChangeParentOwnership.pm b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
index 000eb8a..84f5a97 100644
--- a/lib/RT/Action/RTIR_ChangeParentOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
@@ -61,8 +61,6 @@ sub Prepare {
     return 1;
 }
 
-# {{{ sub Commit
-
 =head2 Commit
 
 Change the ownership of parent incident.
@@ -93,11 +91,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_ChangeParentOwnership_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ChangeParentOwnership_Vendor.pm});
-eval "require RT::Action::RTIR_ChangeParentOwnership_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ChangeParentOwnership_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index f3872d9..2d765dd 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -88,4 +88,6 @@ sub AddIP {
     return 1;
 }
 
+RT::Base->_ImportOverlays;
+
 1;
diff --git a/lib/RT/Action/RTIR_MergeIPs.pm b/lib/RT/Action/RTIR_MergeIPs.pm
index dc44228..3896d17 100644
--- a/lib/RT/Action/RTIR_MergeIPs.pm
+++ b/lib/RT/Action/RTIR_MergeIPs.pm
@@ -55,9 +55,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_MergeIPs_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_MergeIPs_Vendor.pm});
-eval "require RT::Action::RTIR_MergeIPs_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_MergeIPs_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index c7c53a5..8c66d9d 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -64,8 +64,6 @@ sub Prepare {
     return 1;
 }
 
-# {{{ sub Commit
-
 =head2 Commit
 
 Re-open the parent incident
@@ -96,11 +94,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_OpenParent_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_OpenParent_Vendor.pm});
-eval "require RT::Action::RTIR_OpenParent_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_OpenParent_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index 5b0519c..ebbd845 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -66,8 +66,6 @@ sub Prepare {
     return 1;
 }
 
-# {{{ sub Commit
-
 =head2 Commit
 
 Resolve all children.
@@ -112,11 +110,6 @@ END
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_ResolveChildren_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ResolveChildren_Vendor.pm});
-eval "require RT::Action::RTIR_ResolveChildren_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_ResolveChildren_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetBlockState.pm b/lib/RT/Action/RTIR_SetBlockState.pm
index 2137ba4..2df7a88 100644
--- a/lib/RT/Action/RTIR_SetBlockState.pm
+++ b/lib/RT/Action/RTIR_SetBlockState.pm
@@ -83,9 +83,6 @@ sub GetState {
     return 'active' if $status eq 'removed';
 }
 
-eval "require RT::Action::RTIR_SetBlockState_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetBlockState_Vendor.pm});
-eval "require RT::Action::RTIR_SetBlockState_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetBlockState_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetConstituency.pm b/lib/RT/Action/RTIR_SetConstituency.pm
index ec129ec..1cb4419 100644
--- a/lib/RT/Action/RTIR_SetConstituency.pm
+++ b/lib/RT/Action/RTIR_SetConstituency.pm
@@ -174,9 +174,6 @@ sub IsValidConstituency {
 
 }
 
-eval "require RT::Action::RTIR_SetConstituency_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetConstituency_Vendor.pm});
-eval "require RT::Action::RTIR_SetConstituency_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetConstituency_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetConstituencyGroup.pm b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
index 223f776..202beb0 100644
--- a/lib/RT/Action/RTIR_SetConstituencyGroup.pm
+++ b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
@@ -82,10 +82,6 @@ sub ConstituencyValues {
 
 }
 
-eval "require RT::Action::RTIR_SetConstituencyGroup_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetConstituencyGroup_Vendor.pm});
-eval "require RT::Action::RTIR_SetConstituencyGroup_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetConstituencyGroup_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Action/RTIR_SetDueBySLA.pm b/lib/RT/Action/RTIR_SetDueBySLA.pm
index ad74e37..6d000a2 100644
--- a/lib/RT/Action/RTIR_SetDueBySLA.pm
+++ b/lib/RT/Action/RTIR_SetDueBySLA.pm
@@ -104,11 +104,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_SetDueBySLA_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueBySLA_Vendor.pm});
-eval "require RT::Action::RTIR_SetDueBySLA_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueBySLA_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetDueCorrespond.pm b/lib/RT/Action/RTIR_SetDueCorrespond.pm
index f4f649f..5c0e2d6 100644
--- a/lib/RT/Action/RTIR_SetDueCorrespond.pm
+++ b/lib/RT/Action/RTIR_SetDueCorrespond.pm
@@ -91,11 +91,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_SetDueCorrespond_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueCorrespond_Vendor.pm});
-eval "require RT::Action::RTIR_SetDueCorrespond_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueCorrespond_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index 70c49db..8395121 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -115,6 +115,6 @@ sub UpdateDue {
     return 1;
 }
 
-# }}}
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetDueReopen.pm b/lib/RT/Action/RTIR_SetDueReopen.pm
index f7703bf..7c16a6c 100644
--- a/lib/RT/Action/RTIR_SetDueReopen.pm
+++ b/lib/RT/Action/RTIR_SetDueReopen.pm
@@ -94,11 +94,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_SetDueReopen_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueReopen_Vendor.pm});
-eval "require RT::Action::RTIR_SetDueReopen_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueReopen_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetDueToNow.pm b/lib/RT/Action/RTIR_SetDueToNow.pm
index 08114da..d16da7e 100644
--- a/lib/RT/Action/RTIR_SetDueToNow.pm
+++ b/lib/RT/Action/RTIR_SetDueToNow.pm
@@ -98,9 +98,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_SetDueToNow_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueToNow_Vendor.pm});
-eval "require RT::Action::RTIR_SetDueToNow_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetDueToNow_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index e364450..662918b 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -83,11 +83,6 @@ sub Commit {
     return 1;
 }
 
-# }}}
-
-eval "require RT::Action::RTIR_SetHowReported_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetHowReported_Vendor.pm});
-eval "require RT::Action::RTIR_SetHowReported_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetHowReported_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetIncidentReportState.pm b/lib/RT/Action/RTIR_SetIncidentReportState.pm
index da7662b..85b2943 100644
--- a/lib/RT/Action/RTIR_SetIncidentReportState.pm
+++ b/lib/RT/Action/RTIR_SetIncidentReportState.pm
@@ -78,9 +78,6 @@ sub GetState {
     return '';
 }
 
-eval "require RT::Action::RTIR_SetIncidentReportState_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentReportState_Vendor.pm});
-eval "require RT::Action::RTIR_SetIncidentReportState_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentReportState_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetIncidentResolution.pm b/lib/RT/Action/RTIR_SetIncidentResolution.pm
index db3c04c..10e635b 100644
--- a/lib/RT/Action/RTIR_SetIncidentResolution.pm
+++ b/lib/RT/Action/RTIR_SetIncidentResolution.pm
@@ -48,10 +48,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_SetIncidentResolution_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentResolution_Vendor.pm});
-eval "require RT::Action::RTIR_SetIncidentResolution_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentResolution_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Action/RTIR_SetStartedToNow.pm b/lib/RT/Action/RTIR_SetStartedToNow.pm
index 6855f99..2d80a35 100644
--- a/lib/RT/Action/RTIR_SetStartedToNow.pm
+++ b/lib/RT/Action/RTIR_SetStartedToNow.pm
@@ -30,9 +30,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_SetStartedToNow_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartedToNow_Vendor.pm});
-eval "require RT::Action::RTIR_SetStartedToNow_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartedToNow_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetStartsByBizHours.pm b/lib/RT/Action/RTIR_SetStartsByBizHours.pm
index d267511..967c3a5 100644
--- a/lib/RT/Action/RTIR_SetStartsByBizHours.pm
+++ b/lib/RT/Action/RTIR_SetStartsByBizHours.pm
@@ -85,9 +85,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_SetStartsByBizHours_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartsByBizHours_Vendor.pm});
-eval "require RT::Action::RTIR_SetStartsByBizHours_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartsByBizHours_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetStartsToNow.pm b/lib/RT/Action/RTIR_SetStartsToNow.pm
index dd7e2e6..367912d 100644
--- a/lib/RT/Action/RTIR_SetStartsToNow.pm
+++ b/lib/RT/Action/RTIR_SetStartsToNow.pm
@@ -87,9 +87,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_SetStartsToNow_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartsToNow_Vendor.pm});
-eval "require RT::Action::RTIR_SetStartsToNow_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartsToNow_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_SetState.pm b/lib/RT/Action/RTIR_SetState.pm
index 03d0d3d..4ab6f75 100644
--- a/lib/RT/Action/RTIR_SetState.pm
+++ b/lib/RT/Action/RTIR_SetState.pm
@@ -40,9 +40,6 @@ sub Commit {
 
 sub GetState { return '' }
 
-eval "require RT::Action::RTIR_SetState_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetState_Vendor.pm});
-eval "require RT::Action::RTIR_SetState_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetState_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Action/RTIR_UnsetDue.pm b/lib/RT/Action/RTIR_UnsetDue.pm
index 8cac0fe..be6c067 100644
--- a/lib/RT/Action/RTIR_UnsetDue.pm
+++ b/lib/RT/Action/RTIR_UnsetDue.pm
@@ -77,9 +77,6 @@ sub Commit {
     return 1;
 }
 
-eval "require RT::Action::RTIR_UnsetDue_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_UnsetDue_Vendor.pm});
-eval "require RT::Action::RTIR_UnsetDue_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_UnsetDue_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR.pm b/lib/RT/Condition/RTIR.pm
index 9d0d5f7..a84a83a 100644
--- a/lib/RT/Condition/RTIR.pm
+++ b/lib/RT/Condition/RTIR.pm
@@ -54,4 +54,6 @@ sub IsStaff {
     return $cgm->First? 1 : 0;
 }
 
+RT::Base->_ImportOverlays;
+
 1;
diff --git a/lib/RT/Condition/RTIR_BlockActivation.pm b/lib/RT/Condition/RTIR_BlockActivation.pm
index 118414f..58783a0 100644
--- a/lib/RT/Condition/RTIR_BlockActivation.pm
+++ b/lib/RT/Condition/RTIR_BlockActivation.pm
@@ -25,9 +25,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_BlockActivation_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_BlockActivation_Vendor.pm});
-eval "require RT::Condition::RTIR_BlockActivation_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_BlockActivation_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR_CloseTicket.pm b/lib/RT/Condition/RTIR_CloseTicket.pm
index d6220b9..797e11f 100644
--- a/lib/RT/Condition/RTIR_CloseTicket.pm
+++ b/lib/RT/Condition/RTIR_CloseTicket.pm
@@ -72,10 +72,6 @@ sub IsApplicable {
     return 1;
 }
 
-eval "require RT::Condition::RTIR_CloseTicket_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_CloseTicket_Vendor.pm});
-eval "require RT::Condition::RTIR_CloseTicket_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_CloseTicket_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Condition/RTIR_CustomerResponse.pm b/lib/RT/Condition/RTIR_CustomerResponse.pm
index cd4030a..faafb47 100644
--- a/lib/RT/Condition/RTIR_CustomerResponse.pm
+++ b/lib/RT/Condition/RTIR_CustomerResponse.pm
@@ -75,9 +75,6 @@ sub IsApplicable {
     return !$self->IsStaff;
 }
 
-eval "require RT::Condition::RTIR_CustomerResponse_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_CustomerResponse_Vendor.pm});
-eval "require RT::Condition::RTIR_CustomerResponse_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_CustomerResponse_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR_LinkingToIncident.pm b/lib/RT/Condition/RTIR_LinkingToIncident.pm
index 65c0ece..e0a09fc 100644
--- a/lib/RT/Condition/RTIR_LinkingToIncident.pm
+++ b/lib/RT/Condition/RTIR_LinkingToIncident.pm
@@ -34,9 +34,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_LinkingToIncident_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_LinkingToIncident_Vendor.pm});
-eval "require RT::Condition::RTIR_LinkingToIncident_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_LinkingToIncident_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR_Merge.pm b/lib/RT/Condition/RTIR_Merge.pm
index 0cfa20e..902099c 100644
--- a/lib/RT/Condition/RTIR_Merge.pm
+++ b/lib/RT/Condition/RTIR_Merge.pm
@@ -20,9 +20,6 @@ sub IsApplicable {
     return 1;
 }
 
-eval "require RT::Condition::RTIR_Merge_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_Merge_Vendor.pm});
-eval "require RT::Condition::RTIR_Merge_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_Merge_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR_ReopenTicket.pm b/lib/RT/Condition/RTIR_ReopenTicket.pm
index 61c4731..aa46b06 100644
--- a/lib/RT/Condition/RTIR_ReopenTicket.pm
+++ b/lib/RT/Condition/RTIR_ReopenTicket.pm
@@ -70,10 +70,6 @@ sub IsApplicable {
     return 1;
 }
 
-eval "require RT::Condition::RTIR_ReopenTicket_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_ReopenTicket_Vendor.pm});
-eval "require RT::Condition::RTIR_ReopenTicket_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_ReopenTicket_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
index d8a539d..b53c51a 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
@@ -27,11 +27,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_RequireConstituencyChange_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireConstituencyChange_Vendor.pm});
-eval "require RT::Condition::RTIR_RequireConstituencyChange_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireConstituencyChange_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
-
diff --git a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
index 0eb6475..b804663 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
@@ -27,9 +27,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_RequireConstituencyGroupChange_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireConstituencyGroupChange_Vendor.pm});
-eval "require RT::Condition::RTIR_RequireConstituencyGroupChange_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireConstituencyGroupChange_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
diff --git a/lib/RT/Condition/RTIR_RequireDueChange.pm b/lib/RT/Condition/RTIR_RequireDueChange.pm
index 8fd7121..e37a30a 100644
--- a/lib/RT/Condition/RTIR_RequireDueChange.pm
+++ b/lib/RT/Condition/RTIR_RequireDueChange.pm
@@ -69,10 +69,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_RequireDueChange_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireDueChange_Vendor.pm});
-eval "require RT::Condition::RTIR_RequireDueChange_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireDueChange_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Condition/RTIR_RequireStateChange.pm b/lib/RT/Condition/RTIR_RequireStateChange.pm
index f40d49e..3d15079 100644
--- a/lib/RT/Condition/RTIR_RequireStateChange.pm
+++ b/lib/RT/Condition/RTIR_RequireStateChange.pm
@@ -77,10 +77,6 @@ sub IsApplicable {
     return 0;
 }
 
-eval "require RT::Condition::RTIR_RequireStateChange_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireStateChange_Vendor.pm});
-eval "require RT::Condition::RTIR_RequireStateChange_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_RequireStateChange_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/Condition/RTIR_StaffResponse.pm b/lib/RT/Condition/RTIR_StaffResponse.pm
index 67d01b7..dc54d6b 100644
--- a/lib/RT/Condition/RTIR_StaffResponse.pm
+++ b/lib/RT/Condition/RTIR_StaffResponse.pm
@@ -70,10 +70,6 @@ sub IsApplicable {
     return $self->IsStaff;
 }
 
-eval "require RT::Condition::RTIR_StaffResponse_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_StaffResponse_Vendor.pm});
-eval "require RT::Condition::RTIR_StaffResponse_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_StaffResponse_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;
-
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index d0f0d52..3b47c62 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -692,10 +692,6 @@ if ( RT::IR->HasConstituency ) {
     };
 }
 
-#
-eval "require RT::IR_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Vendor.pm});
-eval "require RT::IR_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Local.pm});
+RT::Base->_ImportOverlays;
 
 1;

commit b6f9546cfa0726adcf72ac75c03d5b79d8782873
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Jul 11 18:13:17 2011 +0400

    make sure we have strict and warnings everywhere
    
    and concistent

diff --git a/lib/RT/Action/RTIR.pm b/lib/RT/Action/RTIR.pm
index 374babf..971dffa 100644
--- a/lib/RT/Action/RTIR.pm
+++ b/lib/RT/Action/RTIR.pm
@@ -1,9 +1,7 @@
-
-use warnings;
 use strict;
-use RT::IR;
-package RT::Action::RTIR;
+use warnings;
 
+package RT::Action::RTIR;
 use base 'RT::Action';
 
 sub CreatorCurrentUser {
diff --git a/lib/RT/Action/RTIR_ChangeChildOwnership.pm b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
index 21ba5d9..606a588 100644
--- a/lib/RT/Action/RTIR_ChangeChildOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
@@ -44,8 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_ChangeChildOwnership;
 use strict;
+use warnings;
+
+package RT::Action::RTIR_ChangeChildOwnership;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
@@ -54,7 +56,6 @@ Always run this.
 
 =cut
 
-
 sub Prepare {
     my $self = shift;
 
diff --git a/lib/RT/Action/RTIR_ChangeParentOwnership.pm b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
index 84f5a97..b8600e8 100644
--- a/lib/RT/Action/RTIR_ChangeParentOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
@@ -44,8 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_ChangeParentOwnership;
 use strict;
+use warnings;
+
+package RT::Action::RTIR_ChangeParentOwnership;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index 2d765dd..7b1a62a 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -1,8 +1,7 @@
-package RT::Action::RTIR_FindIP;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_FindIP;
 use base qw(RT::Action::RTIR);
 
 use Regexp::Common qw(net);
diff --git a/lib/RT/Action/RTIR_MergeIPs.pm b/lib/RT/Action/RTIR_MergeIPs.pm
index 3896d17..6f30d23 100644
--- a/lib/RT/Action/RTIR_MergeIPs.pm
+++ b/lib/RT/Action/RTIR_MergeIPs.pm
@@ -1,8 +1,7 @@
-package RT::Action::RTIR_MergeIPs;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_MergeIPs;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index 8c66d9d..9e7fafa 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -44,11 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_OpenParent;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_OpenParent;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index ebbd845..5c4e973 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -44,11 +44,11 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_ResolveChildren;
 use strict;
-use base 'RT::Action::RTIR';
+use warnings;
 
-use RT::IR::Ticket;
+package RT::Action::RTIR_ResolveChildren;
+use base 'RT::Action::RTIR';
 
 =head2 Prepare
 
@@ -56,7 +56,6 @@ Check if the Incident is being closed.
 
 =cut
 
-
 sub Prepare {
     my $self = shift;
     my @inactive = $self->TicketObj->QueueObj->InactiveStatusArray;
diff --git a/lib/RT/Action/RTIR_SetBlockState.pm b/lib/RT/Action/RTIR_SetBlockState.pm
index 2df7a88..bc62c08 100644
--- a/lib/RT/Action/RTIR_SetBlockState.pm
+++ b/lib/RT/Action/RTIR_SetBlockState.pm
@@ -44,9 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetBlockState;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetBlockState;
 use base 'RT::Action::RTIR_SetState';
 
 =head1 GetState
diff --git a/lib/RT/Action/RTIR_SetConstituency.pm b/lib/RT/Action/RTIR_SetConstituency.pm
index 1cb4419..6ef0e0a 100644
--- a/lib/RT/Action/RTIR_SetConstituency.pm
+++ b/lib/RT/Action/RTIR_SetConstituency.pm
@@ -1,8 +1,7 @@
-package RT::Action::RTIR_SetConstituency;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_SetConstituency;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetConstituencyGroup.pm b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
index 202beb0..cdd4a1c 100644
--- a/lib/RT/Action/RTIR_SetConstituencyGroup.pm
+++ b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
@@ -1,8 +1,7 @@
-package RT::Action::RTIR_SetConstituencyGroup;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_SetConstituencyGroup;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetDueBySLA.pm b/lib/RT/Action/RTIR_SetDueBySLA.pm
index 6d000a2..96eefc4 100644
--- a/lib/RT/Action/RTIR_SetDueBySLA.pm
+++ b/lib/RT/Action/RTIR_SetDueBySLA.pm
@@ -44,12 +44,11 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetDueBySLA;
-
 use strict;
 use warnings;
-use RT::Action::RTIR;
-use base qw'RT::Action::RTIR';
+
+package RT::Action::RTIR_SetDueBySLA;
+use base 'RT::Action::RTIR';
 
 =head2 Prepare
 
diff --git a/lib/RT/Action/RTIR_SetDueCorrespond.pm b/lib/RT/Action/RTIR_SetDueCorrespond.pm
index 5c0e2d6..61f07cb 100644
--- a/lib/RT/Action/RTIR_SetDueCorrespond.pm
+++ b/lib/RT/Action/RTIR_SetDueCorrespond.pm
@@ -44,11 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetDueCorrespond;
-
-
 use strict;
+use warnings;
 
+package RT::Action::RTIR_SetDueCorrespond;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
@@ -57,7 +56,6 @@ Always run this.
 
 =cut
 
-
 sub Prepare {
     my $self = shift;
 
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index 8395121..e20d25a 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -44,11 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetDueIncident;
-
-
 use strict;
+use warnings;
 
+package RT::Action::RTIR_SetDueIncident;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetDueReopen.pm b/lib/RT/Action/RTIR_SetDueReopen.pm
index 7c16a6c..73ee42d 100644
--- a/lib/RT/Action/RTIR_SetDueReopen.pm
+++ b/lib/RT/Action/RTIR_SetDueReopen.pm
@@ -44,10 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetDueReopen;
-
 use strict;
-use RT::IR;
+use warnings;
+
+package RT::Action::RTIR_SetDueReopen;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetDueToNow.pm b/lib/RT/Action/RTIR_SetDueToNow.pm
index d16da7e..aa1ad6f 100644
--- a/lib/RT/Action/RTIR_SetDueToNow.pm
+++ b/lib/RT/Action/RTIR_SetDueToNow.pm
@@ -44,12 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetDueToNow;
-
 use strict;
 use warnings;
 
-use RT::IR;
+package RT::Action::RTIR_SetDueToNow;
 use base 'RT::Action::RTIR';
 
 =head1 NAME
diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index 662918b..5ce641a 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -44,9 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetHowReported;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetHowReported;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetIncidentReportState.pm b/lib/RT/Action/RTIR_SetIncidentReportState.pm
index 85b2943..ef88562 100644
--- a/lib/RT/Action/RTIR_SetIncidentReportState.pm
+++ b/lib/RT/Action/RTIR_SetIncidentReportState.pm
@@ -44,11 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetIncidentReportState;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_SetIncidentReportState;
 use base 'RT::Action::RTIR_SetState';
 
 =head2 GetState
diff --git a/lib/RT/Action/RTIR_SetIncidentResolution.pm b/lib/RT/Action/RTIR_SetIncidentResolution.pm
index 10e635b..63fff52 100644
--- a/lib/RT/Action/RTIR_SetIncidentResolution.pm
+++ b/lib/RT/Action/RTIR_SetIncidentResolution.pm
@@ -1,6 +1,7 @@
-package RT::Action::RTIR_SetIncidentResolution;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetIncidentResolution;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetStartedToNow.pm b/lib/RT/Action/RTIR_SetStartedToNow.pm
index 2d80a35..1b4e554 100644
--- a/lib/RT/Action/RTIR_SetStartedToNow.pm
+++ b/lib/RT/Action/RTIR_SetStartedToNow.pm
@@ -1,6 +1,7 @@
-package RT::Action::RTIR_SetStartedToNow;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetStartedToNow;
 use base 'RT::Action::RTIR';
 
 sub Prepare { return 1 }
diff --git a/lib/RT/Action/RTIR_SetStartsByBizHours.pm b/lib/RT/Action/RTIR_SetStartsByBizHours.pm
index 967c3a5..2ccff8b 100644
--- a/lib/RT/Action/RTIR_SetStartsByBizHours.pm
+++ b/lib/RT/Action/RTIR_SetStartsByBizHours.pm
@@ -44,9 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetStartsByBizHours;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetStartsByBizHours;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetStartsToNow.pm b/lib/RT/Action/RTIR_SetStartsToNow.pm
index 367912d..5dba7b8 100644
--- a/lib/RT/Action/RTIR_SetStartsToNow.pm
+++ b/lib/RT/Action/RTIR_SetStartsToNow.pm
@@ -44,9 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_SetStartsToNow;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_SetStartsToNow;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_SetState.pm b/lib/RT/Action/RTIR_SetState.pm
index 4ab6f75..385b883 100644
--- a/lib/RT/Action/RTIR_SetState.pm
+++ b/lib/RT/Action/RTIR_SetState.pm
@@ -1,8 +1,7 @@
-package RT::Action::RTIR_SetState;
-
 use strict;
 use warnings;
 
+package RT::Action::RTIR_SetState;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Action/RTIR_UnsetDue.pm b/lib/RT/Action/RTIR_UnsetDue.pm
index be6c067..1067eee 100644
--- a/lib/RT/Action/RTIR_UnsetDue.pm
+++ b/lib/RT/Action/RTIR_UnsetDue.pm
@@ -44,9 +44,10 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
-package RT::Action::RTIR_UnsetDue;
-
 use strict;
+use warnings;
+
+package RT::Action::RTIR_UnsetDue;
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
diff --git a/lib/RT/Condition/RTIR.pm b/lib/RT/Condition/RTIR.pm
index a84a83a..d7a3c9b 100644
--- a/lib/RT/Condition/RTIR.pm
+++ b/lib/RT/Condition/RTIR.pm
@@ -1,7 +1,5 @@
-
-use warnings;
 use strict;
-use RT::IR;
+use warnings;
 
 package RT::Condition::RTIR;
 use base 'RT::Condition';
diff --git a/lib/RT/Condition/RTIR_BlockActivation.pm b/lib/RT/Condition/RTIR_BlockActivation.pm
index 58783a0..902e387 100644
--- a/lib/RT/Condition/RTIR_BlockActivation.pm
+++ b/lib/RT/Condition/RTIR_BlockActivation.pm
@@ -1,8 +1,7 @@
-package RT::Condition::RTIR_BlockActivation;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_BlockActivation;
 use base 'RT::Condition::RTIR';
 
 =head2 IsApplicable
diff --git a/lib/RT/Condition/RTIR_CloseTicket.pm b/lib/RT/Condition/RTIR_CloseTicket.pm
index 797e11f..a2c00ea 100644
--- a/lib/RT/Condition/RTIR_CloseTicket.pm
+++ b/lib/RT/Condition/RTIR_CloseTicket.pm
@@ -43,14 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
- 
-
-
-package RT::Condition::RTIR_CloseTicket;
-
-
 use strict;
+use warnings;
 
+package RT::Condition::RTIR_CloseTicket;
 use base 'RT::Condition::RTIR';
 
 
diff --git a/lib/RT/Condition/RTIR_CustomerResponse.pm b/lib/RT/Condition/RTIR_CustomerResponse.pm
index faafb47..135c377 100644
--- a/lib/RT/Condition/RTIR_CustomerResponse.pm
+++ b/lib/RT/Condition/RTIR_CustomerResponse.pm
@@ -43,12 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
-
-package RT::Condition::RTIR_CustomerResponse;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_CustomerResponse;
 use base 'RT::Condition::RTIR';
 
 =head1 NAME
diff --git a/lib/RT/Condition/RTIR_LinkingToIncident.pm b/lib/RT/Condition/RTIR_LinkingToIncident.pm
index e0a09fc..c39d19e 100644
--- a/lib/RT/Condition/RTIR_LinkingToIncident.pm
+++ b/lib/RT/Condition/RTIR_LinkingToIncident.pm
@@ -1,8 +1,7 @@
-package RT::Condition::RTIR_LinkingToIncident;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_LinkingToIncident;
 use base 'RT::Condition::RTIR';
 
 =head2 IsApplicable
diff --git a/lib/RT/Condition/RTIR_Merge.pm b/lib/RT/Condition/RTIR_Merge.pm
index 902099c..b5155d0 100644
--- a/lib/RT/Condition/RTIR_Merge.pm
+++ b/lib/RT/Condition/RTIR_Merge.pm
@@ -1,8 +1,7 @@
-package RT::Condition::RTIR_Merge;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_Merge;
 use base 'RT::Condition::RTIR';
 
 =head2 IsApplicable
diff --git a/lib/RT/Condition/RTIR_ReopenTicket.pm b/lib/RT/Condition/RTIR_ReopenTicket.pm
index aa46b06..50603ff 100644
--- a/lib/RT/Condition/RTIR_ReopenTicket.pm
+++ b/lib/RT/Condition/RTIR_ReopenTicket.pm
@@ -43,14 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
- 
-
-
-package RT::Condition::RTIR_ReopenTicket;
-
-
 use strict;
+use warnings;
 
+package RT::Condition::RTIR_ReopenTicket;
 use base 'RT::Condition::RTIR';
 
 
diff --git a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
index b53c51a..dbdbc18 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
@@ -1,8 +1,7 @@
-package RT::Condition::RTIR_RequireConstituencyChange;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_RequireConstituencyChange;
 use base 'RT::Condition::RTIR';
 
 =head2 IsApplicable
diff --git a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
index b804663..05934e4 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
@@ -1,10 +1,8 @@
-package RT::Condition::RTIR_RequireConstituencyGroupChange;
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_RequireConstituencyGroupChange;
 use base 'RT::Condition::RTIR';
-use RT::CustomField;
 
 =head2 IsApplicable
 
diff --git a/lib/RT/Condition/RTIR_RequireDueChange.pm b/lib/RT/Condition/RTIR_RequireDueChange.pm
index e37a30a..8618681 100644
--- a/lib/RT/Condition/RTIR_RequireDueChange.pm
+++ b/lib/RT/Condition/RTIR_RequireDueChange.pm
@@ -43,13 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
- 
-
+use strict;
+use warnings;
 
 package RT::Condition::RTIR_RequireDueChange;
-
-
-use strict;
 use base 'RT::Condition::RTIR';
 
 
diff --git a/lib/RT/Condition/RTIR_RequireStateChange.pm b/lib/RT/Condition/RTIR_RequireStateChange.pm
index 3d15079..359b899 100644
--- a/lib/RT/Condition/RTIR_RequireStateChange.pm
+++ b/lib/RT/Condition/RTIR_RequireStateChange.pm
@@ -43,15 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
- 
-
-
-package RT::Condition::RTIR_RequireStateChange;
-
-
 use strict;
 use warnings;
 
+package RT::Condition::RTIR_RequireStateChange;
 use base 'RT::Condition::RTIR';
 
 
diff --git a/lib/RT/Condition/RTIR_StaffResponse.pm b/lib/RT/Condition/RTIR_StaffResponse.pm
index dc54d6b..3698fc4 100644
--- a/lib/RT/Condition/RTIR_StaffResponse.pm
+++ b/lib/RT/Condition/RTIR_StaffResponse.pm
@@ -43,14 +43,10 @@
 # those contributions and any derivatives thereof.
 # 
 # }}} END BPS TAGGED BLOCK
- 
-
-
-package RT::Condition::RTIR_StaffResponse;
-
-
 use strict;
+use warnings;
 
+package RT::Condition::RTIR_StaffResponse;
 use base 'RT::Condition::RTIR';
 
 
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 3b47c62..7b191f7 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -44,14 +44,14 @@
 # 
 # }}} END BPS TAGGED BLOCK
 #
+use 5.008003;
+use strict;
+use warnings;
+
 package RT::IR;
 
 our $VERSION = '2.5.7';
 
-use 5.008003;
-use warnings;
-use strict;
-
 use Business::Hours;
 use Business::SLA;
 
diff --git a/lib/RT/IR/Config.pm b/lib/RT/IR/Config.pm
index f14e7aa..a205f09 100644
--- a/lib/RT/IR/Config.pm
+++ b/lib/RT/IR/Config.pm
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
 package RT::IR::Config;
 
 sub Init {
diff --git a/lib/RT/IR/Test/Web.pm b/lib/RT/IR/Test/Web.pm
index 6744fe7..406c91c 100644
--- a/lib/RT/IR/Test/Web.pm
+++ b/lib/RT/IR/Test/Web.pm
@@ -1,8 +1,7 @@
-package RT::IR::Test::Web;
-
 use strict;
 use warnings;
 
+package RT::IR::Test::Web;
 use base qw(RT::Test::Web);
 
 require RT::IR::Test;

commit c6062fbebecd1bd45338ecfe027f2c44626915f9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Jul 11 18:22:15 2011 +0400

    move `sub Prepare { return 1 }` to SUPER class

diff --git a/lib/RT/Action/RTIR.pm b/lib/RT/Action/RTIR.pm
index 971dffa..2979875 100644
--- a/lib/RT/Action/RTIR.pm
+++ b/lib/RT/Action/RTIR.pm
@@ -4,6 +4,14 @@ use warnings;
 package RT::Action::RTIR;
 use base 'RT::Action';
 
+=head2 Prepare
+
+RTIR's actions don't do anything by default.
+
+=cut
+
+sub Prepare { return 1 }
+
 sub CreatorCurrentUser {
     my $self = shift;
     my $user = new RT::CurrentUser($self->TransactionObj->CurrentUser);
diff --git a/lib/RT/Action/RTIR_ChangeChildOwnership.pm b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
index 606a588..b5595a6 100644
--- a/lib/RT/Action/RTIR_ChangeChildOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
@@ -50,18 +50,6 @@ use warnings;
 package RT::Action::RTIR_ChangeChildOwnership;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 =head2 Commit
 
 Change the ownership of children.
diff --git a/lib/RT/Action/RTIR_ChangeParentOwnership.pm b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
index b8600e8..f7cf39c 100644
--- a/lib/RT/Action/RTIR_ChangeParentOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeParentOwnership.pm
@@ -50,19 +50,6 @@ use warnings;
 package RT::Action::RTIR_ChangeParentOwnership;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 =head2 Commit
 
 Change the ownership of parent incident.
diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index 7b1a62a..4c9d3e1 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -8,14 +8,6 @@ use Regexp::Common qw(net);
 use Regexp::Common::net::CIDR ();
 use Net::CIDR ();
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Search for IP addresses in the transaction's content.
diff --git a/lib/RT/Action/RTIR_MergeIPs.pm b/lib/RT/Action/RTIR_MergeIPs.pm
index 6f30d23..4a57956 100644
--- a/lib/RT/Action/RTIR_MergeIPs.pm
+++ b/lib/RT/Action/RTIR_MergeIPs.pm
@@ -4,14 +4,6 @@ use warnings;
 package RT::Action::RTIR_MergeIPs;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Change the ownership of children.
diff --git a/lib/RT/Action/RTIR_OpenParent.pm b/lib/RT/Action/RTIR_OpenParent.pm
index 9e7fafa..90e77b7 100644
--- a/lib/RT/Action/RTIR_OpenParent.pm
+++ b/lib/RT/Action/RTIR_OpenParent.pm
@@ -50,19 +50,6 @@ use warnings;
 package RT::Action::RTIR_OpenParent;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 =head2 Commit
 
 Re-open the parent incident
diff --git a/lib/RT/Action/RTIR_SetConstituency.pm b/lib/RT/Action/RTIR_SetConstituency.pm
index 6ef0e0a..b9f0b18 100644
--- a/lib/RT/Action/RTIR_SetConstituency.pm
+++ b/lib/RT/Action/RTIR_SetConstituency.pm
@@ -4,15 +4,6 @@ use warnings;
 package RT::Action::RTIR_SetConstituency;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the Constituency custom field.
diff --git a/lib/RT/Action/RTIR_SetConstituencyGroup.pm b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
index cdd4a1c..6354cc7 100644
--- a/lib/RT/Action/RTIR_SetConstituencyGroup.pm
+++ b/lib/RT/Action/RTIR_SetConstituencyGroup.pm
@@ -4,15 +4,6 @@ use warnings;
 package RT::Action::RTIR_SetConstituencyGroup;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the Constituency custom field.
diff --git a/lib/RT/Action/RTIR_SetDueBySLA.pm b/lib/RT/Action/RTIR_SetDueBySLA.pm
index 96eefc4..a4e2a3d 100644
--- a/lib/RT/Action/RTIR_SetDueBySLA.pm
+++ b/lib/RT/Action/RTIR_SetDueBySLA.pm
@@ -50,19 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueBySLA;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 # {{{ sub Commit
 
 =head2 Commit
diff --git a/lib/RT/Action/RTIR_SetDueCorrespond.pm b/lib/RT/Action/RTIR_SetDueCorrespond.pm
index 61f07cb..2761fcd 100644
--- a/lib/RT/Action/RTIR_SetDueCorrespond.pm
+++ b/lib/RT/Action/RTIR_SetDueCorrespond.pm
@@ -50,18 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueCorrespond;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 # {{{ sub Commit
 
 =head2 Commit
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index e20d25a..e0ecae8 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -50,19 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueIncident;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 # {{{ sub Commit
 
 =head2 Commit
diff --git a/lib/RT/Action/RTIR_SetDueReopen.pm b/lib/RT/Action/RTIR_SetDueReopen.pm
index 73ee42d..f42fd0f 100644
--- a/lib/RT/Action/RTIR_SetDueReopen.pm
+++ b/lib/RT/Action/RTIR_SetDueReopen.pm
@@ -50,17 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueReopen;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-
-sub Prepare {
-    return 1;
-}
-
 # {{{ sub Commit
 
 =head2 Commit
diff --git a/lib/RT/Action/RTIR_SetDueToNow.pm b/lib/RT/Action/RTIR_SetDueToNow.pm
index aa1ad6f..0d57cf1 100644
--- a/lib/RT/Action/RTIR_SetDueToNow.pm
+++ b/lib/RT/Action/RTIR_SetDueToNow.pm
@@ -60,14 +60,6 @@ Set Due date of a ticket to now.
 
 =head1 METHODS
 
-=head2 Prepare
-
-Always commit action.
-
-=cut
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the Due date based on your SLA_Response settings
diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index 5ce641a..7bd512d 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -50,18 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetHowReported;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 # {{{ sub Commit
 
 =head2 Commit
diff --git a/lib/RT/Action/RTIR_SetIncidentResolution.pm b/lib/RT/Action/RTIR_SetIncidentResolution.pm
index 63fff52..9512e01 100644
--- a/lib/RT/Action/RTIR_SetIncidentResolution.pm
+++ b/lib/RT/Action/RTIR_SetIncidentResolution.pm
@@ -4,14 +4,6 @@ use warnings;
 package RT::Action::RTIR_SetIncidentResolution;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the resolution if there is no value.
diff --git a/lib/RT/Action/RTIR_SetStartedToNow.pm b/lib/RT/Action/RTIR_SetStartedToNow.pm
index 1b4e554..57a7a0a 100644
--- a/lib/RT/Action/RTIR_SetStartedToNow.pm
+++ b/lib/RT/Action/RTIR_SetStartedToNow.pm
@@ -4,8 +4,6 @@ use warnings;
 package RT::Action::RTIR_SetStartedToNow;
 use base 'RT::Action::RTIR';
 
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the Started date to now.
diff --git a/lib/RT/Action/RTIR_SetState.pm b/lib/RT/Action/RTIR_SetState.pm
index 385b883..f7da8cf 100644
--- a/lib/RT/Action/RTIR_SetState.pm
+++ b/lib/RT/Action/RTIR_SetState.pm
@@ -4,14 +4,6 @@ use warnings;
 package RT::Action::RTIR_SetState;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare { return 1 }
-
 =head2 Commit
 
 Set the state according to the status.
diff --git a/lib/RT/Action/RTIR_UnsetDue.pm b/lib/RT/Action/RTIR_UnsetDue.pm
index 1067eee..53af28d 100644
--- a/lib/RT/Action/RTIR_UnsetDue.pm
+++ b/lib/RT/Action/RTIR_UnsetDue.pm
@@ -50,18 +50,6 @@ use warnings;
 package RT::Action::RTIR_UnsetDue;
 use base 'RT::Action::RTIR';
 
-=head2 Prepare
-
-Always run this.
-
-=cut
-
-sub Prepare {
-    my $self = shift;
-
-    return 1;
-}
-
 =head2 Commit
 
 Set the Due date accordingly.

commit fdfc443f52ef1c9a9b1a9203e355f3621f443f3b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Jul 11 18:26:36 2011 +0400

    drop "# {{{ sub Commit" lines

diff --git a/lib/RT/Action/RTIR_SetDueBySLA.pm b/lib/RT/Action/RTIR_SetDueBySLA.pm
index a4e2a3d..a80cd08 100644
--- a/lib/RT/Action/RTIR_SetDueBySLA.pm
+++ b/lib/RT/Action/RTIR_SetDueBySLA.pm
@@ -50,7 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueBySLA;
 use base 'RT::Action::RTIR';
 
-# {{{ sub Commit
 
 =head2 Commit
 
diff --git a/lib/RT/Action/RTIR_SetDueCorrespond.pm b/lib/RT/Action/RTIR_SetDueCorrespond.pm
index 2761fcd..2b7a5e4 100644
--- a/lib/RT/Action/RTIR_SetDueCorrespond.pm
+++ b/lib/RT/Action/RTIR_SetDueCorrespond.pm
@@ -50,7 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueCorrespond;
 use base 'RT::Action::RTIR';
 
-# {{{ sub Commit
 
 =head2 Commit
 
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index e0ecae8..2570660 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -50,7 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueIncident;
 use base 'RT::Action::RTIR';
 
-# {{{ sub Commit
 
 =head2 Commit
 
diff --git a/lib/RT/Action/RTIR_SetDueReopen.pm b/lib/RT/Action/RTIR_SetDueReopen.pm
index f42fd0f..01bdb57 100644
--- a/lib/RT/Action/RTIR_SetDueReopen.pm
+++ b/lib/RT/Action/RTIR_SetDueReopen.pm
@@ -50,7 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetDueReopen;
 use base 'RT::Action::RTIR';
 
-# {{{ sub Commit
 
 =head2 Commit
 
diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index 7bd512d..6769094 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -50,7 +50,6 @@ use warnings;
 package RT::Action::RTIR_SetHowReported;
 use base 'RT::Action::RTIR';
 
-# {{{ sub Commit
 
 =head2 Commit
 

commit e68e2c57cf12c4e9a00d47ad0f7265f22201c7e8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 00:10:07 2011 +0400

    ItemsArrayRef in RT::Tickets may return undef
    
    it's customized and doesn't behave like super version :(

diff --git a/html/RTIR/Elements/AttachReports b/html/RTIR/Elements/AttachReports
index 60e32cd..d467b0b 100644
--- a/html/RTIR/Elements/AttachReports
+++ b/html/RTIR/Elements/AttachReports
@@ -19,7 +19,7 @@ my $type = RT::IR::TicketType( Ticket => $Ticket );
 if ( $type eq 'Incident' ) {
     push @parents, $Ticket->id;
 } else {
-    push @parents, map $_->id, @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef };
+    push @parents, map $_->id, @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] };
 }
 return unless @parents;
 

commit 7781fb1878951eebb5a305ed32a77c31b0fa4761
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 01:00:07 2011 +0400

    test that report gets opened on linking to incident

diff --git a/t/report/status.t b/t/report/status.t
new file mode 100644
index 0000000..5d06565
--- /dev/null
+++ b/t/report/status.t
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::IR::Test tests => 30;
+
+RT::Test->started_ok;
+my $agent = default_agent();
+
+diag "link IR to Inc on create" if $ENV{'TEST_VERBOSE'};
+{
+    my $inc_id = $agent->create_incident( { Subject => "test" } );
+    my $ir_id = $agent->create_ir( { Subject => "test", Incident => $inc_id } );
+    is $agent->ticket_status($ir_id), 'open', 'auto open kicked in';
+}
+
+diag "link IR to Inc after create" if $ENV{'TEST_VERBOSE'};
+{
+    my $inc_id = $agent->create_incident( { Subject => "test" } );
+    my $ir_id = $agent->create_ir( { Subject => "test" } );
+    is $agent->ticket_status($ir_id), 'new', 'auto open kicked in';
+
+    {
+        my $inc = RT::Ticket->new( RT->SystemUser );
+        $inc->Load( $inc_id );
+        my $ir = RT::Ticket->new( RT->SystemUser );
+        $ir->Load( $ir_id );
+        my ($status, $msg) = $ir->AddLink( Type => 'MemberOf', Target => $inc_id );
+        ok($status, 'linked IR with Inc') or diag "error: $msg";
+    }
+
+    is $agent->ticket_status($ir_id), 'open', 'auto open kicked in';
+}
+

commit e082bad994e8153ea7728a195f3bbfa8f2d2e923
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 01:48:15 2011 +0400

    delete SetStartedToNow action and all scrips
    
    Started should be controlled by lifecycles

diff --git a/etc/initialdata b/etc/initialdata
index d0c6b00..12ae0ae 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -181,10 +181,6 @@
        Description => 'Set the starts date to the current time' ,                                            # loc
        ExecModule => 'RTIR_SetStartsToNow',
     },
-    {  Name        => 'RTIR Set Started to Now',    # loc
-       Description => 'Set the started date to the current time' ,                                            # loc
-       ExecModule => 'RTIR_SetStartedToNow',
-    },
     {  Name        => 'RTIR Set Due by SLA',    # loc
        Description => 'Set the due date according to SLA' ,                                            # loc
        ExecModule => 'RTIR_SetDueBySLA',
@@ -353,17 +349,6 @@
        ScripAction       => 'RTIR Set Starts by Business Hours',
        Template          => 'Blank' },
 
-    {  Description       => "SetStarted",
-       Queue             => 'Blocks',
-       ScripCondition    => 'RTIR Block Activation',
-       ScripAction       => 'RTIR Set Started to Now',
-       Template          => 'Blank' },
-    {  Description       => "SetStarted",
-       Queue             => 'Incident Reports',
-       ScripCondition    => 'RTIR Linking To Incident',
-       ScripAction       => 'RTIR Set Started to Now',
-       Template          => 'Blank' },
-
     {  Description       => "SetDue",
        Queue             => 'Incident Reports',
        ScripCondition    => 'On Create',
diff --git a/lib/RT/Action/RTIR_SetStartedToNow.pm b/lib/RT/Action/RTIR_SetStartedToNow.pm
deleted file mode 100644
index 57a7a0a..0000000
--- a/lib/RT/Action/RTIR_SetStartedToNow.pm
+++ /dev/null
@@ -1,34 +0,0 @@
-use strict;
-use warnings;
-
-package RT::Action::RTIR_SetStartedToNow;
-use base 'RT::Action::RTIR';
-
-=head2 Commit
-
-Set the Started date to now.
-
-=cut
-
-sub Commit {
-    my $self = shift;
-
-    my $ticket = $self->TicketObj;
-
-    # set if the Started value isn't already set
-    return 1 if $ticket->StartedObj->Unix > 0;
-
-    my $date = RT::Date->new( $RT::SystemUser );
-    $date->SetToNow;
-    my ($status, $msg) = $ticket->SetStarted( $date->ISO );
-    unless ( $status ) {
-        $RT::Logger->error("Couldn't set date: $msg");
-        return 0;
-    }
-
-    return 1;
-}
-
-RT::Base->_ImportOverlays;
-
-1;

commit 9f739d17ea5edadc3829385d4672eee1b365e517
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 01:53:57 2011 +0400

    new RTIR_Activate action
    
    It's will replace SetState action for IRs
    It's like AutoOpen in RT, but doesn't check who updated ticket

diff --git a/etc/initialdata b/etc/initialdata
index 12ae0ae..4ecf232 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -253,6 +253,10 @@
        Description => 'Set group responsible for constituency' ,                                            # loc
        ExecModule  => 'RTIR_SetConstituencyGroup',
     },
+    {  Name        => 'RTIR Activate Ticket',    # loc
+       Description => 'Set status to first active possible',            # loc
+       ExecModule  => 'RTIR_Activate',
+    },
 );
 
 @ScripConditions = (
diff --git a/lib/RT/Action/RTIR_Activate.pm b/lib/RT/Action/RTIR_Activate.pm
new file mode 100644
index 0000000..3288a3d
--- /dev/null
+++ b/lib/RT/Action/RTIR_Activate.pm
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+
+package RT::Action::RTIR_Activate;
+use base 'RT::Action::RTIR';
+
+=head2 Commit
+
+Set status to first active that's possible to change to.
+
+=cut
+
+sub Commit {
+    my $self = shift;
+
+    my $ticket = $self->TicketObj;
+
+    my $new = $ticket->FirstActiveStatus;
+    return 1 unless $new;
+
+    my ($status, $msg) = $ticket->SetStatus( $new );
+    unless ( $status ) {
+        $RT::Logger->error( "Couldn't activate ticket: $msg" );
+        return 0;
+    }
+
+    return 1;
+}
+
+RT::Base->_ImportOverlays;
+
+1;

commit 06aeb5ee5dfd72d85d4f7a6e362a9b282d2625d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 01:58:10 2011 +0400

    replace SetIncidentReportState with another scrip
    
    old code dealt with more cases. we synced State CF with
    Status, now we don't and things are simpler.

diff --git a/etc/initialdata b/etc/initialdata
index 4ecf232..cfbbe1e 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -225,10 +225,6 @@
        Description => 'Open the parent Incident when a child reopens' ,                                            # loc
        ExecModule => 'RTIR_OpenParent',
     },
-    {  Name        => 'RTIR Set Incident Report State',    # loc
-       Description => 'Set the state of an Incident Report' ,                                            # loc
-       ExecModule => 'RTIR_SetIncidentReportState',
-    },
     {  Name        => 'RTIR Set Block State',    # loc
        Description => 'Set the state of a Block' ,                                            # loc
        ExecModule => 'RTIR_SetBlockState',
@@ -398,11 +394,12 @@
        ScripCondition    => 'RTIR Require State Change',
        ScripAction       => 'RTIR Set Block State',
        Template          => 'Blank', },
-    {  Description       => "SetRTIRState",
+    {  Description       => "On Linking To Incident Activate Report",
        Queue             => 'Incident Reports',
-       ScripCondition    => 'RTIR Require State Change',
-       ScripAction       => 'RTIR Set Incident Report State',
-       Template          => 'Blank', },
+       ScripCondition    => 'RTIR Linking To Incident',
+       ScripAction       => 'RTIR Activate Ticket',
+       Template          => 'Blank' },
+
 
 # XXX: description is duplication, but set Due of the incident
     {  Description       => "SetRTIRState",
diff --git a/lib/RT/Action/RTIR_SetIncidentReportState.pm b/lib/RT/Action/RTIR_SetIncidentReportState.pm
deleted file mode 100644
index ef88562..0000000
--- a/lib/RT/Action/RTIR_SetIncidentReportState.pm
+++ /dev/null
@@ -1,82 +0,0 @@
-# {{{ BEGIN BPS TAGGED BLOCK
-# 
-# COPYRIGHT:
-#  
-# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
-#                                          <jesse 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-# 
-# 
-# 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
-#
-use strict;
-use warnings;
-
-package RT::Action::RTIR_SetIncidentReportState;
-use base 'RT::Action::RTIR_SetState';
-
-=head2 GetState
-
-Returns state of the C<Incident Report>.
-
-=cut
-
-sub GetState {
-    my $self = shift;
-
-    my $status = $self->TicketObj->Status;
-    return $status if $status eq 'resolved' || $status eq 'rejected';
-
-    if ( $status =~ /^(?:new|open|stalled)$/ ) {
-        # TODO: check how do we set (control) Status of the IR
-        # may be we don't need to check this conditions and
-        # just use status value as in other RTIR_Set*State actions
-
-        my $parents = RT::Tickets->new( $self->TransactionObj->CurrentUser );
-        $parents->LimitHasMember( $self->TicketObj->id );
-        $parents->LimitQueue( VALUE => 'Incidents' );
-        return 'open' if $parents->Count;
-        return 'new';
-    }
-
-    return '';
-}
-
-RT::Base->_ImportOverlays;
-
-1;

commit e8e87b1417621a9034d199a93c6c67faf9b1462f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 16:50:34 2011 +0400

    replace SetBlockState with smaller SetBlockStatus
    
    * we don't need custom condition for Blocks,
      it's just 'On Correspond'
    * we don't need SetState super class

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index ee0d456..a4e080b 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -24,6 +24,8 @@
   Status changes
 ** it's there, but we should make it faster
 
+* upgrade script that deletes and renames scrips
+
 === BRINGING UP TO DATE
 
 * Some pages with forms need new nice layouts like in RT, reply
@@ -58,9 +60,6 @@
   anyway we break backwards compatibility, let's be consistent
   and ditch the word
 
-* split SetState action and conditions for IRs and Blocks.
-  they just have different workflow now
-
 * migrate SetIncidentReportState over lifecycles
 
 * make Submit buttons names consistent with RT's
diff --git a/etc/initialdata b/etc/initialdata
index cfbbe1e..ff9e61b 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -225,9 +225,9 @@
        Description => 'Open the parent Incident when a child reopens' ,                                            # loc
        ExecModule => 'RTIR_OpenParent',
     },
-    {  Name        => 'RTIR Set Block State',    # loc
-       Description => 'Set the state of a Block' ,                                            # loc
-       ExecModule => 'RTIR_SetBlockState',
+    {  Name        => 'RTIR Set Block Status',    # loc
+       Description => 'Set the status of a Block' ,                                            # loc
+       ExecModule => 'RTIR_SetBlockStatus',
     },
     {  Name        => 'RTIR Set Incident Resolution',    # loc
        Description => 'Set the default resolution of an Incident' ,                                            # loc
@@ -277,11 +277,6 @@
        ApplicableTransTypes => 'Any',
        ExecModule => 'RTIR_ReopenTicket',
     },
-    {  Name        => 'RTIR Require State Change',    # loc
-       Description => 'A ticket requires a state change' ,                                            # loc
-       ApplicableTransTypes => 'Any',
-       ExecModule => 'RTIR_RequireStateChange',
-    },
     {  Name        => 'RTIR Require Due Change',    # loc
        Description => 'The due date of the parent incident must be changed',                                            # loc
        ApplicableTransTypes => 'Any',
@@ -389,10 +384,10 @@
        ScripAction       => 'RTIR Set How Reported',
        Template          => 'Blank' },
 
-    {  Description       => "SetRTIRState",
+    {  Description       => "On Correspond Change Status of the Block",
        Queue             => 'Blocks',
-       ScripCondition    => 'RTIR Require State Change',
-       ScripAction       => 'RTIR Set Block State',
+       ScripCondition    => 'On Correspond',
+       ScripAction       => 'RTIR Set Block Status',
        Template          => 'Blank', },
     {  Description       => "On Linking To Incident Activate Report",
        Queue             => 'Incident Reports',
diff --git a/lib/RT/Action/RTIR_SetBlockState.pm b/lib/RT/Action/RTIR_SetBlockStatus.pm
similarity index 74%
rename from lib/RT/Action/RTIR_SetBlockState.pm
rename to lib/RT/Action/RTIR_SetBlockStatus.pm
index bc62c08..c7dec9d 100644
--- a/lib/RT/Action/RTIR_SetBlockState.pm
+++ b/lib/RT/Action/RTIR_SetBlockStatus.pm
@@ -47,41 +47,49 @@
 use strict;
 use warnings;
 
-package RT::Action::RTIR_SetBlockState;
-use base 'RT::Action::RTIR_SetState';
+package RT::Action::RTIR_SetBlockStatus;
+use base 'RT::Action::RTIR';
 
-=head1 GetState
+=head2 Commit
 
-Returns state of the C<Block>.
+Set the state according to the status.
 
 =cut
 
-sub GetState {
+sub Commit {
     my $self = shift;
 
+    my $t = $self->TicketObj;
     my $txn = $self->TransactionObj;
-    return unless $txn->Type eq 'Correspond';
 
-    my $status = lc $self->TicketObj->Status;
-    if ( $status =~ /^pending / && $txn->IsInbound ) {
+    my $new;
+
+    my $current = lc $t->Status;
+    if ( $current =~ /^pending / && $txn->IsInbound ) {
         if ( my $re = RT->Config->Get('RTIR_BlockAproveActionRegexp') ) {
             my $content = $txn->Content;
-            return '' if !$content || $content !~ /$re/;
+            return 1 if !$content || $content !~ /$re/;
         }
 
-        if ( $status eq 'pending activation' ) {
+        if ( $current eq 'pending activation' ) {
             # switch to active state if it is reply from requestor(s)
-            return 'active';
-        } elsif ( $status eq 'pending removal' ) {
+            $new = 'active';
+        } elsif ( $current eq 'pending removal' ) {
             # switch to removed state when requestor(s) replies
-            return 'removed';
-        }
-        else {
-            return '';
+            $new = 'removed';
         }
     }
+    
+    if ( !$new && $t->QueueObj->Lifecycle->IsInactive( $current ) ) {
+        $new = $t->FirstActiveStatus;
+    }
+    return 1 unless $new;
+
+    my ( $res, $msg ) = $t->SetStatus( $new );
+    $RT::Logger->warning("Couldn't set status to $new: $msg")
+        unless $res;
+    return 1;
 
-    return 'active' if $status eq 'removed';
 }
 
 RT::Base->_ImportOverlays;
diff --git a/lib/RT/Action/RTIR_SetState.pm b/lib/RT/Action/RTIR_SetState.pm
deleted file mode 100644
index f7da8cf..0000000
--- a/lib/RT/Action/RTIR_SetState.pm
+++ /dev/null
@@ -1,36 +0,0 @@
-use strict;
-use warnings;
-
-package RT::Action::RTIR_SetState;
-use base 'RT::Action::RTIR';
-
-=head2 Commit
-
-Set the state according to the status.
-
-=cut
-
-sub Commit {
-    my $self = shift;
-
-    my $t = $self->TicketObj;
-
-    my $txn = $self->TransactionObj;
- 
-    return 1 if $txn->Type eq 'Set' && $txn->Field eq 'Status';
-
-    my $status = $self->GetState;
-    return 1 unless $status;
-    return 1 if $t->Status eq $status;
-
-    my ( $res, $msg ) = $t->SetStatus( $status );
-    $RT::Logger->warning("Couldn't set status to $status: $msg")
-        unless $res;
-    return 1;
-}
-
-sub GetState { return '' }
-
-RT::Base->_ImportOverlays;
-
-1;
diff --git a/lib/RT/Condition/RTIR_RequireStateChange.pm b/lib/RT/Condition/RTIR_RequireStateChange.pm
deleted file mode 100644
index 359b899..0000000
--- a/lib/RT/Condition/RTIR_RequireStateChange.pm
+++ /dev/null
@@ -1,77 +0,0 @@
-# {{{ BEGIN BPS TAGGED BLOCK
-# 
-# COPYRIGHT:
-#  
-# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
-#                                          <jesse 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-# 
-# 
-# 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
-use strict;
-use warnings;
-
-package RT::Condition::RTIR_RequireStateChange;
-use base 'RT::Condition::RTIR';
-
-
-=head2 IsApplicable
-
-If the ticket was closed
-
-=cut
-
-sub IsApplicable {
-    my $self = shift;
-
-    my $type = $self->TransactionObj->Type;
-    return 1 if $type eq "Create";
-
-    my $field = $self->TransactionObj->Field;
-    return 1 if
-        ( $type =~ /^(Add|Delete)Link$/ and $field =~ /^(MemberOf|MergedInto)$/ ) or
-        ( $type eq "Set" and $field eq "Queue" );
-
-    return 1 if $type eq 'Correspond' && $self->TicketObj->QueueObj->Name eq 'Blocks';
-
-    return 0;
-}
-
-RT::Base->_ImportOverlays;
-
-1;

commit 9d8e1db846cdc1fbf48c1ae8cb782c2181441395
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 18:49:30 2011 +0400

    more diag out of 011-merge.t

diff --git a/t/011-merge.t b/t/011-merge.t
index 106f285..7df9d21 100644
--- a/t/011-merge.t
+++ b/t/011-merge.t
@@ -30,8 +30,7 @@ diag "simple merge of IRs" if $ENV{'TEST_VERBOSE'};
 
 }
 
-diag "merge an IR into a linked IR, the product should have open state"
-    if $ENV{'TEST_VERBOSE'};
+diag "merge an IR into a linked IR, the product should have open state" if $ENV{'TEST_VERBOSE'};
 {
     my $inc_id = $agent->create_incident( {Subject => "base inc for merging"});
     my $ir1_id = $agent->create_ir( {Subject => "ir1 for merging", Incident => $inc_id});
@@ -58,6 +57,8 @@ diag "merge an IR into a linked IR, the product should have open state"
     $agent->ticket_status_is( $ir2_id, 'open' );
 }
 
+diag "merge a linked IR into an IR, the product should have open state"
+    if $ENV{'TEST_VERBOSE'};
 { # as previouse but with reversed merge operation
     my $ir1_id = $agent->create_ir( {Subject => "ir2 for merging"});
 
@@ -84,7 +85,8 @@ diag "merge an IR into a linked IR, the product should have open state"
     $agent->ticket_status_is( $ir1_id, 'open' );
 }
 
-{ # merge two IRs that are linked to different Incidents
+diag "merge two IRs that are linked to different Incidents" if $ENV{'TEST_VERBOSE'};
+{
     my $inc1_id = $agent->create_incident( {Subject => "base inc1 for merging"});
     my $ir1_id = $agent->create_ir( {Subject => "ir1 for merging", Incident => $inc1_id});
 

commit dc3eceb4e87375ea2a3076439e0e4ed452cbc730
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 18:51:52 2011 +0400

    treat merge of linked as linking to an incident

diff --git a/lib/RT/Condition/RTIR_LinkingToIncident.pm b/lib/RT/Condition/RTIR_LinkingToIncident.pm
index c39d19e..cf0d4d1 100644
--- a/lib/RT/Condition/RTIR_LinkingToIncident.pm
+++ b/lib/RT/Condition/RTIR_LinkingToIncident.pm
@@ -29,7 +29,9 @@ sub IsApplicable {
         }
         return $parent->QueueObj->Name eq 'Incidents';
     }
-
+    elsif ( $type eq 'AddLink' && $field eq 'MergedInto' ) {
+        return RT::IR->Incidents( $self->TicketObj )->Count;
+    }
     return 0;
 }
 

commit 2548b9999799e618336e7fff135faca235bc0912
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 12 22:38:00 2011 +0400

    there is no need in initial status for incidents

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 6cf0b18..699b413 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -280,7 +280,7 @@ Set(@Active_MakeClicky, qw(httpurl_overwrite ip email domain));
 Set(
     %Lifecycles,
     incidents => {
-        initial         => ['open'],
+        initial         => [],
         active          => ['open'],
         inactive        => ['resolved', 'abandoned'],
 

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


More information about the Rt-commit mailing list