[Rt-commit] rtir branch, 2.9-trunk, created. 8bea22223848861aa0e08c2c268ab23083efa964

Jesse Vincent jesse at bestpractical.com
Sun Oct 24 10:59:48 EDT 2010


The branch, 2.9-trunk has been created
        at  8bea22223848861aa0e08c2c268ab23083efa964 (commit)

- Log -----------------------------------------------------------------
commit 17cd91c61f3f679c4dfa79eb87052167ba134e9b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 21 21:03:23 2010 +0800

    no ::Generic module any more

diff --git a/lib/RT/Action/RTIR.pm b/lib/RT/Action/RTIR.pm
index 58bd3a0..e19b1dc 100644
--- a/lib/RT/Action/RTIR.pm
+++ b/lib/RT/Action/RTIR.pm
@@ -4,7 +4,7 @@ use strict;
 use RT::IR;
 package RT::Action::RTIR;
 
-use base 'RT::Action::Generic';
+use base 'RT::Action';
 
 sub CreatorCurrentUser {
     my $self = shift;
diff --git a/lib/RT/Condition/RTIR.pm b/lib/RT/Condition/RTIR.pm
index 21363d4..9d0d5f7 100644
--- a/lib/RT/Condition/RTIR.pm
+++ b/lib/RT/Condition/RTIR.pm
@@ -4,7 +4,7 @@ use strict;
 use RT::IR;
 
 package RT::Condition::RTIR;
-use base 'RT::Condition::Generic';
+use base 'RT::Condition';
 
 =head1 NAME
 

commit 29f73d54b997922f7a5d7e7737ead646ca91d6f6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 21 21:03:51 2010 +0800

    no ActiveStatus or alike in config any more

diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index ada2064..1533666 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -84,7 +84,8 @@ sub Commit {
                 .") AND MemberOf = " . $id
                 ." AND ("
                 # TODO: move to per queue statuses lists
-                . join(" AND ", map "Status != '$_'", RT->Config->Get('InactiveStatus') )
+                . join(" AND ", map "Status != '$_'",
+                        RT::Queue->InactiveStatusArray )
                 .")";
 
     my $members = new RT::Tickets( $self->TransactionObj->CurrentUser );
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index 1208ae3..400936e 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -102,7 +102,8 @@ sub UpdateDue {
                 ." OR Queue = 'Blocks'"
                 .") AND MemberOf = " . $incident->Id
                 ." AND ("
-                . join( " OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') )
+                . join( " OR ", map "Status = '$_'",
+                        RT::Queue->ActiveStatusArray )
                 .")";
     my $children = new RT::Tickets($self->CurrentUser);
     $children->FromSQL( $query );
diff --git a/lib/RT/IR/Ticket.pm b/lib/RT/IR/Ticket.pm
index 693e6e6..b6cc906 100644
--- a/lib/RT/IR/Ticket.pm
+++ b/lib/RT/IR/Ticket.pm
@@ -41,7 +41,8 @@ sub IsLinkedToActiveIncidents {
 
     my $query =  "Queue = 'Incidents'"
                 ." AND HasMember = ". $child->id
-                ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." ) ";
+                ." AND ( ". join(" OR ", map "Status = '$_'",
+                            RT::Queue->ActiveStatusArray ) ." ) ";
 
     $query   .= " AND id != ". $parent->Id if $parent;
 

commit 764d4ce59b6897fde4406cb59f33a42e0bd9f9fc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 21 22:00:55 2010 +0800

    we have IPAddressRange in rt 3.9

diff --git a/etc/initialdata b/etc/initialdata
index 49121c4..f8018e9 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -31,9 +31,9 @@
     },
 );
 
-use Regexp::Common qw(net);
-use Regexp::Common::net::CIDR();
-my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IPv4})?\s*|$RE{net}{CIDR}{IPv4})$};
+#use Regexp::Common qw(net);
+#use Regexp::Common::net::CIDR();
+#my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IPv4})?\s*|$RE{net}{CIDR}{IPv4})$};
 
 
 @CustomFields = (
@@ -184,8 +184,7 @@ my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IP
     },
     {
         Name        => 'IP',
-        Type        => 'FreeformMultiple',
-        Pattern     => "$ip_pattern",
+        Type        => 'IPAddressRangeMultiple',
         Queue       => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
         Disabled    => 0,
         Description => 'IP address for RTIR queues',
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 5a9b246..1ecdb79 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -307,171 +307,7 @@ sub DefaultConstituency {
 }
 
 
-# IPs processing hooks
-# in order too implement searches by IP ranges we
-# store IPs in "%03d.%03d.%03d.%03d" format so ops
-# like > and < make sense.
 use Hook::LexWrap;
-use Regexp::Common qw(RE_net_IPv4);
-use Regexp::Common::net::CIDR;
-require Net::CIDR;
-
-sub ParseIPRange {
-    my $arg = shift or return ();
-
-    if ( $arg =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/go ) {
-        my $cidr = join( '.', map $_||0, (split /\./, $1)[0..3] ) ."/$2";
-        $arg = (Net::CIDR::cidr2range( $cidr ))[0] || $arg;
-    }
-
-    my ($sIP, $eIP);
-    if ( $arg =~ /^\s*($RE{net}{IPv4})\s*$/o ) {
-        $sIP = $eIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $1;
-    }
-    elsif ( $arg =~ /^\s*($RE{net}{IPv4})-($RE{net}{IPv4})\s*$/o ) {
-        $sIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $1;
-        $eIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $2;
-    }
-    else {
-        return ();
-    }
-    ($sIP, $eIP) = ($eIP, $sIP) if $sIP gt $eIP;
-
-    return $sIP, $eIP;
-}
-
-
-# limit formatting "%03d.%03d.%03d.%03d"
-# "= 'sIP-eIP'" => "( >=sIP AND <=eIP)"
-# "!= 'sIP-eIP'" => "( <sIP OR >eIP)"
-# two ranges intercect when ( eIP1 >= sIP2 AND sIP1 <= eIP2 )
-require RT::Tickets;
-wrap 'RT::Tickets::_CustomFieldLimit',
-    pre => sub {
-        return if $_[2] && $_[2] =~ /^[<>]=?$/;
-        return unless $_[3] =~ /^\s*($RE{net}{IPv4})\s*(?:-\s*($RE{net}{IPv4})\s*)?$/o;
-        my ($start_ip, $end_ip) = ($1, ($2 || $1));
-        $_ = sprintf "%03d.%03d.%03d.%03d", split /\./, $_
-            for $start_ip, $end_ip;
-        ($start_ip, $end_ip) = ($end_ip, $start_ip) if $start_ip gt $end_ip;
-
-        my ($tickets, $field, $op, $value, %rest) = @_[0..($#_-1)];
-        $tickets->_OpenParen;
-        unless ( $op =~ /NOT|!=|<>/i ) { # positive equation
-            $tickets->_CustomFieldLimit(
-                $field, '<=', $end_ip, %rest,
-                SUBKEY => $rest{'SUBKEY'}. '.Content',
-            );
-            $tickets->_CustomFieldLimit(
-                $field, '>=', $start_ip, %rest,
-                SUBKEY          => $rest{'SUBKEY'}. '.LargeContent',
-                ENTRYAGGREGATOR => 'AND',
-            );
-            # as well limit borders so DB optimizers can use better
-            # estimations and scan less rows
-            $tickets->_CustomFieldLimit(
-                $field, '>=', '000.000.000.000', %rest,
-                SUBKEY          => $rest{'SUBKEY'}. '.Content',
-                ENTRYAGGREGATOR => 'AND',
-            );
-            $tickets->_CustomFieldLimit(
-                $field, '<=', '255.255.255.255', %rest,
-                SUBKEY          => $rest{'SUBKEY'}. '.LargeContent',
-                ENTRYAGGREGATOR => 'AND',
-            );
-        }
-        else { # negative equation
-            $tickets->_CustomFieldLimit($field, '>', $end_ip, %rest);
-            $tickets->_CustomFieldLimit(
-                $field, '<', $start_ip, %rest,
-                SUBKEY          => $rest{'SUBKEY'}. '.LargeContent',
-                ENTRYAGGREGATOR => 'OR',
-            );
-            # TODO: as well limit borders so DB optimizers can use better
-            # estimations and scan less rows, but it's harder to do
-            # as we have OR aggregator
-        }
-        $tickets->_CloseParen;
-        # return right now as we did everything
-        $_[-1] = ref $_[-1]? [1]: 1;
-    };
-
-# "[!]= 'CIDR'" => "op 'sIP-eIP'"
-wrap 'RT::Tickets::_CustomFieldLimit',
-    pre => sub {
-        return unless $_[3] =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/o;
-        # convert incomplete 192.168/24 to 192.168.0.0/24 format
-        my $cidr = join( '.', map $_||0, (split /\./, $1)[0..3] ) ."/$2";
-        # convert to range and continue, it will be catched by next wrapper
-        $_[3] = (Net::CIDR::cidr2range( $cidr ))[0] || $_[3];
-    };
-$RT::Tickets::dispatch{'CUSTOMFIELD'} = \&RT::Tickets::_CustomFieldLimit;
-
-# on OCFV create format storage
-require RT::ObjectCustomFieldValue;
-wrap 'RT::ObjectCustomFieldValue::Create',
-    pre => sub {
-        my %args = @_[1.. at _-2];
-        my $cf = GetCustomField( 'IP' );
-        unless ( $cf && $cf->id ) {
-            $RT::Logger->crit("Couldn't load IP CF");
-            return;
-        }
-        return unless $cf->id == $args{'CustomField'};
-
-        for ( my $i = 1; $i < @_; $i += 2 ) {
-            next unless $_[$i] && $_[$i] eq 'Content';
-
-            my ($sIP, $eIP) = ParseIPRange( $_[++$i] );
-            unless ( $sIP && $eIP ) {
-                $_[-1] = 0;
-                return;
-            }
-            $_[$i] = $sIP;
-
-            my $flag = 0;
-            for ( my $j = 1; $j < @_; $j += 2 ) {
-                next unless $_[$j] && $_[$j] eq 'LargeContent';
-                $flag = $_[++$j] = $eIP;
-                last;
-            }
-            splice @_, -1, 0, LargeContent => $eIP unless $flag;
-            return;
-        }
-    };
-
-# strip zero chars(deserialize)
-{
-my $re_ip_sunit = qr/[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5]/;
-my $re_ip_serialized = qr/$re_ip_sunit(?:\.$re_ip_sunit){3}/;
-my $obj;
-wrap 'RT::ObjectCustomFieldValue::Content',
-    pre  => sub { $obj = $_[0] },
-    post => sub {
-        return unless $_[-1];
-        my $val = ref $_[-1]? \$_[-1][0]: \$_[-1];
-        return unless $$val =~ /^\s*($re_ip_serialized)\s*$/o;
-        $$val = sprintf "%d.%d.%d.%d", split /\./, $1;
-
-        my $large_content = $obj->__Value('LargeContent');
-        return if !$large_content
-            || $large_content !~ /^\s*($re_ip_serialized)\s*$/o;
-        my $eIP = sprintf "%d.%d.%d.%d", split /\./, $1;
-        $$val .= '-'. $eIP unless $$val eq $eIP;
-        return;
-    };
-}
-
-# don't return LargeContent to avoid making angry RT's AddCFV logic
-wrap 'RT::ObjectCustomFieldValue::LargeContent',
-    pre  => sub {
-        my $obj = $_[0];
-        my $cf = GetCustomField( 'IP' );
-        return unless $cf && $cf->id;
-        return unless $obj->CustomField == $cf->id;
-        $_[-1] = undef;
-    };
-
 
 if ( RT::IR->HasConstituency ) {
     # ACL checks for multiple constituencies
@@ -658,31 +494,4 @@ 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});
 
-package RT::ObjectCustomFieldValue;
-
-use strict;
-use warnings;
-
-sub LoadByCols {
-    my $self = shift;
-    my %args = @_;
-    return $self->SUPER::LoadByCols( %args )
-        unless $args{'CustomField'} && $args{'Content'};
-
-    my $cf = RT::IR::GetCustomField( 'IP' );
-    unless ( $cf && $cf->id ) {
-        $RT::Logger->crit("Couldn't load IP CF");
-        return $self->SUPER::LoadByCols( %args )
-    }
-    return $self->SUPER::LoadByCols( %args )
-        unless $cf->id == $args{'CustomField'};
-
-    my ($sIP, $eIP) = RT::IR::ParseIPRange( $args{'Content'} );
-    return $self->SUPER::LoadByCols( %args )
-        unless $sIP && $eIP;
-
-    return $self->SUPER::LoadByCols( %args, Content => $sIP, LargeContent => $eIP );
-}
-
-
 1;
diff --git a/t/custom-fields/ip.t b/t/custom-fields/ip.t
index 8bfb2cf..6c09d25 100644
--- a/t/custom-fields/ip.t
+++ b/t/custom-fields/ip.t
@@ -18,7 +18,7 @@ diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
     is( $cfs->Count, 1, "found one CF with name 'IP'" );
 
     $cf = $cfs->First;
-    is( $cf->Type, 'Freeform', 'type check' );
+    is( $cf->Type, 'IPAddressRange', 'type check' );
     is( $cf->LookupType, 'RT::Queue-RT::Ticket', 'lookup type check' );
     ok( !$cf->MaxValues, "unlimited number of values" );
     ok( !$cf->Disabled, "not disabled" );

commit 4f3a8869f2adc89e4c7ee99c624acb8f495b95cd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 23 00:14:21 2010 +0800

    typo fix

diff --git a/t/custom-fields/defaults-on-linking.t b/t/custom-fields/defaults-on-linking.t
index e41fef0..ea41ee0 100644
--- a/t/custom-fields/defaults-on-linking.t
+++ b/t/custom-fields/defaults-on-linking.t
@@ -14,7 +14,7 @@ my $cf_name = 'test';
         Type       => 'FreeformSingle',
     );
 
-    for my $q ('Incident Reports', 'Investigation', 'Incidents', 'Blocks') {
+    for my $q ('Incident Reports', 'Investigations', 'Incidents', 'Blocks') {
         my $q_obj = RT::Queue->new($RT::SystemUser);
         $q_obj->Load($q);
         unless ( $q_obj->Id ) {

commit f2cc9a2b0c21ae012c8b8c33e50ca60d237729bd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Sep 24 19:33:06 2010 +0800

    disable cache of RT::IR::CustomFields

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 1ecdb79..9d7fa11 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -231,7 +231,12 @@ sub CustomFields {
         @_%2 ? (Field => @_) : @_
     );
 
-    unless ( keys %cache ) {
+# TODO cache doesn't work with rt 3.9
+# t/customfields/defaults-on-linking.t will fail with cache on
+# maybe because it's called too early somewhere?
+# anyway, seems caching here is not a great idea
+# as it will obstruct cf updates later?
+#    unless ( keys %cache ) {
         foreach my $qname ( @QUEUES ) {
             my $type = TicketType( Queue => $qname );
             $cache{$type} = [];
@@ -259,7 +264,7 @@ sub CustomFields {
         while ( my $cf = $cfs->Next ) {
             push @{ $cache{'Global'} }, $cf;
         }
-    }
+#    }
 
     my $type = TicketType( %arg );
 

commit a359cf99292bf387151d201f17d9b1e599272039
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 27 11:19:56 2010 +0800

    need to explicitly logout for relogin

diff --git a/t/constituency/basics.t b/t/constituency/basics.t
index a123ed6..d96d3e8 100644
--- a/t/constituency/basics.t
+++ b/t/constituency/basics.t
@@ -246,7 +246,7 @@ ok($from =~ /govnet/, "The from address pciked up the gov address");
 
 diag "check defaults";
 {
-    $agent->login('eduhandler', 'eduhandler');
+    $agent->login('eduhandler', 'eduhandler', logout => 1 );
     my $ir_id = $agent->create_ir(
         { Subject => "test" },
     );
@@ -257,7 +257,7 @@ diag "check defaults";
 
 diag "check defaults";
 {
-    $agent->login('govhandler', 'govhandler');
+    $agent->login('govhandler', 'govhandler', logout => 1);
     my $ir_id = $agent->create_ir(
         { Subject => "test" },
     );
@@ -268,7 +268,7 @@ diag "check defaults";
 
 diag "check defaults when creating inc with inv";
 {
-    $agent->login('govhandler', 'govhandler');
+    $agent->login('govhandler', 'govhandler', logout => 1);
 	my ($inc_id, $inv_id) = $agent->create_incident_and_investigation(
 	    {
             Subject => "Incident", 
@@ -289,7 +289,7 @@ diag "check defaults when creating inc with inv";
 
 diag "check defaults when creating inc with inv";
 {
-    $agent->login('eduhandler', 'eduhandler');
+    $agent->login('eduhandler', 'eduhandler', logout => 1);
 	my ($inc_id, $inv_id) = $agent->create_incident_and_investigation(
 	    {
             Subject => "Incident", 

commit ad04ef89cc27951da29ed1455d0d40983a634108
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 27 12:09:21 2010 +0800

    we need send_via_mailgate_and_http

diff --git a/t/constituency/email.t b/t/constituency/email.t
index efaa2dc..235cba1 100644
--- a/t/constituency/email.t
+++ b/t/constituency/email.t
@@ -41,7 +41,7 @@ Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue);
+        my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => $queue);
         is $status >> 8, 0, "The mail gateway exited ok";
         ok $id, "created ticket $id";
 
@@ -76,7 +76,7 @@ Subject: This is a test of constituency functionality
 Foob!
 EOF
         local $ENV{'EXTENSION'} = $val;
-        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue);
+        my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => $queue);
         is $status >> 8, 0, "The mail gateway exited ok";
         ok $id, "created ticket $id";
         $incident_id = $id if $queue eq 'Incidents';
diff --git a/t/constituency/email_outgoing.t b/t/constituency/email_outgoing.t
index dda7e33..3866cb2 100644
--- a/t/constituency/email_outgoing.t
+++ b/t/constituency/email_outgoing.t
@@ -68,7 +68,7 @@ Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
+    my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => 'Incident Reports');
     is $status >> 8, 0, "The mail gateway exited ok";
     ok $id, "created ticket $id";
 
@@ -103,7 +103,7 @@ Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports', extension => 'GOVNET');
+    my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => 'Incident Reports', extension => 'GOVNET');
     is $status >> 8, 0, "The mail gateway exited ok";
     ok $id, "created ticket $id";
 

commit 74fdc0c9c6a54218c519477f32352ba10e0cfa96
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 27 12:58:40 2010 +0800

    not set Started if changed from open

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 9d7fa11..eb4c807 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -371,11 +371,35 @@ if ( RT::IR->HasConstituency ) {
     };
 }
 
+require RT::Ticket;
+{
+    no warnings 'redefine';
+    my $set_status = RT::Ticket->can('SetStatus');
+    *RT::Ticket::SetStatus = sub {
+        my $self = shift;
+        my %args;
+        if ( @_ == 1 ) {
+
+            # it's called like $ticket->SetStatus('new')
+            $args{Status} = $_[0];
+        }
+        else {
+            %args = @_;
+        }
+
+        my $old  = $self->__Value('Status');
+        # if old status is open, we don't want to SetStarted
+        if ( $old eq 'open' ) {
+            $args{SetStarted} = 0;
+        }
+
+        $self->$set_status(%args);
+    };
+}
 
 if ( RT::IR->HasConstituency ) {
     # Queue {Comment,Correspond}Address for multiple constituencies
 
-    require RT::Ticket;
     wrap 'RT::Ticket::QueueObj', pre => sub {
         my $queue = RT::Queue->new($_[0]->CurrentUser);
         $queue->Load($_[0]->__Value('Queue'));

commit d9d4fe8cddeb17feaa2c294edfdb630d8e3c25e1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 27 13:00:37 2010 +0800

    remove CIDR dependencies since we have those in rt

diff --git a/Makefile.PL b/Makefile.PL
index 7736a43..5a61528 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,9 +33,6 @@ requires('Net::Whois::RIPE');
 # IP searching
 requires('Hook::LexWrap');
 requires('Regexp::Common');
-# CIDR parsing and converting
-requires('Net::CIDR');
-requires('Regexp::Common::net::CIDR');
 
 # for tests
 build_requires('Test::More');

commit 714ceb9e5911630466974074f7768c5d42f2247f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 27 14:00:02 2010 +0800

    avoid sned_via_mailgate_and_http if we can

diff --git a/t/constituency/email.t b/t/constituency/email.t
index 235cba1..431129f 100644
--- a/t/constituency/email.t
+++ b/t/constituency/email.t
@@ -41,7 +41,7 @@ Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-        my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => $queue);
+        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue);
         is $status >> 8, 0, "The mail gateway exited ok";
         ok $id, "created ticket $id";
 
@@ -56,7 +56,7 @@ EOF
     }
 }
 
-diag "create a ticket via gate using EXTENSION" if $ENV{'TEST_VERBOSE'};
+diag "create a ticket via gate using Extension header" if $ENV{'TEST_VERBOSE'};
 {
     my $i = 0;
 
@@ -71,12 +71,12 @@ diag "create a ticket via gate using EXTENSION" if $ENV{'TEST_VERBOSE'};
         my $text = <<EOF;
 From: @{[ $rtir_user->EmailAddress ]}
 To: rt\@@{[RT->Config->Get('rtname')]}
+X-RT-Mail-Extension: $val
 Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-        local $ENV{'EXTENSION'} = $val;
-        my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => $queue);
+        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue );
         is $status >> 8, 0, "The mail gateway exited ok";
         ok $id, "created ticket $id";
         $incident_id = $id if $queue eq 'Incidents';
diff --git a/t/constituency/email_outgoing.t b/t/constituency/email_outgoing.t
index 3866cb2..3b23598 100644
--- a/t/constituency/email_outgoing.t
+++ b/t/constituency/email_outgoing.t
@@ -68,7 +68,7 @@ Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-    my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => 'Incident Reports');
+    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
     is $status >> 8, 0, "The mail gateway exited ok";
     ok $id, "created ticket $id";
 
@@ -99,11 +99,12 @@ diag "create an IR under GOVNET";
     my $text = <<EOF;
 From: @{[ $rtir_user->EmailAddress ]}
 To: gov-reports\@example.com
+X-RT-Mail-Extension: GOVNET
 Subject: This is a test of constituency functionality
 
 Foob!
 EOF
-    my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, queue => 'Incident Reports', extension => 'GOVNET');
+    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
     is $status >> 8, 0, "The mail gateway exited ok";
     ok $id, "created ticket $id";
 

commit d3fcdddde54604c6e7d975d8b853acdb6a58e7b6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 7 13:26:16 2010 +0800

    use status since we have lifecycle

diff --git a/etc/initialdata b/etc/initialdata
index f8018e9..0b536a7 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -38,18 +38,6 @@
 
 @CustomFields = (
     {
-        Name        => 'State',
-        Type        => 'SelectSingle',
-        Queue       => 'Incidents',
-        Disabled    => 0,
-        Description => 'State for Incidents RTIR queue',
-        Values      => [
-            { Name      => "open",      SortOrder => 1 },
-            { Name      => "resolved",  SortOrder => 2 },
-            { Name      => "abandoned", SortOrder => 3 },
-        ],
-    },
-    {
         Name        => 'Constituency',
         Type        => 'SelectSingle',
         Queue       => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
@@ -61,43 +49,6 @@
         ],
     },
     {
-        Name        => 'State',
-        Type        => 'SelectSingle',
-        Queue       => 'Incident Reports',
-        Disabled    => 0,
-        Description => 'State for Incident Reports RTIR queue',
-        Values      => [
-            { Name      => "new",      SortOrder => 1 },
-            { Name      => "open",     SortOrder => 2 },
-            { Name      => "resolved", SortOrder => 3 },
-            { Name      => "rejected", SortOrder => 4 },
-        ],
-    },
-    {
-        Name        => 'State',
-        Type        => 'SelectSingle',
-        Queue       => 'Investigations',
-        Disabled    => 0,
-        Description => 'State for Investigations RTIR queue',
-        Values      => [
-            { Name      => "open",     SortOrder => 1 },
-            { Name      => "resolved", SortOrder => 2 },
-        ],
-    },
-    {
-        Name        => 'State',
-        Type        => 'SelectSingle',
-        Queue       => 'Blocks',
-        Disabled    => 0,
-        Description => 'State for Blocks RTIR queue',
-        Values      => [
-            { Name      => "pending activation", SortOrder => 1 },
-            { Name      => "active", SortOrder => 2 },
-            { Name      => "pending removal", SortOrder => 3 },
-            { Name      => "removed", SortOrder => 4 }
-        ],
-    },
-    {
         Name        => 'Description',
         Type        => 'FreeformSingle',
         Queue       => 'Incidents',
diff --git a/html/Callbacks/RTIR/Elements/ListActions/ModifyRow b/html/Callbacks/RTIR/Elements/ListActions/ModifyRow
index 3ad45c3..ea2ae0f 100644
--- a/html/Callbacks/RTIR/Elements/ListActions/ModifyRow
+++ b/html/Callbacks/RTIR/Elements/ListActions/ModifyRow
@@ -12,11 +12,6 @@ foreach my $item ( grep $_, @skiplist ) {
 # get out of here if we are not in RTIR space
 return unless $m->request_comp->path =~ m{^/RTIR/};
 
-# skip RT status updates
-# XXX: this doesn't work with localization
-if ( $$row =~ /^\s*(?:Ticket\s*#?\d+:\s*)?Status changed from/ ) {
-    return $$skip = 1;
-}
 </%INIT>
 
 <%ARGS>
diff --git a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
index 5c7a7bf..a1fb3b7 100644
--- a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
@@ -52,7 +52,7 @@ $COLUMN_MAP->{'HasIncident'} = {
         my $t = shift;
         my $yesno;
 
-        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND CF.{State} != 'rejected'";
+        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND Status != 'rejected'";
         my $incidents = new RT::Tickets($session{'CurrentUser'});
         $incidents->FromSQL($query);
 
diff --git a/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields b/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
index 1f96c13..66bba5b 100644
--- a/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
+++ b/html/Callbacks/RTIR/Ticket/Elements/EditCustomFields/MassageCustomFields
@@ -11,7 +11,7 @@ my $on_create = $QueueObj && !($TicketObj && $TicketObj->id);
 
 # We never want to see the RTIR custom fields State and Constituency in the edity ui
 $CustomFields->_OpenParen('RTIR');
-$CustomFields->Limit( SUBCLAUSE => 'RTIR', ENTRYAGGREGATOR => 'AND', FIELD => 'Name', OPERATOR => '!=', VALUE => 'State');
+# $CustomFields->Limit( SUBCLAUSE => 'RTIR', ENTRYAGGREGATOR => 'AND', FIELD => 'Name', OPERATOR => '!=', VALUE => 'State');
 $CustomFields->Limit( SUBCLAUSE => 'RTIR', ENTRYAGGREGATOR => 'AND', FIELD => 'Name', OPERATOR => '!=', VALUE => 'Constituency');
 $CustomFields->_CloseParen('RTIR');
 </%init>
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 4094f3f..32d07ef 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -62,7 +62,6 @@
 % }
 <input type="hidden" name="id" value="new" />
 <input type="hidden" name="Queue" value="<% $Queue %>" />
-<input type="hidden" name="Status" value="<% $Status || 'new' %>" />
 % if ( $Split ) {
 <input type="hidden" name="Ticket" value="<% $TicketObj->Id %>" />
 % }
@@ -99,6 +98,17 @@
   </tr>
 % }
   <tr>
+    <td class="label"><&|/l&>Status</&>:</td>
+    <td colspan="2">
+      <& /Elements/SelectStatus,
+          Name => 'Status',
+          QueueObj => $QueueObj,
+          DefaultValue => 0,
+#          Default => 'new',
+      &>
+    </td>
+  </tr>
+  <tr>
     <td class="label"><&|/l&>Owner</&>:</td>
     <td colspan="2">
       <& /Elements/SelectOwner, 
@@ -276,7 +286,7 @@ if ( $Type eq 'Report' ) {
 } elsif ( $Type eq 'Investigation' ) {
     $Status = 'open';
 } elsif ( $Type eq 'Block' ) {
-    $Status = 'new';
+    $Status = 'active';
 }
 $name ||= $Type;
 
diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index 4e38d44..4297eea 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -45,6 +45,12 @@
 &>
 <table>
   <tr>
+    <td class="label"><% loc("Status") %>:</td>
+    <td class="value" colspan="2">
+      <% $Ticket->Status %>
+    </td>
+  </tr>
+  <tr>
     <td class="label"><% loc("Incident") %>:</td>
     <td class="value" colspan="2">
       <& /RTIR/Elements/ShowIncidents, Ticket => $Ticket &>
@@ -157,13 +163,12 @@ if ( $id eq 'new' ) {
     }
     ($Ticket, @results) = CreateTicket( %ARGS, Attachments => delete $session{'Attachments'} );
 } elsif( $id ) {
-    my $oldstate = $Ticket->FirstCustomFieldValue('State') ||'';
     
     $m->callback(
         CallbackName => 'ProcessArguments', 
         Ticket => $Ticket,
         ARGSRef => \%ARGS,  
-        Actions => \@results
+        Actions => \@results,
     );
 
     if ( $ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/ ) {
@@ -190,13 +195,6 @@ if ( $id eq 'new' ) {
     $ARGS{UpdateAttachments} = delete $session{'Attachments'};
     push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
-    if ( $Type eq 'Block' && ($ARGS{'Status'}||'') eq 'open' && $Ticket->Status eq 'open' ) {
-        my ($id, $msg) = $Ticket->AddCustomFieldValue(
-            Field => 'State',
-            Value => 'active',
-        );
-        $RT::Logger->error("Couldn't set state: $msg");
-    }
     push @results, ProcessTicketBasics(  TicketObj => $Ticket, ARGSRef => \%ARGS );
 
     my $strict_acl = RT->Config->Set( StrictLinkACL => 0 );
@@ -204,11 +202,6 @@ if ( $id eq 'new' ) {
     RT->Config->Set( StrictLinkACL => $strict_acl );
 
     push @results, ProcessTicketDates(   TicketObj => $Ticket, ARGSRef => \%ARGS );
-
-    my $newstate = $Ticket->FirstCustomFieldValue('State') || '';
-    if ($newstate ne $oldstate) {
-        push (@results, loc("State changed from [_1] to [_2]", $oldstate, $newstate));
-    }
 }
 
 if ( $ARGS{'BulkArticles'} && @SelectedTickets ) {
@@ -226,15 +219,13 @@ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
 # update id argument in the case we took merged or created new
 $ARGS{'id'} = $id = $Ticket->Id;
 
-if ( @results ) {
-    # We've done something, so we need to clear the decks to avoid
-    # resubmission on refresh. But we need to store Actions somewhere
-    # too, so we don't lose them.
-    my $key = Digest::MD5::md5_hex( rand(1024) );
-    push @{ $session{"Actions"}{ $key } ||= [] }, @results;
-    $session{'i'}++;
-    RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."RTIR/Display.html?id=". $id ."&results=" . $key );
-}
+$m->comp(
+    '/Ticket/Elements/MaybeRedirectForResults',
+    Actions     => \@results,
+    Path        => 'RTIR/Display.html',
+    TicketObj   => $Ticket,
+);
+
 
 if ( $Type eq 'Report' ) {
     $name = "Incident Report";
diff --git a/html/RTIR/Edit.html b/html/RTIR/Edit.html
index 94ae82f..3de93ce 100644
--- a/html/RTIR/Edit.html
+++ b/html/RTIR/Edit.html
@@ -51,12 +51,17 @@
 
 <table>
   <tr>
-    <td class="label"><%loc("State")%>:</td>
+    <td class="label"><&|/l&>Status</&>:</td>
     <td class="value" colspan="2">
 % unless ( $Type eq 'Block' ) {
-      <& /RTIR/Elements/ShowRTIRField, Ticket => $Ticket, Name => 'State' &>
+      <% $Ticket->Status %>
 % } else {
-      <& /RTIR/Block/Elements/EditState, TicketObj => $Ticket, Default => $Ticket->Status &>
+      <& /Elements/SelectStatus,
+          Name => 'Status',
+          QueueObj => $Ticket->QueueObj,
+          DefaultValue => 0,
+          Default => $Ticket->Status,
+      &>
 % }
     </td>
   </tr>
@@ -169,7 +174,6 @@ if ( $constituency_propagation eq 'reject' ) {
 
 if ( $SaveChanges && !$OnlySearchForPeople ) {
     my $checks_failure = 0;
-    my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' );
     push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
     my $strict_acl = RT->Config->Set( StrictLinkACL => 0 );
@@ -192,10 +196,6 @@ if ( $SaveChanges && !$OnlySearchForPeople ) {
     $checks_failure = 1 unless $status;
     push @results, ProcessTicketCustomFieldUpdates( ARGSRef => \%ARGS );
 
-    my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' );
-    if ($newstate ne $oldstate) {
-        push (@results, loc("State changed from [_1] to [_2]", $oldstate, $newstate));
-    }
     if ( !$checks_failure && RT->Config->Get('DisplayAfterEdit', $session{'CurrentUser'}) ) {
         $m->callback(CallbackName => 'BeforeDisplay', ARGSRef => \%ARGS, Ticket => $Ticket);
         push @{ $session{'Actions'}{''} ||= [] }, @results;
diff --git a/html/RTIR/Elements/AttachReports b/html/RTIR/Elements/AttachReports
index ced93e6..5604efc 100644
--- a/html/RTIR/Elements/AttachReports
+++ b/html/RTIR/Elements/AttachReports
@@ -38,7 +38,7 @@ return unless $siblings->Count;
 my $Format = q{
     '<b><a HREF="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#',
     '<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></b>/TITLE:Subject',
-    '__CustomField.{State}__/TITLE:State',
+    '__Status__/TITLE:Status',
     __LastUpdatedRelative__, __CreatedRelative__
 };
 </%INIT>
diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index ac06fa9..a44f3b1 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -28,7 +28,7 @@
 %# XXX: why we don't use TicketList component here?
 <th><b><&|/l&>id<b></&></th>
 <th><b><&|/l&>Subject<b></&></th>
-<th><b><&|/l&>State<b></&></th>
+<th><b><&|/l&>Status<b></&></th>
 <th><b><&|/l&>Priority<b></&></th>
 <th align="right"><b><&|/l&>Actions<b></&></th>
 </tr>
@@ -45,7 +45,7 @@
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
-<td><& "/RTIR/Elements/ShowRTIRField", Ticket => $Ticket, Name => 'State' &>
+<td><%$Ticket->Status%></td>
 <td><%$Ticket->Priority%></td>
 % if ($Type eq 'Incident') {
 <td align="right"><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?Child=<%$Ticket->Id%>&id=<%$ticket%>">[<%loc("Link")%>]</a></td>
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 2136345..ee168de 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -27,7 +27,7 @@
 <tr>
 <td><b><&|/l&>id<b></&></td>
 <td><b><&|/l&>Subject<b></&></td>
-<td><b><&|/l&>State<b></&></td>
+<td><b><&|/l&>Status<b></&></td>
 <td><b><&|/l&>Priority<b></&></td>
 <td align="right"><b><&|/l&>Actions<b></&></td>
 </tr>
@@ -44,7 +44,7 @@
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
-<td><& "/RTIR/Elements/ShowRTIRField", Ticket => $Ticket, Name => 'State' &>
+<td><%$Ticket->Status%></td>
 </td>
 <td><%$Ticket->Priority%></td>
 <td align="right">
diff --git a/html/RTIR/Elements/NewQuery b/html/RTIR/Elements/NewQuery
index 8a7e4bb..f948565 100644
--- a/html/RTIR/Elements/NewQuery
+++ b/html/RTIR/Elements/NewQuery
@@ -8,7 +8,7 @@ my %seen = ();
 @states =  grep !$seen{$_}++, map lc, grep $_, @states, @add_states;
 
 my $query = join " OR ",
-            map "'CF.{State}' = '$_'",
+            map "'Status' = '$_'",
             @states;
 $query = "( $query )" if $query;
 return $query;
diff --git a/html/RTIR/Elements/QueueSummary b/html/RTIR/Elements/QueueSummary
index f916936..6c74ee2 100644
--- a/html/RTIR/Elements/QueueSummary
+++ b/html/RTIR/Elements/QueueSummary
@@ -18,13 +18,13 @@ Description => loc('RTIR queues summary')
 % for my $queue (@queues) {
 %   $i++;
 %   my $queue_cond = "Queue = '$queue'";
-%   my $all_q = "$queue_cond AND (". join( ' OR ', map "CF.{State} = '$_'", @{ $states{ $queue } } ).')';
+%   my $all_q = "$queue_cond AND (". join( ' OR ', map "Status = '$_'", @{ $states{ $queue } } ).')';
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 <td><a href="<% RT->Config->Get('WebPath')%>/Search/Results.html?Query=<% $all_q |un %>""><% $queue %></a></td>
 %   foreach my $s ( @states ) {
 <td align="right">
 %   if ( grep $_ eq $s, @{ $states{ $queue } } ) {
-%       my $query =  "$queue_cond AND CF.{State} = '$s'";
+%       my $query =  "$queue_cond AND Status = '$s'";
 %       $Tickets->FromSQL( $query );
 %       my $qs = $m->comp('/Elements/QueryString', Queue => $queue, Query => $query );
 <a href="<% RT->Config->Get('WebPath') %>/RTIR/Search/Results.html?<% $qs |n %>"><% $Tickets->Count %></a></td>
diff --git a/html/RTIR/Elements/QueueTabs b/html/RTIR/Elements/QueueTabs
index 183f674..e752c05 100644
--- a/html/RTIR/Elements/QueueTabs
+++ b/html/RTIR/Elements/QueueTabs
@@ -155,12 +155,12 @@ if ( $Ticket && $Ticket->QueueObj->Name eq $QueueName ) {
             $actions->{'A'} = {
                 title => loc('Reply to Reporters'),
                 path  =>
-                    "RTIR/Incident/Reply.html?id=$id&DefaultStatus=stalled&SelectAllTickets=1",
+                    "RTIR/Incident/Reply.html?id=$id&SelectAllTickets=1",
             };
             $actions->{'Ab'} = {
                 title => loc('Reply to All'),
                 path  =>
-                    "RTIR/Incident/Reply.html?id=$id&DefaultStatus=stalled&SelectAllTickets=1&All=1",
+                    "RTIR/Incident/Reply.html?id=$id&SelectAllTickets=1&All=1",
             };
         } elsif ( $Type eq 'Block' ) {
             $actions->{'A'} = {
@@ -172,7 +172,7 @@ if ( $Ticket && $Ticket->QueueObj->Name eq $QueueName ) {
             $actions->{'A'} = {
                 title => loc('Reply'),
                 path  =>
-                    "RTIR/Update.html?id=$id&Action=Respond&DefaultStatus=stalled",
+                    "RTIR/Update.html?id=$id&Action=Respond",
             };
         }
     }
@@ -198,32 +198,32 @@ if ( $Ticket && $Ticket->QueueObj->Name eq $QueueName ) {
                     title => loc('Quick Resolve'),
                 };
             } elsif ( $Type eq 'Block' ) {
-                if ( ($Ticket->FirstCustomFieldValue('State')||'') ne 'active' ) {
+                if ( $Ticket->Status ne 'active' ) {
                     $actions->{'Ab'} = {
-                        path  => "RTIR/Update.html?Action=Comment&DefaultStatus=open&id=$id",
+                        path  => "RTIR/Update.html?Action=Comment&DefaultStatus=active&id=$id",
                         title => loc('Activate')
                     };
                 }
                 $actions->{'Ac'} = {
-                    path  => "RTIR/Update.html?Action=Comment&DefaultStatus=resolved&id=$id",
+                    path  => "RTIR/Update.html?Action=Comment&DefaultStatus=removed&id=$id",
                     title => loc('Remove'),
                 };
                 $actions->{'Acc'} = {
-                    path  => "RTIR/Display.html?Status=resolved&id=$id",
+                    path  => "RTIR/Display.html?Status=removed&id=$id",
                     title => loc('Quick Remove'),
                 };
             }
             if ( $Type eq 'Incident' ) {
                 $actions->{'B'} = {
                     path =>
-                        "RTIR/Incident/Reply.html?id=$id&Action=Comment&All=1&DefaultStatus=rejected&SelectAllTickets=1",
+                        "RTIR/Incident/Reply.html?id=$id&Action=Comment&All=1&DefaultStatus=abandoned&SelectAllTickets=1",
                     title => loc('Abandon'),
                 };
             }
         } else {
             if ( $Type eq 'Block' ) {
                 $actions->{'C'} = {
-                    path  => "RTIR/Update.html?Action=Comment&DefaultStatus=open&id=$id",
+                    path  => "RTIR/Update.html?Action=Comment&DefaultStatus=active&id=$id",
                     title => loc('Activate')
                 };
             } else {
@@ -233,9 +233,9 @@ if ( $Ticket && $Ticket->QueueObj->Name eq $QueueName ) {
                 };
             }
         }
-        if ( $Type eq 'Block' && ($Ticket->FirstCustomFieldValue('State')||'') eq 'active' ) {
+        if ( $Type eq 'Block' && $Ticket->Status eq 'active' ) {
             $actions->{'Ab'} = {
-                path  => "RTIR/Update.html?Action=Respond&DefaultStatus=stalled&id=$id",
+                path  => "RTIR/Update.html?Action=Respond&DefaultStatus=pending removal&id=$id",
                 title => loc('Pending Removal'),
             };
         }
diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index f4d69bd..7aa14c3 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -28,7 +28,7 @@
 %       my $checked = (grep { $_ eq $s } @States)? 'checked': '';
 <input type="checkbox" name="States" value="<% $s %>" <% $checked %> />&nbsp;<% $s %>
 %   }
-<& /Elements/Submit, Name => 'RefineStates', Label => loc('Filter states') &>
+<& /Elements/Submit, Name => 'RefineStatus', Label => loc('Filter states') &>
 % }
 
 % if ($Delete) {
diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index a67ad36..e5d30b0 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -25,7 +25,7 @@
 % while ( my $incident = $incidents->Next ) {
 % $m->out('<ul>') unless $count;
 <li>
-<a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $incident->Id %>"><% $incident->Id %>: <% $incident->Subject %></a> <i>( <& /RTIR/Elements/ShowRTIRField, Ticket => $incident, Name => 'State' &> )</i>
+<a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $incident->Id %>"><% $incident->Id %>: <% $incident->Subject %></a> <i>( <% $incident->Status %> )</i>
 % if ( $show_unlink ) {
 <a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $Ticket->Id %>&DeleteLink--MemberOf-<% $incident->Id %>=1">[<% loc('Unlink') %>]</a>
 % }
@@ -54,7 +54,7 @@
 
 my $count = 0;
 
-my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id . " AND CF.{State} != 'rejected'";
+my $query = "Queue = 'Incidents' AND HasMember = " . $Ticket->Id . " AND Status != 'rejected'";
 my $incidents = new RT::Tickets($session{'CurrentUser'});
 $incidents->FromSQL($query);
 
diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index 71edf36..739f169 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -113,7 +113,7 @@ if ( $ARGS{'BulkAbandon'} ) {
         # process replies
         if( scalar @ReplyToAll ) {
             # XXX: why do we limit to open?
-            my $query = "CF.{State} = 'open' AND MemberOf = $id";
+            my $query = "Status = 'open' AND MemberOf = $id";
             $query .= " AND (". join(' OR ', map "Queue = '$_'", @ReplyToAll) .")";
             my $members = new RT::Tickets( $t->CurrentUser );
             $members->FromSQL( $query );
@@ -140,15 +140,7 @@ if ( $ARGS{'BulkAbandon'} ) {
 
         push @tmp, $t;
         foreach my $t( @tmp ) {
-            my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' );
-
             push @tempresults, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $t );
-
-            my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' );
-            if ( $newstate ne $oldstate ) {
-                push @tempresults,
-                     [ $t->id, loc("State changed from [_1] to [_2]", $oldstate, $newstate ) ];
-            }
         }
     }
 
@@ -176,7 +168,7 @@ my $current_tab = $BaseURL ."&$QueryString";
 
 </%INIT>
 <%ARGS>
-$Status          => 'rejected'
+$Status          => 'abandoned'
 $Queue           => 'Incidents'
 
 $BaseQuery       => $m->comp( '/RTIR/Elements/BaseQuery', Queue => $Queue );
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index 9cbc609..04c2373 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -52,7 +52,6 @@ if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) {
 
 <input type="hidden" name="id"           value="new" />
 <input type="hidden" name="Queue"        value="<% $QueueObj->Name       || '' %>" />
-<input type="hidden" name="Status"       value="<% $ARGS{'Status'}       || 'open' %>" />
 % if ( $ChildObj ) {
 <input type="hidden" name="Child"        value="<% $Child %>" />
 % }
@@ -80,6 +79,17 @@ if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) {
 % }
 
 <tr>
+  <td class="label"><&|/l&>Status</&>:</td>
+  <td colspan="2">
+    <& /Elements/SelectStatus,
+        Name => 'Status',
+        QueueObj => $QueueObj,
+        DefaultValue => 0,
+        Default => 'open',
+    &>
+  </td>
+</tr>
+<tr>
     <td class="label"><&|/l&>Owner</&>:</td>
 % if ( $ChildObj ) {
     <td class="value">
@@ -199,7 +209,7 @@ unless ( exists $ARGS{'Content'} ) {
     %ARGS,
     NamePrefix => 'Investigation',
     Queue => 'Investigations',
-    Status => 'new',
+    Status => 'open',
     SkipField => { Owner => 1, Attachments => 1, DateFields => 1 },
 &>
 <& /Elements/Submit,
diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index bf94ed4..90bb2b8 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -43,6 +43,12 @@
 
 <table>
   <tr>
+    <td class="label"><% loc("Status") %>:</td>
+    <td class="value" colspan="2">
+      <% $TicketObj->Status %>
+    </td>
+  </tr>
+  <tr>
     <td class="label"><&|/l&>Owner</&>:</td>
     <td class="value"><& /Elements/ShowUser, User => $TicketObj->OwnerObj &></td>
   </tr>
@@ -231,7 +237,6 @@ unless( $TicketObj->QueueObj->Name eq 'Incidents' ) {
 $ARGS{'id'} = $id = $TicketObj->Id;
 
 if( 1 ) {
-    my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $TicketObj, 'State' );
 
     if ( $ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/ )
     {   
@@ -273,10 +278,6 @@ if( 1 ) {
         push @results, ProcessUpdateMessage( ARGSRef => \%ARGS, TicketObj => $TicketObj );
     }
 
-    my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $TicketObj, 'State' );
-    if ($newstate ne $oldstate) {
-        push @results, loc("State changed from [_1] to [_2]", $oldstate, $newstate );
-    }
 }
 
 # XXX: need the way to show @results when aborting
diff --git a/html/RTIR/Incident/Edit.html b/html/RTIR/Incident/Edit.html
index 5c9dab8..066fbe7 100644
--- a/html/RTIR/Incident/Edit.html
+++ b/html/RTIR/Incident/Edit.html
@@ -48,8 +48,15 @@
 
 <table>
   <tr>
-    <td class="label"><&|/l&>State</&>:</td>
-    <td class="value"><& /RTIR/Elements/ShowRTIRField, Name => 'State', Ticket => $Ticket &></td>
+    <td class="label"><&|/l&>Status</&>:</td>
+    <td>
+      <& /Elements/SelectStatus,
+          Name => 'Status',
+          QueueObj => $Ticket->QueueObj,
+          DefaultValue => 0,
+          Default => $Ticket->Status,
+      &>
+    </td>
   </tr>
   <tr>
     <td class="label"><&|/l&>Owner</&>:</td>
@@ -141,7 +148,6 @@ if ( $constituency_cf && $constituency_propagation eq 'reject' ) {
 my @results;
 if ( $SaveChanges && !$OnlySearchForPeople ) {
     my $checks_failure = 0;
-    my $oldstate = $Ticket->FirstCustomFieldValue('State');
     push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
     push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS);
 
@@ -163,10 +169,6 @@ if ( $SaveChanges && !$OnlySearchForPeople ) {
     $ARGS{UpdateAttachments} = $session{'Attachments'};
        push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
 
-    my $newstate = $Ticket->FirstCustomFieldValue('State');
-    if ($newstate ne $oldstate) {
-        push (@results, loc("State changed from [_1] to [_2]", $oldstate, $newstate));
-    }
     if ( !$checks_failure && RT->Config->Get('DisplayAfterEdit', $session{'CurrentUser'}) ) {
         $m->callback(CallbackName => 'BeforeDisplay', ARGSRef => \%ARGS, Ticket => $Ticket);
 
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 5f38d13..1f6ad36 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -125,7 +125,7 @@ if ($DefaultStatus eq 'resolved') {
     $title = loc("Resolve Incident #[_1] (including children)", $id);
     $SubmitCaption = loc("Resolve Incident");
     $SubmitLabel = loc("Resolve");
-} elsif ($DefaultStatus eq 'rejected') {
+} elsif ($DefaultStatus eq 'abandoned') {
     $title = loc("Abandon Incident #[_1] (including children)", $id);
     $SubmitCaption = loc("Abandon Incident");
     $SubmitLabel = loc("Abandon");
@@ -143,7 +143,7 @@ my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
 my $ActiveStatesQuery =
-    join ' OR ', map "CF.{State} = '$_'",
+    join ' OR ', map "Status = '$_'",
     RT::IR::States( Queue => \@queues );
 
 $Query ||= "( $ActiveStatesQuery )";
@@ -190,8 +190,6 @@ if ( $SubmitTicket && !$checks_failure ) {
         }
         $id = $Ticket->id;
 
-        my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' );
-
         my @tempresults;
         $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
         push @tempresults, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
@@ -199,20 +197,15 @@ if ( $SubmitTicket && !$checks_failure ) {
         unless ( RT::IR::Ticket::IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
             # XXX: we push into results directly cuz ProcessTicketBasics returns results
             # with leading 'Ticket XX:' string
-            push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
-        }
-
-        my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' );
-
-        if ($newstate ne $oldstate) {
-            push (@tempresults, loc("State changed from [_1] to [_2]", $oldstate, $newstate));
+            push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef
+=> { %ARGS, $ARGS{Status} eq 'abandoned' ? ( Status => 'rejected' ) : () } );
         }
 
         push @results, map { loc("Ticket [_1]: [_2]", $id, $_) } @tempresults;
     }
 
     my $update_incident_state = 1;
-    if ( $DefaultStatus =~ /^(rejected|resolved)$/) {
+    if ( $DefaultStatus =~ /^(abandoned|resolved)$/) {
         # if we are going to resolve/reject incident then do it only when we've
         # rejected all children that are not linked to another active incident(s)
         my $children = RT::Tickets->new( $session{'CurrentUser'} );
@@ -225,16 +218,10 @@ if ( $SubmitTicket && !$checks_failure ) {
     }
 
     if ( $update_incident_state ) {
-        my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $IncidentObj, 'State' );
         push @results, ProcessObjectCustomFieldUpdates( Object => $IncidentObj, ARGSRef => \%ARGS);
         push @results, ProcessTicketBasics( TicketObj => $IncidentObj, ARGSRef => \%ARGS );
-        my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $IncidentObj, 'State' );
-
-        if ($newstate ne $oldstate) {
-            push @results, loc("State changed from [_1] to [_2]", $oldstate, $newstate);
-        }
     } else {
-        push @results, loc("State of the Incident left unchanged; not all children were updated");
+        push @results, loc("Status of the Incident left unchanged; not all children were updated");
     }
 
     my $pass = {};
diff --git a/html/RTIR/Investigation/Elements/Create b/html/RTIR/Investigation/Elements/Create
index 3af49af..1717258 100644
--- a/html/RTIR/Investigation/Elements/Create
+++ b/html/RTIR/Investigation/Elements/Create
@@ -117,7 +117,7 @@ $QueueObj => undef,
 </%ARGS>
 <%INIT>
 my %DEFAULTS = (
-    Status => 'new',
+    Status => 'open',
 );
 my $value_cb = sub {
     my $name = shift;
diff --git a/html/RTIR/Report/BulkReject.html b/html/RTIR/Report/BulkReject.html
index 707a421..e24bee3 100644
--- a/html/RTIR/Report/BulkReject.html
+++ b/html/RTIR/Report/BulkReject.html
@@ -105,15 +105,14 @@ if ( $BulkReject ) {
         }
 
         # warn if this IR has any incidents
-        my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND CF.{State} != 'rejected'";
+        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) {
             push( @tempresults, [ $id, loc("Warning: already has incident") ] );
         }
 
-        my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' ) ||'';
-        
         if ( $t->Owner != $session{'CurrentUser'}->id &&
              $t->Owner == $RT::Nobody->id )
         {
@@ -126,12 +125,6 @@ if ( $BulkReject ) {
         }
 
         push @tempresults, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $t );
-
-        my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' ) ||'';
-        if ( $newstate ne $oldstate ) {
-            push @tempresults,
-                 [ $id, loc("State changed from [_1] to [_2]", $oldstate, $newstate ) ];
-        }
     }
     push @results, map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ }
                    @tempresults;
diff --git a/html/RTIR/Search/Reporting.html b/html/RTIR/Search/Reporting.html
index 9e55c4e..6298faf 100644
--- a/html/RTIR/Search/Reporting.html
+++ b/html/RTIR/Search/Reporting.html
@@ -47,7 +47,7 @@ my $current_tab = "$BaseURL&$QueryString";
 </%INIT>
 
 <%ARGS>
-$PrimaryGroupBy => 'CF.{State}'
+$PrimaryGroupBy => 'Status'
 $ChartStyle     => 'bar'
 $ShowChart      => 0
 
diff --git a/html/RTIR/Update.html b/html/RTIR/Update.html
index 284796f..5d069aa 100644
--- a/html/RTIR/Update.html
+++ b/html/RTIR/Update.html
@@ -64,8 +64,8 @@
 
 <table border="0">
 
-<tr><td align="right"><&|/l&>State</&>:</td>
-<td><& /RTIR/Elements/ShowRTIRField, Ticket => $Ticket, Name => 'State' &></td></tr>
+<tr><td align="right"><&|/l&>Status</&>:</td>
+<td><% $Ticket->Status %></td></tr>
 <tr><td align="right"><&|/l&>Update Type</&>:</td>
 <td><select name="UpdateType">
 % if ($CanComment) {
diff --git a/lib/RT/Action/RTIR_SetBlockState.pm b/lib/RT/Action/RTIR_SetBlockState.pm
index c297edf..2b07b3e 100644
--- a/lib/RT/Action/RTIR_SetBlockState.pm
+++ b/lib/RT/Action/RTIR_SetBlockState.pm
@@ -57,44 +57,11 @@ Returns state of the C<Block>.
 
 sub GetState {
     my $self = shift;
-    my %state = (
-        new      => 'pending activation',
-#        open     => 'active',
-        stalled  => 'pending removal',
-        resolved => 'removed',
-        rejected => 'removed',
-    );
     my $t = $self->TicketObj;
     my $txn = $self->TransactionObj;
-    my $status = $t->Status;
-    my $old_state = $t->FirstCustomFieldValue('State');
+    my $old_status = $t->Status;
 
-    if ( $status eq 'new' && $txn->Type eq 'Correspond' && $txn->IsInbound && $old_state eq 'pending activation' ) {
-        if ( my $re = RT->Config->Get('RTIR_BlockAproveActionRegexp') ) {
-            my $content = $txn->Content;
-            return '' if !$content || $content !~ /$re/;
-        }
-        my ($val, $msg) = $t->SetStatus( 'open' );
-        $RT::Logger->error("Couldn't change status: $msg") unless $val;
-        return 'active';
-    }
-
-    return $state{ $status } if $state{ $status };
-    # all code below is related to open status
-
-    # if block was removed (resolved/rejected) we reactivate it
-    return 'active' if $old_state eq 'removed';
-
-    if ( $txn->Creator != $RT::SystemUser->id ) {
-        # if a duty team member changes Status directly then we want to activate
-        if ( ($txn->Type eq 'Status' || ($txn->Type eq 'Set' && $txn->Field eq 'Status')) &&
-                $self->CreatorCurrentUser->PrincipalObj->HasRight(
-                    Right => 'ModifyTicket', Object => $t
-                )
-        ) {
-            return 'active';
-        }
-    }
+    return 'active' if $old_status eq 'removed';
 
     # next code related to requestor's correspondents
     return '' unless $txn->Type eq 'Correspond';
@@ -105,15 +72,11 @@ sub GetState {
         return '' if !$content || $content !~ /$re/;
     }
 
-    if ( $old_state eq 'pending activation' ) {
+    if ( $old_status eq 'pending activation' ) {
         # switch to active state if it is reply from requestor(s)
         return 'active';
-    } elsif ( $old_state eq 'pending removal' ) {
-        # switch to removed state when requestor(s) replies
-        # but do it via changing status!
-        my ($val, $msg) = $t->SetStatus( 'resolved' );
-        $RT::Logger->error("Couldn't change status: $msg") unless $val;
-        return '';
+    } elsif ( $old_status eq 'pending removal' ) {
+        return 'removed';
     }
 
     return '';
diff --git a/lib/RT/Action/RTIR_SetIncidentState.pm b/lib/RT/Action/RTIR_SetIncidentState.pm
index fc623cc..cc21aa8 100644
--- a/lib/RT/Action/RTIR_SetIncidentState.pm
+++ b/lib/RT/Action/RTIR_SetIncidentState.pm
@@ -57,6 +57,7 @@ Returns state of the C<Incident>.
 
 sub GetState {
     my $self = shift;
+    return '';
     my %state = (
         new      => 'open',
         open     => 'open',
diff --git a/lib/RT/Action/RTIR_SetInvestigationState.pm b/lib/RT/Action/RTIR_SetInvestigationState.pm
index e5a1181..ef84e16 100644
--- a/lib/RT/Action/RTIR_SetInvestigationState.pm
+++ b/lib/RT/Action/RTIR_SetInvestigationState.pm
@@ -59,6 +59,7 @@ Returns state of the C<Investigation>.
 
 sub GetState {
     my $self = shift;
+    return '';
     my %state = (
         new      => 'open',
         open     => 'open',
diff --git a/lib/RT/Action/RTIR_SetState.pm b/lib/RT/Action/RTIR_SetState.pm
index 8802394..8bc3ec4 100644
--- a/lib/RT/Action/RTIR_SetState.pm
+++ b/lib/RT/Action/RTIR_SetState.pm
@@ -23,23 +23,16 @@ sub Commit {
     my $self = shift;
 
     my $t = $self->TicketObj;
-    my $cf = RT::CustomField->new( $self->TransactionObj->CurrentUser );
-    $cf->LoadByNameAndQueue( Queue => $t->QueueObj->Id, Name => 'State' );
-    unless ( $cf->Id ) {
-        $RT::Logger->warning("Couldn't load 'State' CF for queue ". $t->QueueObj->Name );
-        return 1;
-    }
  
-    if ($self->TransactionObj->Type eq 'CustomField' and $self->TransactionObj->Field == $cf->id) {
-	return 1;
+    if ( $self->TransactionObj->Field eq 'Status' ) {
+        return 1;
     }
 
     my $state = $self->GetState;
     return 1 unless $state;
 
-    my ($res, $msg) = $t->AddCustomFieldValue(Field => $cf->id, Value => $state);
-
-    $RT::Logger->warning("Couldn't add custom field value: $msg") unless $res;
+    my ( $res, $msg ) = $t->SetStatus( $state ) unless $t->Status eq $state;
+    $RT::Logger->warning("Couldn't set status to $state: $msg") unless $res;
     return 1;
 }
 
diff --git a/lib/RT/Condition/RTIR_BlockActivation.pm b/lib/RT/Condition/RTIR_BlockActivation.pm
index a3269f0..957cfe6 100644
--- a/lib/RT/Condition/RTIR_BlockActivation.pm
+++ b/lib/RT/Condition/RTIR_BlockActivation.pm
@@ -19,21 +19,7 @@ sub IsApplicable {
     my $txn = $self->TransactionObj;
 
     my $type = $txn->Type;
-    return 1 if $type eq 'Create'
-        && ($self->TicketObj->FirstCustomFieldValue('State')||'') eq 'active';
-
-    if ( $type eq 'CustomField' ) {
-        my $cf = $self->TicketObj->QueueObj->CustomField('State');
-        unless ( $cf->id ) {
-            $RT::Logger->error("Couldn't load the 'State' field");
-            return 0;
-        }
-
-        return 0 unless $cf->id == $txn->Field;
-        return 0 unless ($txn->OldValue||'') eq 'pending activation';
-        return 0 unless ($txn->NewValue||'') eq 'active';
-        return 1;
-    }
+    return 1 if $type eq 'Create' && $self->TicketObj->Status eq 'active';
 
     return 0;
 }
diff --git a/lib/RT/Condition/RTIR_RequireStateChange.pm b/lib/RT/Condition/RTIR_RequireStateChange.pm
index 78b41bb..ab1e46b 100644
--- a/lib/RT/Condition/RTIR_RequireStateChange.pm
+++ b/lib/RT/Condition/RTIR_RequireStateChange.pm
@@ -65,7 +65,7 @@ sub IsApplicable {
     my $self = shift;
 
     my $type = $self->TransactionObj->Type;
-    return 1 if $type eq "Create" or $type eq "CustomField";
+    return 1 if $type eq "Create";# or $type eq "CustomField";
     return 1 if $self->IsStatusChange;
 
     my $field = $self->TransactionObj->Field;
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index eb4c807..8b7776a 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -71,15 +71,6 @@ my %TYPE = (
     'investigations'   => 'Investigation',
     'blocks'           => 'Block',
 );
-my %STATES = (
-    'incidents'        => { Active => ['open'], Inactive => ['resolved', 'abandoned'] },
-    'incident reports' => { Active => ['new', 'open'], Inactive => ['resolved', 'rejected'] },
-    'investigations'   => { Active => ['open'], Inactive => ['resolved'] },
-    'blocks'           => {
-        Active => ['pending activation', 'active', 'pending removal'],
-        Inactive => ['removed'],
-    },
-);
 
 =head1 FUNCTIONS
 
@@ -207,9 +198,17 @@ sub States {
         : ref $arg{'Queue'}? @{ $arg{'Queue'} } : ( $arg{'Queue'} );
     
     my @states;
-    foreach ( @queues ) {
-        push @states, @{ $STATES{ lc $_ }->{'Active'} || [] } if $arg{'Active'};
-        push @states, @{ $STATES{ lc $_ }->{'Inactive'} || [] } if $arg{'Inactive'};
+    foreach my $name (@queues) {
+        my $queue = RT::Queue->new($RT::SystemUser);
+        $queue->Load($name);
+        if ( $queue->id ) {
+            push @states, $queue->lifecycle->active   if $arg{'Active'};
+            push @states, $queue->lifecycle->inactive if $arg{'Inactive'};
+        }
+        else {
+            $RT::Logger->error( "failed to load queue $name" );
+        }
+
     }
 
     my %seen = ();
@@ -397,6 +396,17 @@ require RT::Ticket;
     };
 }
 
+require RT::Action::AutoOpen;
+{
+    no warnings 'redefine';
+    my $prepare = RT::Action::AutoOpen->can('Prepare');
+    *RT::Action::AutoOpen::Prepare = sub {
+        my $self = shift;
+        return 1 if $self->TicketObj->QueueObj->Name eq 'Blocks';
+        $self->$prepare(@_);
+    };
+}
+
 if ( RT::IR->HasConstituency ) {
     # Queue {Comment,Correspond}Address for multiple constituencies
 
diff --git a/lib/RT/IR/Test/Web.pm b/lib/RT/IR/Test/Web.pm
index 1dd8780..839d827 100644
--- a/lib/RT/IR/Test/Web.pm
+++ b/lib/RT/IR/Test/Web.pm
@@ -182,24 +182,24 @@ sub display_ticket {
     $self->get_ok("/RTIR/Display.html?id=$id", "Loaded Display page for Ticket #$id");
 }
 
-sub ticket_state {
+sub ticket_status {
     my $self = shift;
     my $id = shift;
     
     $self->display_ticket( $id);
-    my ($got) = ($self->content =~ qr{State:\s*</td>\s*<td[^>]*?class="value"[^>]*?>\s*([\w ]+?)\s*</td>}ism);
+    my ($got) = ($self->content =~ qr{Status:\s*</td>\s*<td[^>]*?class="value"[^>]*?>\s*([\w ]+?)\s*</td>}ism);
     unless ( $got ) {
-        Test::More::diag("Error: couldn't find state value on the page, may be regexp problem");
+        Test::More::diag("Error: couldn't find status value on the page, may be regexp problem");
     }
     return $got;
 }
 
-sub ticket_state_is {
+sub ticket_status_is {
     my $self = shift;
     my $id = shift;
-    my $state = shift;
-    my $desc = shift || "State of the ticket #$id is '$state'";
-    return Test::More::is($self->ticket_state( $id), $state, $desc);
+    my $status = shift;
+    my $desc = shift || "Status of the ticket #$id is '$status'";
+    return Test::More::is($self->ticket_status( $id), $status, $desc);
 }
 
 sub ticket_is_linked_to_inc {
@@ -297,7 +297,7 @@ sub merge_ticket {
     while($self->content() !~ m|<a href="/Ticket/Display.html\?id=$id_to_merge_to">$id_to_merge_to</a>|) {
         my @ids = sort map s|<b>\s*<a href="/Ticket/Display.html?id=(\d+)">\1</a>\s*</b>|$1|, split /<td/, $self->content();
         my $max = pop @ids;
-        my $url = "Merge.html?id=$id&Order=ASC&Query=( 'CF.{State}' = 'new' OR 'CF.{State}' = 'open' AND 'id' > $max)";
+        my $url = "Merge.html?id=$id&Order=ASC&Query=( 'Status' = 'new' OR 'Status' = 'open' AND 'id' > $max)";
         my $weburl = RT->Config->Get('WebURL');
         Test::More::diag("IDs found: " . join ', ', @ids);
         Test::More::diag("Max ID: " . $max);
@@ -405,7 +405,7 @@ sub resolve_rtir_ticket {
     Test::More::is( $self->status, 200, "Attempting to resolve $type #$id" );
 
     $self->content_like(
-        qr/.*State changed from \w+ to resolved.*/,
+        qr/.*Status changed from \S*\w+\S* to \S*resolved.*/,
         "Successfully resolved $type #$id"
     );
 }
@@ -447,7 +447,7 @@ sub bulk_abandon {
 
     foreach my $id (@to_abandon) {
         $self->ok_and_content_like(
-            qr{<li>Ticket $id: State changed from \w+ to abandoned</li>}i,
+            qr{<li>Ticket $id: Status changed from \S*\w+\S* to \S*abandoned\S*</li>}i,
             "Incident $id abandoned" );
     }
 
diff --git a/t/002-test-reject.t b/t/002-test-reject.t
index 9bb35f4..519d0df 100644
--- a/t/002-test-reject.t
+++ b/t/002-test-reject.t
@@ -39,9 +39,8 @@ for my $id ($nobody_quick, $me_quick) {
     $agent->display_ticket( $id);
     $agent->follow_link_ok({text => "Quick Reject"}, "Followed 'Quick Reject' link");
 
-    like($agent->content, qr/State changed from new to rejected/, "site says ticket got rejected");
+    like($agent->content, qr/Status changed from \S*new\S* to \S*rejected\S*/, "site says ticket got rejected");
 }
-
 for my $id ($nobody_slow, $me_slow) {
     $agent->display_ticket( $id);
 
@@ -53,14 +52,13 @@ for my $id ($nobody_slow, $me_slow) {
 
     is ($agent->status, 200, "attempt to reject succeeded");
 
-    like($agent->content, qr/State changed from new to rejected/, "site says ticket got rejected");
+    like($agent->content, qr/Status changed from \S*new\S* to \S*rejected\S*/, "site says ticket got rejected");
 }
 
 # we need to flush the cache, or else later the status change will not be detected
 use DBIx::SearchBuilder::Record::Cachable;
 DBIx::SearchBuilder::Record::Cachable::FlushCache();
 
-
 for my $id ($nobody_slow, $nobody_quick, $me_quick, $me_slow) {
     my $ir_obj = RT::Ticket->new(RT::SystemUser());
     $ir_obj->Load($id);
@@ -84,7 +82,7 @@ diag "test that after reject links to incidents are still there" if $ENV{'TEST_V
     $agent->field(UpdateContent => "why you are rejected");
     $agent->click("SubmitTicket");
     is $agent->status, 200, "attempt to reject succeeded";
-    $agent->ticket_state_is( $id, 'rejected' );
+    $agent->ticket_status_is( $id, 'rejected' );
 
     {
         my $tickets = RT::Tickets->new( $RT::SystemUser );
@@ -97,7 +95,7 @@ diag "test that after reject links to incidents are still there" if $ENV{'TEST_V
     $agent->follow_link_ok({text => "Incident Reports", n => 2}, "Followed 'Incident Reports' link");
     $agent->form_number(3);
     $agent->tick( States => 'rejected' );
-    $agent->click('RefineStates');
+    $agent->click('RefineStatus');
 
     $agent->has_tag('a', "$id", 'we have link to ticket');
 }
@@ -114,7 +112,7 @@ diag "test that after quick reject links to incidents are still there" if $ENV{'
 
     $agent->display_ticket( $id);
     $agent->follow_link_ok({text => "Quick Reject"}, "Followed 'Reject' link");
-    $agent->ticket_state_is( $id, 'rejected' );
+    $agent->ticket_status_is( $id, 'rejected' );
 
     {
         my $tickets = RT::Tickets->new( $RT::SystemUser );
@@ -127,7 +125,7 @@ diag "test that after quick reject links to incidents are still there" if $ENV{'
     $agent->follow_link_ok({text => "Incident Reports", n => 2}, "Followed 'Incident Reports' link");
     $agent->form_number(3);
     $agent->tick( States => 'rejected' );
-    $agent->click('RefineStates');
+    $agent->click('RefineStatus');
 
     $agent->has_tag('a', "$id", 'we have link to ticket');
 }
@@ -153,7 +151,7 @@ diag "test that after bulk reject links to incidents are still there" if $ENV{'T
     $agent->tick( SelectedTickets => $id );
     $agent->click('BulkReject');
 
-    $agent->ticket_state_is( $id, 'rejected' );
+    $agent->ticket_status_is( $id, 'rejected' );
 
     {
         my $tickets = RT::Tickets->new( $RT::SystemUser );
@@ -166,7 +164,7 @@ diag "test that after bulk reject links to incidents are still there" if $ENV{'T
     $agent->follow_link_ok({text => "Incident Reports", n => 2}, "Followed 'Incident Reports' link");
     $agent->form_number(3);
     $agent->tick( States => 'rejected' );
-    $agent->click('RefineStates');
+    $agent->click('RefineStatus');
 
     $agent->has_tag('a', "$id", 'we have link to ticket');
 }
diff --git a/t/003-resolve-IR-when-all-incidents-resolved.t b/t/003-resolve-IR-when-all-incidents-resolved.t
index 766a540..59e5195 100644
--- a/t/003-resolve-IR-when-all-incidents-resolved.t
+++ b/t/003-resolve-IR-when-all-incidents-resolved.t
@@ -25,13 +25,21 @@ ir_status('open');
 
 $agent->display_ticket( $inc_1);
 $agent->follow_link_ok({text => "Quick Resolve"}, "followed 'Quick Resolve' link for first incident");
-like($agent->content, qr/State changed from open to resolved/, "resolved the first incident");
+like(
+    $agent->content,
+    qr/Status changed from \S*open\S* to \S*resolved\S*/,
+    "resolved the first incident"
+);
 
 ir_status('open');
 
 $agent->display_ticket( $inc_2);
 $agent->follow_link_ok({text => "Quick Resolve"}, "followed 'Quick Resolve' link for second incident");
-like($agent->content, qr/State changed from open to resolved/, "resolved the second incident");
+like(
+    $agent->content,
+    qr/Status changed from \S*open\S* to \S*resolved\S*/,
+    "resolved the second incident"
+);
 
 ir_status('resolved');
 
diff --git a/t/005-resolve-investigations.t b/t/005-resolve-investigations.t
index 77d72e5..7a85725 100644
--- a/t/005-resolve-investigations.t
+++ b/t/005-resolve-investigations.t
@@ -13,7 +13,7 @@ my $inv_id  = $agent->create_investigation( {Subject => "i want to quick-resolve
 $agent->display_ticket( $inv_id);
 
 $agent->follow_link_ok({text => "Quick Resolve"}, "followed 'RTFM' overview link");
-like($agent->content, qr/State changed from open to resolved/, "it got resolved");
+like($agent->content, qr/Status changed from \S*open\S* to \S*resolved\S*/, "it got resolved");
 
 $inv_id = $agent->create_investigation( {Subject => "resolve me slower"});
 
@@ -27,7 +27,7 @@ $agent->click("SubmitTicket");
 
 is ($agent->status, 200, "attempt to resolve inv succeeded");
 
-like($agent->content, qr/State changed from open to resolved/, "site says ticket got resolved");
+like($agent->content, qr/Status changed from \S*open\S* to \S*resolved\S*/, "site says ticket got resolved");
 
 $agent->follow_link_ok({text => "Open"}, "Followed 'open' link");
-like($agent->content, qr/State changed from resolved to open/, "site says ticket got re-opened");
+like($agent->content, qr/Status changed from \S*resolved\S* to \S*open\S*/, "site says ticket got re-opened");
diff --git a/t/008-workflow-blocks.t b/t/008-workflow-blocks.t
index 245fe6e..7012a84 100644
--- a/t/008-workflow-blocks.t
+++ b/t/008-workflow-blocks.t
@@ -11,7 +11,7 @@ my $agent = default_agent();
 my $inc_id   = $agent->create_incident( {Subject => "incident with block"});
 my $block_id = $agent->create_block( {Subject => "block", Incident => $inc_id});
 
-$agent->ticket_state_is( $block_id, 'pending activation');
+$agent->ticket_status_is( $block_id, 'pending activation');
 
 # XXX: Comment this tests as we don't allow to create blocks without an incident
 # XXX: we need test for this fact
@@ -22,26 +22,27 @@ $agent->ticket_state_is( $block_id, 'pending activation');
 #$agent->ok_and_content_like( qr{$block_id.*block.*?pending activation}, 'have child link');
 #
 #$agent->follow_link_ok({ text => $block_id }, "Followed link back to block");
-#$agent->ticket_state_is( $block_id, 'pending activation');
+#$agent->ticket_status_is( $block_id, 'pending activation');
 
 $agent->has_tag('a', 'Remove', 'we have Remove action');
 $agent->has_tag('a', 'Quick Remove', 'we have Quick Remove action');
 
-my %state = (
-    new      => 'pending activation',
-    open     => 'active',
-    stalled  => 'pending removal',
-    resolved => 'removed',
-    rejected => 'removed',
-);
-
-foreach my $status( qw(open stalled resolved) ) {
+#my %state = (
+#    new      => 'pending activation',
+#    open     => 'active',
+#    stalled  => 'pending removal',
+#    resolved => 'removed',
+#    rejected => 'removed',
+#);
+#
+#foreach my $status( qw(open stalled resolved) ) {
+foreach my $status( 'pending activation', 'pending removal', 'removed' ) {
     $agent->follow_link_ok({ text => "Edit" }, "Goto edit page");
     $agent->form_number(3);
     $agent->field(Status => $status);
     $agent->click('SaveChanges');
-    my $state = $state{ $status };
-    $agent->ticket_state_is( $block_id, $state);
+    my $state = $status;
+    $agent->ticket_status_is( $block_id, $state);
 }
 
 diag "remove using edit";
@@ -49,14 +50,14 @@ diag "remove using edit";
     $agent->follow_link_ok({ text => "Edit" }, "Goto edit page");
 
     # Tests to make sure the unwanted option 'Use system default()' does not appear as an
-    # option in the State field (a reported M3 bug)
+    # option in the Status field (a reported M3 bug)
     $agent->content_unlike(qr{<option (?:value=.*)?>Use system default\(\)</option>}, "The option 'Use system default()' does not exist.");
 
     $agent->form_number(3);
 
-    $agent->field(Status => 'resolved');
+    $agent->field(Status => 'removed');
     $agent->click('SaveChanges');
-    $agent->ticket_state_is( $block_id, 'removed');
+    $agent->ticket_status_is( $block_id, 'removed');
 }
 
 diag "reactivate the block using the link";
@@ -67,7 +68,7 @@ diag "reactivate the block using the link";
     $agent->form_number(3);
     $agent->field( UpdateContent => 'activating block' );
     $agent->click('SubmitTicket');
-    $agent->ticket_state_is( $block_id, 'active');
+    $agent->ticket_status_is( $block_id, 'active');
 }
 
 diag "prepare for removing using the link";
@@ -76,20 +77,20 @@ diag "prepare for removing using the link";
     $agent->follow_link_ok({ text => 'Pending Removal' }, "Prepare block for remove");
     $agent->form_number(3);
     $agent->click('SubmitTicket');
-    $agent->ticket_state_is( $block_id, 'pending removal');
+    $agent->ticket_status_is( $block_id, 'pending removal');
 }
 
 diag "test activation after reply using 'Activate' link";
 {
     my $block_id = $agent->create_block( {Subject => "block", Incident => $inc_id});
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     $agent->follow_link_ok({ text => 'Reply' }, "Go to reply page");
     $agent->form_number(3);
     $agent->field( UpdateContent => 'reply' );
     $agent->click('SubmitTicket');
 
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     $agent->follow_link_ok({ text => 'Activate' }, "activate it");
 
@@ -97,30 +98,29 @@ diag "test activation after reply using 'Activate' link";
     $agent->field( UpdateContent => 'activating block' );
     $agent->click('SubmitTicket');
 
-    $agent->ticket_state_is( $block_id, 'active');
+    $agent->ticket_status_is( $block_id, 'active');
 }
 
 diag "test activation after reply using Edit page";
 {
     my $block_id = $agent->create_block( {Subject => "block", Incident => $inc_id});
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     $agent->follow_link_ok({ text => 'Reply' }, "Go to reply page");
     $agent->form_number(3);
     $agent->field( UpdateContent => 'reply' );
     $agent->click('SubmitTicket');
 
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     $agent->follow_link_ok({ text => "Edit" }, "Goto edit page");
     $agent->form_number(3);
-    $agent->field(Status => 'open');
+    $agent->field(Status => 'active');
     $agent->click('SaveChanges');
 
-    $agent->ticket_state_is( $block_id, 'active');
+    $agent->ticket_status_is( $block_id, 'active');
 }
 
-
 my $re = RT->Config->Get('RTIR_BlockAproveActionRegexp');
 
 SKIP: {
@@ -132,7 +132,7 @@ SKIP: {
         Incident => $inc_id,
         Requestors => 'rt-test at example.com',
     } );
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     {
         my $text = <<EOF;
@@ -145,7 +145,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'active');
+        $agent->ticket_status_is( $block_id, 'active');
     }
 
     {
@@ -154,7 +154,7 @@ EOF
         $agent->form_number(3);
         $agent->field( UpdateContent => 'going to remove' );
         $agent->click('SubmitTicket');
-        $agent->ticket_state_is( $block_id, 'pending removal');
+        $agent->ticket_status_is( $block_id, 'pending removal');
     }
 
     {
@@ -168,7 +168,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'removed');
+        $agent->ticket_status_is( $block_id, 'removed');
     }
 }
 
@@ -181,7 +181,7 @@ SKIP: {
         Incident => $inc_id,
         Requestors => 'rt-test at example.com',
     } );
-    $agent->ticket_state_is( $block_id, 'pending activation');
+    $agent->ticket_status_is( $block_id, 'pending activation');
 
     {
         my $text = <<EOF;
@@ -194,7 +194,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'pending activation');
+        $agent->ticket_status_is( $block_id, 'pending activation');
     }
 
     {
@@ -209,7 +209,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'active');
+        $agent->ticket_status_is( $block_id, 'active');
     }
 
     {
@@ -218,7 +218,7 @@ EOF
         $agent->form_number(3);
         $agent->field( UpdateContent => 'going to remove' );
         $agent->click('SubmitTicket');
-        $agent->ticket_state_is( $block_id, 'pending removal');
+        $agent->ticket_status_is( $block_id, 'pending removal');
     }
 
     {
@@ -232,7 +232,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'pending removal');
+        $agent->ticket_status_is( $block_id, 'pending removal');
     }
 
     {
@@ -247,7 +247,7 @@ EOF
         my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Blocks');
         is $status >> 8, 0, "The mail gateway exited ok";
         is $id, $block_id, "replied to the ticket";
-        $agent->ticket_state_is( $block_id, 'removed');
+        $agent->ticket_status_is( $block_id, 'removed');
     }
 }
 
diff --git a/t/010-bulk-reject.t b/t/010-bulk-reject.t
index 5050a27..76c8d50 100644
--- a/t/010-bulk-reject.t
+++ b/t/010-bulk-reject.t
@@ -36,8 +36,8 @@ $agent->get_ok('/RTIR/index.html', 'open rtir at glance');
     $agent->tick('SelectedTickets', $irs[0]);  
     $agent->tick('SelectedTickets', $irs[2]);
     $agent->click('BulkReject');
-    $agent->ok_and_content_like( qr{Ticket $irs[0]: State changed from \w+ to rejected}, 'reject notice');
-    $agent->ok_and_content_like( qr{Ticket $irs[2]: State changed from \w+ to rejected}, 'reject notice');
+    $agent->ok_and_content_like( qr{Ticket $irs[0]: Status changed from \S*\w+\S* to \S*rejected\S*}, 'reject notice');
+    $agent->ok_and_content_like( qr{Ticket $irs[2]: Status changed from \S*\w+\S* to \S*rejected\S*}, 'reject notice');
 
     $agent->form_number(3);
     ok($agent->value('BulkReject'), 'still on reject page');
@@ -54,11 +54,11 @@ $agent->get_ok('/RTIR/index.html', 'open rtir at glance');
     $agent->tick('SelectedTickets', $irs[1]);
     $agent->tick('SelectedTickets', $irs[3]);
     $agent->click('BulkRejectAndReturn');
-    $agent->ok_and_content_like( qr{Ticket $irs[1]: State changed from new to rejected}, 'reject notice');
-    $agent->ok_and_content_like( qr{Ticket $irs[3]: State changed from new to rejected}, 'reject notice');
+    $agent->ok_and_content_like( qr{Ticket $irs[1]: Status changed from \S*new\S* to \S*rejected\S*}, 'reject notice');
+    $agent->ok_and_content_like( qr{Ticket $irs[3]: Status changed from \S*new\S* to \S*rejected\S*}, 'reject notice');
     $agent->ok_and_content_like( qr{New unlinked Incident Reports}, 'we are on the main page');
 }
 
 foreach( @irs ) {
-    $agent->ticket_state_is( $_, 'rejected', "Ticket #$_ is rejected" );
+    $agent->ticket_status_is( $_, 'rejected', "Ticket #$_ is rejected" );
 }
diff --git a/t/011-merge.t b/t/011-merge.t
index ba50b90..90489ce 100644
--- a/t/011-merge.t
+++ b/t/011-merge.t
@@ -36,7 +36,7 @@ diag "merge an IR into a linked IR, the product should have open state"
     my $inc_id = $agent->create_incident( {Subject => "base inc for merging"});
     my $ir1_id = $agent->create_ir( {Subject => "ir1 for merging", Incident => $inc_id});
     $agent->ok_and_content_like( qr{Incident:.*$inc_id}ms, 'Created linked IR');
-    $agent->ticket_state_is( $ir1_id, 'open' );
+    $agent->ticket_status_is( $ir1_id, 'open' );
 
     my $ir2_id = $agent->create_ir( {Subject => "ir2 for merging"});
     $agent->display_ticket( $ir2_id);
@@ -55,7 +55,7 @@ diag "merge an IR into a linked IR, the product should have open state"
     $agent->display_ticket( $ir2_id);
     $agent->ok_and_content_like( qr{Incident Report #$ir1_id:}, 'Second id points to the ticket we merged into');
 
-    $agent->ticket_state_is( $ir2_id, 'open' );
+    $agent->ticket_status_is( $ir2_id, 'open' );
 }
 
 { # as previouse but with reversed merge operation
@@ -64,7 +64,7 @@ diag "merge an IR into a linked IR, the product should have open state"
     my $inc_id = $agent->create_incident( {Subject => "base inc for merging"});
     my $ir2_id = $agent->create_ir( {Subject => "ir2 for merging", Incident => $inc_id});
     $agent->ok_and_content_like( qr{Incident:.*$inc_id}ms, 'Created linked IR');
-    $agent->ticket_state_is( $ir2_id, 'open' );
+    $agent->ticket_status_is( $ir2_id, 'open' );
 
     $agent->display_ticket( $ir2_id);
 
@@ -81,7 +81,7 @@ diag "merge an IR into a linked IR, the product should have open state"
 
     $agent->display_ticket( $ir1_id);
     $agent->ok_and_content_like( qr{Incident Report #$ir1_id:}, 'Opened the merged ticket');
-    $agent->ticket_state_is( $ir1_id, 'open' );
+    $agent->ticket_status_is( $ir1_id, 'open' );
 }
 
 { # merge two IRs that are linked to different Incidents
diff --git a/t/016-date-started.t b/t/016-date-started.t
index 3ada8cd..6344a96 100644
--- a/t/016-date-started.t
+++ b/t/016-date-started.t
@@ -27,7 +27,7 @@ diag "started date of an IR" if $ENV{'TEST_VERBOSE'};
 {
     my $ir_id = $agent->create_ir( {Subject => "started date"});
     $agent->display_ticket( $ir_id);
-    sleep 5;
+    sleep 1;
 
     my $inc_id = $agent->create_incident_for_ir( $ir_id, {Subject => "started date"} );
     my $inc = RT::Ticket->new( $RT::SystemUser );
diff --git a/t/incident/abandon.t b/t/incident/abandon.t
index 7158c9b..ec63f58 100644
--- a/t/incident/abandon.t
+++ b/t/incident/abandon.t
@@ -15,7 +15,7 @@ diag "abandon unlinked incident" if $ENV{'TEST_VERBOSE'};
     $agent->content_like(qr/Warning: no recipients!/mi, 'no recipients warning on the page');
     $agent->form_number(3);
     $agent->click('SubmitTicket');
-    is $agent->ticket_state( $id), 'abandoned', 'abandoned incident';
+    is $agent->ticket_status( $id), 'abandoned', 'abandoned incident';
 }
 
 diag "abandon unlinked incident, but enter a message during abandoning" if $ENV{'TEST_VERBOSE'};
@@ -26,7 +26,7 @@ diag "abandon unlinked incident, but enter a message during abandoning" if $ENV{
     $agent->form_number(3);
     $agent->field( UpdateContent => 'abandoning' );
     $agent->click('SubmitTicket');
-    is $agent->ticket_state( $id), 'abandoned', 'abandoned incident';
+    is $agent->ticket_status( $id), 'abandoned', 'abandoned incident';
 }
 
 diag "simple abandon incident with IR" if $ENV{'TEST_VERBOSE'};
@@ -38,8 +38,8 @@ diag "simple abandon incident with IR" if $ENV{'TEST_VERBOSE'};
     $agent->content_unlike(qr/Warning: no recipients!/mi, 'have no "no recipients" warning on the page');
     $agent->form_number(3);
     $agent->click('SubmitTicket');
-    is $agent->ticket_state( $inc_id), 'abandoned', 'abandoned incident';
-    is $agent->ticket_state( $ir_id), 'rejected', 'rejected ir';
+    is $agent->ticket_status( $inc_id), 'abandoned', 'abandoned incident';
+    is $agent->ticket_status( $ir_id), 'rejected', 'rejected ir';
 }
 
 diag "abandon incident with resolved IR" if $ENV{'TEST_VERBOSE'};
@@ -47,13 +47,13 @@ diag "abandon incident with resolved IR" if $ENV{'TEST_VERBOSE'};
     my $inc_id = $agent->create_incident( { Subject => "test" } );
     my $ir_id = $agent->create_ir( { Subject => "test", Incident => $inc_id } );
     $agent->follow_link( text => 'Quick Resolve' );
-    is $agent->ticket_state( $ir_id), 'resolved', 'resolved ir';
+    is $agent->ticket_status( $ir_id), 'resolved', 'resolved ir';
     $agent->goto_ticket( $inc_id );
     $agent->follow_link( text => 'Abandon' );
     $agent->form_number(3);
     $agent->click('SubmitTicket');
-    is $agent->ticket_state( $inc_id), 'abandoned', 'abandoned incident';
-    is $agent->ticket_state( $ir_id), 'resolved', 'resolved ir';
+    is $agent->ticket_status( $inc_id), 'abandoned', 'abandoned incident';
+    is $agent->ticket_status( $ir_id), 'resolved', 'resolved ir';
 }
 
 
diff --git a/t/incident/bulk-abandon.t b/t/incident/bulk-abandon.t
index 90985ce..f05e93a 100644
--- a/t/incident/bulk-abandon.t
+++ b/t/incident/bulk-abandon.t
@@ -60,14 +60,14 @@ $agent->resolve_rtir_ticket( $invests[0], 'Investigation');
 $agent->bulk_abandon( @incident_ids);
 
 foreach my $id (@incident_ids) {
-	$agent->ticket_state_is( $id, 'abandoned', "Incident $id is abandoned");
+	$agent->ticket_status_is( $id, 'abandoned', "Incident $id is abandoned");
 }
 
 foreach my $id (@ir_ids ) {
-	diag("IR #$id state is " . $agent->ticket_state( $id)) if($ENV{'TEST_VERBOSE'});
+	diag("IR #$id state is " . $agent->ticket_status( $id)) if($ENV{'TEST_VERBOSE'});
 }
 foreach my $id (@invests) {
-	diag("IR #$id state is " . $agent->ticket_state( $id)) if($ENV{'TEST_VERBOSE'});
+	diag("IR #$id state is " . $agent->ticket_status( $id)) if($ENV{'TEST_VERBOSE'});
 }
 
 

commit 72e900feb972f8ed2335aeea9977fe259bcd1b38
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 7 14:16:07 2010 +0800

    EditState componenct is not needed

diff --git a/html/RTIR/Block/Elements/EditState b/html/RTIR/Block/Elements/EditState
deleted file mode 100644
index 5055737..0000000
--- a/html/RTIR/Block/Elements/EditState
+++ /dev/null
@@ -1,21 +0,0 @@
-<& /Widgets/Form/Select,
-    Name        => 'Status',
-    Default     => 0,
-    Values      => [qw(new open stalled resolved)],
-    ValuesLabel => {
-        new      => loc('pending activation'),
-        open     => loc('active'),
-        stalled  => loc('pending removal'),
-        resolved => loc('removed'),
-    },
-    CurrentValue => $Default,
-&>
-<%ARGS>
-$TicketObj => undef
-$Default   => undef
-</%ARGS>
-<%INIT>
-if ( $Default eq 'open' ) {
-    $Default = 'new' unless $TicketObj->FirstCustomFieldValue('State') eq 'active';
-}
-</%INIT>

commit 54d544ade1ef930517608e460aab67ca3b92dafe
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 7 15:06:39 2010 +0800

    need rt 3.9.6

diff --git a/Makefile.PL b/Makefile.PL
index 5a61528..964d74b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,8 +7,8 @@ version_from('lib/RT/IR.pm');
 
 { # check RT version
     my @v = split /\./, "$RT::VERSION";
-    unless ($v[0]>=3 && $v[1]>=8 && ($v[2]>=3 || $v[2]eq'HEAD')) {
-        die "RTIR 2.4.2 and newer needs RT 3.8.3 at least, you have $RT::VERSION";
+    unless ($v[0]>=3 && $v[1]>=9 && ($v[2]>=6 || $v[2]eq'HEAD')) {
+        die "RTIR 2.4.2 and newer needs RT 3.9.6 at least, you have $RT::VERSION";
     }
 }
 
diff --git a/README b/README
index b688d92..3a82cff 100644
--- a/README
+++ b/README
@@ -14,7 +14,7 @@ or RTIR, please contact Best Practical at sales at bestpractical.com.
 REQUIRED PACKAGES:
 ------------------
 
-o   RT 3.8.3 or later, configured, installed and tested.
+o   RT 3.9.6 or later, configured, installed and tested.
 o   RTFM 2.4.1 or later, configured, installed and tested.
 
 
@@ -29,7 +29,7 @@ information.
 Installation instructions:
 --------------------------
 
-1) Install RT 3.8.3 or newer following RT's regular installation instructions
+1) Install RT 3.9.6 or newer following RT's regular installation instructions
 
 2) Install RTFM 2.4.1 or nerwer, following the installation instructions
    in RTFM's README file. (Don't forget to run "make initdb" to set up the 
@@ -51,6 +51,168 @@ Installation instructions:
 7) Activate RTIR extion in the RT config:
 
     Set(@Plugins, 'RT::FM', 'RT::IR');
+    Set(
+        %Lifecycles,
+        default => {
+            default_initial => 'new',
+            initial         => [ 'new', 'open' ],
+            active          => [ 'open', 'stalled' ],
+            inactive        => [ 'resolved', 'rejected', 'deleted' ],
+
+            transitions => {
+
+                # from   => [ to list ],
+                new      => [qw(open stalled resolved rejected deleted)],
+                open     => [qw(new stalled resolved rejected deleted)],
+                stalled  => [qw(new open rejected resolved deleted)],
+                resolved => [qw(new open stalled rejected deleted)],
+                rejected => [qw(new open stalled resolved deleted)],
+                deleted  => [qw(new open stalled rejected resolved)],
+            },
+            rights => {
+                '* -> deleted'  => 'DeleteTicket',
+                '* -> rejected' => 'ModifyTicket',
+                '* -> *'        => 'ModifyTicket',
+            },
+            actions => {
+
+                # 'from -> to'    => [action text, Respond/Comment/hide/''],
+                'new -> open'     => [ 'Open It', 'Respond' ],
+                'new -> resolved' => [ 'Resolve', 'Comment' ],
+                'new -> rejected' => [ 'Reject',  'Respond' ],
+                'new -> deleted'  => [ 'Delete',  '' ],
+
+                'open -> stalled'  => [ 'Stall',   'Comment' ],
+                'open -> resolved' => [ 'Resolve', 'Comment' ],
+                'open -> rejected' => [ 'Reject',  'Respond' ],
+                'open -> deleted'  => [ 'Delete',  'hide' ],
+
+                'stalled -> open'  => [ 'Open It',  '' ],
+                'resolved -> open' => [ 'Re-open',  'Comment' ],
+                'rejected -> open' => [ 'Re-open',  'Comment' ],
+                'deleted -> open'  => [ 'Undelete', '' ],
+                'open -> new'      => [ 'New',      'hide' ],
+            },
+        },
+        incidents => {
+            default_initial => 'open',
+            initial         => ['open'],
+            active          => ['open'],
+            inactive        => [ 'resolved', 'abandoned' ],
+
+            transitions => {
+
+                # from   => [ to list ],
+                open      => [qw(resolved abandoned)],
+                resolved  => [qw(open abandoned)],
+                abandoned => [qw(open resolved)],
+            },
+            rights  => { '* -> *' => 'ModifyTicket', },
+            actions => {
+                'open -> resolved'  => [ 'Resolve', 'Comment' ],
+                'open -> abandoned' => [ 'Abandon', 'Comment' ],
+                'resolved -> open'  => [ 'Re-open', 'Comment' ],
+                'abandoned -> open' => [ 'Re-open', 'Comment' ],
+            },
+        },
+        incident_reports => {
+            default_initial => 'new',
+            initial         => [ 'new', 'open' ],
+            active          => ['open'],
+            inactive        => [ 'resolved', 'rejected' ],
+
+            transitions => {
+
+                # from   => [ to list ],
+                new      => [qw(open resolved rejected)],
+                open     => [qw(new resolved rejected)],
+                resolved => [qw(new open rejected)],
+                rejected => [qw(new open resolved)],
+            },
+            rights  => { '* -> *' => 'ModifyTicket', },
+            actions => {
+                'new -> open'     => [ 'Open It', 'Respond' ],
+                'new -> resolved' => [ 'Resolve', 'Comment' ],
+                'new -> rejected' => [ 'Reject',  'Respond' ],
+
+                'open -> resolved' => [ 'Resolve', 'Comment' ],
+                'open -> rejected' => [ 'Reject',  'Respond' ],
+
+                'resolved -> open' => [ 'Re-open', 'Comment' ],
+                'rejected -> open' => [ 'Re-open', 'Comment' ],
+
+                'open -> new' => [ 'New', 'hide' ],
+            },
+        },
+        investigations => {
+            default_initial => 'open',
+            initial         => ['open'],
+            active          => ['open'],
+            inactive        => ['resolved'],
+
+            transitions => {
+
+                # from   => [ to list ],
+                open     => [qw(resolved)],
+                resolved => [qw(open)],
+            },
+            rights  => { '* -> *' => 'ModifyTicket', },
+            actions => {
+                'open -> resolved' => [ 'Resolve', 'Comment' ],
+                'resolved -> open' => [ 'Re-open', 'Comment' ],
+            },
+        },
+        blocks => {
+            default_initial => 'pending activation',
+            initial         => ['pending activation'],
+            active          => [ 'active', 'pending removal' ],
+            inactive        => ['removed'],
+
+            transitions => {
+                'pending activation' =>
+                  [ 'active', 'pending removal', 'removed' ],
+                active =>
+                  [ 'pending removal', 'removed', 'pending activation' ],
+                'pending removal' =>
+                  [ 'pending activation', 'removed', 'active' ],
+                removed =>
+                  [ 'pending activation', 'active', 'pending removal' ],
+            },
+            rights  => { '* -> *' => 'ModifyTicket', },
+            actions => {
+                'pending activation -> active' => [ 'Activate', 'Comment' ],
+                'pending activation -> pending removal' =>
+                  [ 'Pending to remove', 'Comment' ],
+                'pending activation -> removed' => [ 'Remove', 'Comment' ],
+
+                'active -> pending activation' =>
+                  [ 'Pending to activate', 'Comment' ],
+                'active -> pending removal' =>
+                  [ 'Pending to remove', 'Comment' ],
+                'active -> removed' => [ 'Remove', 'Comment' ],
+
+                'pending removal -> removed' => [ 'Remove',   'Comment' ],
+                'pending removal -> active'  => [ 'Activate', 'Comment' ],
+                'pending removal -> pending activation' =>
+                  [ 'Pending to Activate', 'Comment' ],
+
+                'removed -> active' => [ 'Activate', 'Comment' ],
+                'removed -> pending activation' =>
+                  [ 'Pending to activate', 'Comment' ],
+                'removed -> pending removal' =>
+                  [ 'Pending to remove', 'Comment' ],
+            },
+        },
+    );
+
+    Set(
+        %LifecycleMap,
+        General            => 'default',
+        Incidents          => 'incidents',
+        'Incident Reports' => 'incident_reports',
+        Investigations     => 'investigations',
+        Blocks             => 'blocks',
+    );
 
 8) Stop and start your web server.
 

commit d215e1c7f0b5936da4ad9a35643330a5e425a8c5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 8 10:49:51 2010 +0800

    need default_inactive

diff --git a/README b/README
index 3a82cff..c972092 100644
--- a/README
+++ b/README
@@ -48,7 +48,7 @@ Installation instructions:
    WARNING: Do not attempt to re-initialize the database if you are
    upgrading.
 
-7) Activate RTIR extion in the RT config:
+7) Activate RTIR extension in the RT config:
 
     Set(@Plugins, 'RT::FM', 'RT::IR');
     Set(
@@ -58,6 +58,7 @@ Installation instructions:
             initial         => [ 'new', 'open' ],
             active          => [ 'open', 'stalled' ],
             inactive        => [ 'resolved', 'rejected', 'deleted' ],
+            default_inactive  => 'resolved',
 
             transitions => {
 
@@ -99,6 +100,7 @@ Installation instructions:
             initial         => ['open'],
             active          => ['open'],
             inactive        => [ 'resolved', 'abandoned' ],
+            default_inactive  => 'resolved',
 
             transitions => {
 
@@ -120,6 +122,7 @@ Installation instructions:
             initial         => [ 'new', 'open' ],
             active          => ['open'],
             inactive        => [ 'resolved', 'rejected' ],
+            default_inactive  => 'resolved',
 
             transitions => {
 
@@ -149,6 +152,7 @@ Installation instructions:
             initial         => ['open'],
             active          => ['open'],
             inactive        => ['resolved'],
+            default_inactive  => 'resolved',
 
             transitions => {
 
@@ -167,6 +171,7 @@ Installation instructions:
             initial         => ['pending activation'],
             active          => [ 'active', 'pending removal' ],
             inactive        => ['removed'],
+            default_inactive  => 'removed',
 
             transitions => {
                 'pending activation' =>

commit 84d74119072c554e4bf4c8db04c6b0fa2a0d1f82
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 12 21:14:33 2010 +0800

    incident and investigation states action are not needed

diff --git a/etc/initialdata b/etc/initialdata
index 0b536a7..1eac210 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -241,18 +241,10 @@
        Description => 'Set the state of an Incident Report' ,                                            # loc
        ExecModule => 'RTIR_SetIncidentReportState',
     },
-    {  Name        => 'RTIR Set Investigation State',    # loc
-       Description => 'Set the state of an Investigation' ,                                            # loc
-       ExecModule => 'RTIR_SetInvestigationState',
-    },
     {  Name        => 'RTIR Set Block State',    # loc
        Description => 'Set the state of a Block' ,                                            # loc
        ExecModule => 'RTIR_SetBlockState',
     },
-    {  Name        => 'RTIR Set Incident State',    # loc
-       Description => 'Set the state of an Incident' ,                                            # loc
-       ExecModule => 'RTIR_SetIncidentState',
-    },
     {  Name        => 'RTIR Set Incident Resolution',    # loc
        Description => 'Set the default resolution of an Incident' ,                                            # loc
        ExecModule => 'RTIR_SetIncidentResolution',
@@ -430,16 +422,6 @@
        ScripCondition    => 'RTIR Require State Change',
        ScripAction       => 'RTIR Set Incident Report State',
        Template          => 'Blank', },
-    {  Description       => "SetRTIRState",
-       Queue             => 'Investigations',
-       ScripCondition    => 'RTIR Require State Change',
-       ScripAction       => 'RTIR Set Investigation State',
-       Template          => 'Blank', },
-    {  Description       => "SetRTIRState",
-       Queue             => 'Incidents',
-       ScripCondition    => 'RTIR Require State Change',
-       ScripAction       => 'RTIR Set Incident State',
-       Template          => 'Blank', },
 
 # XXX: description is duplication, but set Due of the incident
     {  Description       => "SetRTIRState",
diff --git a/lib/RT/Action/RTIR_SetIncidentState.pm b/lib/RT/Action/RTIR_SetIncidentState.pm
deleted file mode 100644
index cc21aa8..0000000
--- a/lib/RT/Action/RTIR_SetIncidentState.pm
+++ /dev/null
@@ -1,76 +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
-#
-package RT::Action::RTIR_SetIncidentState;
-
-use strict;
-use base 'RT::Action::RTIR_SetState';
-
-=head2 GetState
-
-Returns state of the C<Incident>.
-
-=cut
-
-sub GetState {
-    my $self = shift;
-    return '';
-    my %state = (
-        new      => 'open',
-        open     => 'open',
-        stalled  => 'open',
-        resolved => 'resolved',
-        rejected => 'abandoned',
-    );
-    return $state{ $self->TicketObj->Status };
-}
-
-eval "require RT::Action::RTIR_SetIncidentState_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentState_Vendor.pm});
-eval "require RT::Action::RTIR_SetIncidentState_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetIncidentState_Local.pm});
-
-1;
diff --git a/lib/RT/Action/RTIR_SetInvestigationState.pm b/lib/RT/Action/RTIR_SetInvestigationState.pm
deleted file mode 100644
index ef84e16..0000000
--- a/lib/RT/Action/RTIR_SetInvestigationState.pm
+++ /dev/null
@@ -1,78 +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
-#
-package RT::Action::RTIR_SetInvestigationState;
-
-use strict;
-use warnings;
-
-use base 'RT::Action::RTIR_SetState';
-
-=head2 GetState
-
-Returns state of the C<Investigation>.
-
-=cut
-
-sub GetState {
-    my $self = shift;
-    return '';
-    my %state = (
-        new      => 'open',
-        open     => 'open',
-        stalled  => 'open',
-        resolved => 'resolved',
-        rejected => 'resolved',
-    );
-    return $state{ $self->TicketObj->Status } || '';
-}
-
-eval "require RT::Action::RTIR_SetInvestigationState_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetInvestigationState_Vendor.pm});
-eval "require RT::Action::RTIR_SetInvestigationState_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetInvestigationState_Local.pm});
-
-1;

commit 3e65a198173437afd27a4227ee4065eb9ed3e479
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 10:39:29 2010 +0800

    clean comment

diff --git a/etc/initialdata b/etc/initialdata
index 1eac210..02da995 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -31,11 +31,6 @@
     },
 );
 
-#use Regexp::Common qw(net);
-#use Regexp::Common::net::CIDR();
-#my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IPv4})?\s*|$RE{net}{CIDR}{IPv4})$};
-
-
 @CustomFields = (
     {
         Name        => 'Constituency',

commit 5bb81c3e9ebb91be048a3d43fafc28a2ce86aa71
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 10:47:16 2010 +0800

    no need /TITLE:Status

diff --git a/html/RTIR/Elements/AttachReports b/html/RTIR/Elements/AttachReports
index 5604efc..a04b5b6 100644
--- a/html/RTIR/Elements/AttachReports
+++ b/html/RTIR/Elements/AttachReports
@@ -38,7 +38,7 @@ return unless $siblings->Count;
 my $Format = q{
     '<b><a HREF="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#',
     '<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></b>/TITLE:Subject',
-    '__Status__/TITLE:Status',
+    '__Status__',
     __LastUpdatedRelative__, __CreatedRelative__
 };
 </%INIT>

commit cccc6311bc623383e2d552281db87f584a8db85c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 10:52:30 2010 +0800

    word update

diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index 7aa14c3..3796a72 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -28,7 +28,7 @@
 %       my $checked = (grep { $_ eq $s } @States)? 'checked': '';
 <input type="checkbox" name="States" value="<% $s %>" <% $checked %> />&nbsp;<% $s %>
 %   }
-<& /Elements/Submit, Name => 'RefineStatus', Label => loc('Filter states') &>
+<& /Elements/Submit, Name => 'RefineStatus', Label => loc('Filter status') &>
 % }
 
 % if ($Delete) {

commit e94fb2d6adf5fd029479ff1cbda3878aa7e3cf71
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 10:55:16 2010 +0800

    loc

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index a44f3b1..e4e63a9 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -45,7 +45,7 @@
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
-<td><%$Ticket->Status%></td>
+<td><% loc( $Ticket->Status ) %></td>
 <td><%$Ticket->Priority%></td>
 % if ($Type eq 'Incident') {
 <td align="right"><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?Child=<%$Ticket->Id%>&id=<%$ticket%>">[<%loc("Link")%>]</a></td>
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index ee168de..c1ba4bc 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -44,7 +44,7 @@
 <tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%></a></b></td>
 <td><b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Subject%></a></b></td>
-<td><%$Ticket->Status%></td>
+<td><% loc($Ticket->Status) %></td>
 </td>
 <td><%$Ticket->Priority%></td>
 <td align="right">
diff --git a/html/RTIR/Update.html b/html/RTIR/Update.html
index 5d069aa..7f0ccd2 100644
--- a/html/RTIR/Update.html
+++ b/html/RTIR/Update.html
@@ -65,7 +65,7 @@
 <table border="0">
 
 <tr><td align="right"><&|/l&>Status</&>:</td>
-<td><% $Ticket->Status %></td></tr>
+<td><% loc($Ticket->Status) %></td></tr>
 <tr><td align="right"><&|/l&>Update Type</&>:</td>
 <td><select name="UpdateType">
 % if ($CanComment) {

commit 51685caf618e3a28f3da8382c8c8e8e5adbdf8ed
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 11:14:13 2010 +0800

    comment clean

diff --git a/lib/RT/Condition/RTIR_RequireStateChange.pm b/lib/RT/Condition/RTIR_RequireStateChange.pm
index ab1e46b..1bba907 100644
--- a/lib/RT/Condition/RTIR_RequireStateChange.pm
+++ b/lib/RT/Condition/RTIR_RequireStateChange.pm
@@ -65,7 +65,7 @@ sub IsApplicable {
     my $self = shift;
 
     my $type = $self->TransactionObj->Type;
-    return 1 if $type eq "Create";# or $type eq "CustomField";
+    return 1 if $type eq "Create";
     return 1 if $self->IsStatusChange;
 
     my $field = $self->TransactionObj->Field;

commit fb442fc2ce99f72d2c8853e9bfdfc0ef602a4e66
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 12:09:12 2010 +0800

    forgot another situation

diff --git a/lib/RT/Condition/RTIR_BlockActivation.pm b/lib/RT/Condition/RTIR_BlockActivation.pm
index 957cfe6..f413d0f 100644
--- a/lib/RT/Condition/RTIR_BlockActivation.pm
+++ b/lib/RT/Condition/RTIR_BlockActivation.pm
@@ -4,11 +4,10 @@ use strict;
 use warnings;
 
 use base 'RT::Condition::RTIR';
-use RT::CustomField;
 
 =head2 IsApplicable
 
-When state of the block changes from C<pending active> to C<active>
+When state of the block changes from C<pending activation> to C<active>
 or ticket created with C<active> state.
 
 =cut
@@ -20,6 +19,17 @@ sub IsApplicable {
 
     my $type = $txn->Type;
     return 1 if $type eq 'Create' && $self->TicketObj->Status eq 'active';
+    if (
+        (
+            $txn->Type eq 'Status'
+            || ( $txn->Type eq 'Set' && $txn->Field eq 'Status' )
+        )
+        && $self->TicketObj->OldStatus eq 'pending activation'
+        && $self->TicketObj->NewStatus eq 'active'
+      )
+    {
+        return 1;
+    }
 
     return 0;
 }

commit 6fb17515a7e8039547020c9d3cfa3e7860ac354c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 12:14:11 2010 +0800

    show status instead of editing

diff --git a/html/RTIR/Incident/Edit.html b/html/RTIR/Incident/Edit.html
index 066fbe7..c84a7ad 100644
--- a/html/RTIR/Incident/Edit.html
+++ b/html/RTIR/Incident/Edit.html
@@ -49,14 +49,7 @@
 <table>
   <tr>
     <td class="label"><&|/l&>Status</&>:</td>
-    <td>
-      <& /Elements/SelectStatus,
-          Name => 'Status',
-          QueueObj => $Ticket->QueueObj,
-          DefaultValue => 0,
-          Default => $Ticket->Status,
-      &>
-    </td>
+    <td><% loc($Ticket->Status) %></td></tr>
   </tr>
   <tr>
     <td class="label"><&|/l&>Owner</&>:</td>

commit 23125355dffd81d08dbb1f08007e25645ab2fd26
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 12:15:15 2010 +0800

    blocks have a complex situation

diff --git a/lib/RT/Action/RTIR_SetBlockState.pm b/lib/RT/Action/RTIR_SetBlockState.pm
index 2b07b3e..5a510cb 100644
--- a/lib/RT/Action/RTIR_SetBlockState.pm
+++ b/lib/RT/Action/RTIR_SetBlockState.pm
@@ -61,8 +61,28 @@ sub GetState {
     my $txn = $self->TransactionObj;
     my $old_status = $t->Status;
 
+    if ( $txn->Type eq 'Correspond' && $txn->IsInbound && $old_status eq 'pending activation' ) {
+        if ( my $re = RT->Config->Get('RTIR_BlockAproveActionRegexp') ) {
+            my $content = $txn->Content;
+            return '' if !$content || $content !~ /$re/;
+        }
+        return 'active';
+    }
+
     return 'active' if $old_status eq 'removed';
 
+    # if block was removed (resolved/rejected) we reactivate it
+    if ( $txn->Creator != $RT::SystemUser->id ) {
+        # if a duty team member changes Status directly then we want to activate
+        if ( ($txn->Type eq 'Status' || ($txn->Type eq 'Set' && $txn->Field eq 'Status')) &&
+                $self->CreatorCurrentUser->PrincipalObj->HasRight(
+                    Right => 'ModifyTicket', Object => $t
+                )
+        ) {
+            return 'active';
+        }
+    }
+
     # next code related to requestor's correspondents
     return '' unless $txn->Type eq 'Correspond';
     return '' unless $t->Requestors->HasMember( $txn->CreatorObj->PrincipalObj );
@@ -76,6 +96,7 @@ sub GetState {
         # switch to active state if it is reply from requestor(s)
         return 'active';
     } elsif ( $old_status eq 'pending removal' ) {
+        # switch to removed state when requestor(s) replies
         return 'removed';
     }
 

commit a4d0e7c4662d9529096390f425c24c78f4e022c2
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 12:15:48 2010 +0800

    move general methods to rt

diff --git a/lib/RT/IR/Test/Web.pm b/lib/RT/IR/Test/Web.pm
index 839d827..c5fff42 100644
--- a/lib/RT/IR/Test/Web.pm
+++ b/lib/RT/IR/Test/Web.pm
@@ -91,20 +91,6 @@ sub create_rtir_ticket
     return $self->get_ticket_id;
 }
 
-sub get_ticket_id {
-    my $self = shift;
-    my $content = $self->content;
-    my $id = 0;
-    if ($content =~ /.*Ticket (\d+) created.*/g) {
-        $id = $1;
-    }
-    elsif ($content =~ /.*No permission to view newly created ticket #(\d+).*/g) {
-        Test::More::diag("\nNo permissions to view the ticket.\n") if($ENV{'TEST_VERBOSE'});
-        $id = $1;
-    }
-    return $id;
-}
-
 sub create_incident_for_ir {
     my $self = shift;
     my $ir_id = shift;
@@ -138,43 +124,6 @@ sub create_incident_for_ir {
     return $incident_id;
 }
 
-sub set_custom_field {
-    my $self   = shift;
-    my $queue   = shift;
-    my $cf_name = shift;
-    my $val     = shift;
-    
-    my $field_name = $self->custom_field_input( $queue, $cf_name )
-        or return 0;
-
-    $self->field($field_name, $val);
-    return 1;
-}
-
-sub custom_field_input {
-    my $self   = shift;
-    my $queue   = shift;
-    my $cf_name = shift;
-
-    my $cf_obj = RT::CustomField->new( $RT::SystemUser );
-    $cf_obj->LoadByName( Queue => $queue, Name => $cf_name );
-    unless ( $cf_obj->id ) {
-        Test::More::diag("Can not load custom field '$cf_name' in queue '$queue'");
-        return undef;
-    }
-    my $cf_id = $cf_obj->id;
-    
-    my ($res) =
-        grep /^Object-RT::Ticket-\d*-CustomField-$cf_id-Values?$/,
-        map $_->name,
-        $self->current_form->inputs;
-    unless ( $res ) {
-        Test::More::diag("Can not find input for custom field '$cf_name' #$cf_id");
-        return undef;
-    }
-    return $res;
-}
-
 sub display_ticket {
     my $self = shift;
     my $id = shift;
@@ -182,26 +131,6 @@ sub display_ticket {
     $self->get_ok("/RTIR/Display.html?id=$id", "Loaded Display page for Ticket #$id");
 }
 
-sub ticket_status {
-    my $self = shift;
-    my $id = shift;
-    
-    $self->display_ticket( $id);
-    my ($got) = ($self->content =~ qr{Status:\s*</td>\s*<td[^>]*?class="value"[^>]*?>\s*([\w ]+?)\s*</td>}ism);
-    unless ( $got ) {
-        Test::More::diag("Error: couldn't find status value on the page, may be regexp problem");
-    }
-    return $got;
-}
-
-sub ticket_status_is {
-    my $self = shift;
-    my $id = shift;
-    my $status = shift;
-    my $desc = shift || "Status of the ticket #$id is '$status'";
-    return Test::More::is($self->ticket_status( $id), $status, $desc);
-}
-
 sub ticket_is_linked_to_inc {
     my $self = shift;
     my $id = shift;

commit a719650fa1af9b1909fb379916d76461ae30e10c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 12:16:08 2010 +0800

    open -> new is not needed

diff --git a/README b/README
index c972092..b0694ee 100644
--- a/README
+++ b/README
@@ -128,7 +128,7 @@ Installation instructions:
 
                 # from   => [ to list ],
                 new      => [qw(open resolved rejected)],
-                open     => [qw(new resolved rejected)],
+                open     => [qw(resolved rejected)],
                 resolved => [qw(new open rejected)],
                 rejected => [qw(new open resolved)],
             },
@@ -143,8 +143,6 @@ Installation instructions:
 
                 'resolved -> open' => [ 'Re-open', 'Comment' ],
                 'rejected -> open' => [ 'Re-open', 'Comment' ],
-
-                'open -> new' => [ 'New', 'hide' ],
             },
         },
         investigations => {
@@ -177,11 +175,11 @@ Installation instructions:
                 'pending activation' =>
                   [ 'active', 'pending removal', 'removed' ],
                 active =>
-                  [ 'pending removal', 'removed', 'pending activation' ],
+                  [ 'pending removal', 'removed' ],
                 'pending removal' =>
-                  [ 'pending activation', 'removed', 'active' ],
+                  [ 'removed', 'active' ],
                 removed =>
-                  [ 'pending activation', 'active', 'pending removal' ],
+                  [ 'active', 'pending removal' ],
             },
             rights  => { '* -> *' => 'ModifyTicket', },
             actions => {
@@ -190,20 +188,14 @@ Installation instructions:
                   [ 'Pending to remove', 'Comment' ],
                 'pending activation -> removed' => [ 'Remove', 'Comment' ],
 
-                'active -> pending activation' =>
-                  [ 'Pending to activate', 'Comment' ],
                 'active -> pending removal' =>
                   [ 'Pending to remove', 'Comment' ],
                 'active -> removed' => [ 'Remove', 'Comment' ],
 
                 'pending removal -> removed' => [ 'Remove',   'Comment' ],
                 'pending removal -> active'  => [ 'Activate', 'Comment' ],
-                'pending removal -> pending activation' =>
-                  [ 'Pending to Activate', 'Comment' ],
 
                 'removed -> active' => [ 'Activate', 'Comment' ],
-                'removed -> pending activation' =>
-                  [ 'Pending to activate', 'Comment' ],
                 'removed -> pending removal' =>
                   [ 'Pending to remove', 'Comment' ],
             },

commit 74beebf75742691aed9364ad7e1adeb77bde7d4c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 14 13:10:43 2010 +0800

    no need to hack SetStatus any more as we have improved lifecycle

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 8b7776a..97c9528 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -371,30 +371,6 @@ if ( RT::IR->HasConstituency ) {
 }
 
 require RT::Ticket;
-{
-    no warnings 'redefine';
-    my $set_status = RT::Ticket->can('SetStatus');
-    *RT::Ticket::SetStatus = sub {
-        my $self = shift;
-        my %args;
-        if ( @_ == 1 ) {
-
-            # it's called like $ticket->SetStatus('new')
-            $args{Status} = $_[0];
-        }
-        else {
-            %args = @_;
-        }
-
-        my $old  = $self->__Value('Status');
-        # if old status is open, we don't want to SetStarted
-        if ( $old eq 'open' ) {
-            $args{SetStarted} = 0;
-        }
-
-        $self->$set_status(%args);
-    };
-}
 
 require RT::Action::AutoOpen;
 {

commit 453382ff7ad1d48999ab0cc121bcb78d01f1914c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 15 01:21:40 2010 +0400

    fix RTIR_BlockActivation condition

diff --git a/lib/RT/Condition/RTIR_BlockActivation.pm b/lib/RT/Condition/RTIR_BlockActivation.pm
index f413d0f..118414f 100644
--- a/lib/RT/Condition/RTIR_BlockActivation.pm
+++ b/lib/RT/Condition/RTIR_BlockActivation.pm
@@ -16,20 +16,11 @@ sub IsApplicable {
     my $self = shift;
 
     my $txn = $self->TransactionObj;
-
-    my $type = $txn->Type;
-    return 1 if $type eq 'Create' && $self->TicketObj->Status eq 'active';
-    if (
-        (
-            $txn->Type eq 'Status'
-            || ( $txn->Type eq 'Set' && $txn->Field eq 'Status' )
-        )
-        && $self->TicketObj->OldStatus eq 'pending activation'
-        && $self->TicketObj->NewStatus eq 'active'
-      )
-    {
-        return 1;
-    }
+    return 1 if $txn->Type eq 'Create' && $self->TicketObj->Status eq 'active';
+    return 1 if
+        $self->IsStatusChange
+        && $txn->OldValue eq 'pending activation'
+        && $txn->NewValue eq 'active';
 
     return 0;
 }

commit 77e2cbdb456a5b3dd5ba5c2c4406a0c2a0976104
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Oct 18 19:37:16 2010 +0800

    upgrade script for 3.9

diff --git a/etc/upgrade/2.7.0/content b/etc/upgrade/2.7.0/content
new file mode 100644
index 0000000..8cd7041
--- /dev/null
+++ b/etc/upgrade/2.7.0/content
@@ -0,0 +1,106 @@
+
+ at Initial = (
+
+    # IP type change
+    sub {
+        my $ip_cf = RT::CustomField->new($RT::SystemUser);
+        $ip_cf->Load('IP');
+        if ( $ip_cf->id ) {
+            $ip_cf->SetType('IPAddressRange');
+            $ip_cf->SetMaxValue(0);
+            $ip_cf->SetPattern('');
+        }
+    },
+
+    #
+    # CF.State => Status
+    sub {
+        my %state;
+        for my $queue ( 'Incidents', 'Incident Reports', 'Investigations',
+            'Blocks' )
+        {
+            my $state = RT::CustomField->new($RT::SystemUser);
+            $state->LoadByName( Name => 'State', Queue => $queue );
+            $state{$queue} = $state if $state->id;
+        }
+
+        my $Tickets = RT::Tickets->new($RT::SystemUser);
+        $Tickets->UnLimit;
+        while ( my $ticket = $Tickets->Next ) {
+            next
+              unless $ticket->QueueObj->Name =~
+                  /^(Incidents|Incident Reports|Investigations|Blocks)$/;
+            my $txns = $ticket->Transactions;
+            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'
+                    && $txn->Field == $state{ $ticket->QueueObj->Name }->id )
+                {
+                    $txn->__Set( Field => 'Type', Value => 'Set' );
+                    $txn->__Set( Field => 'Field', Value => 'Status' );
+                    $txn->__Set( Field => 'ReferenceType', Value => '' );
+
+                    if ( $txn->OldReference ) {
+                        $ocfv =
+                          RT::ObjectCustomFieldValue->new($RT::SystemUser);
+                        $ocfv->Load( $txn->OldReference );
+                        $txn->__Set(
+                            Field => 'OldValue',
+                            Value => $ocfv->Content
+                        );
+                        $txn->__Set( Field => 'OldReference', Value => '' );
+                        $ocfv->Delete;
+                    }
+
+                    if ( $txn->NewReference ) {
+                        $ocfv =
+                          RT::ObjectCustomFieldValue->new($RT::SystemUser);
+                        $ocfv->Load( $txn->NewReference );
+                        $txn->__Set(
+                            Field => 'NewValue',
+                            Value => $ocfv->Content
+                        );
+                        $txn->__Set( Field => 'NewReference', Value => '' );
+                        $ocfv->Delete;
+                    }
+                }
+            }
+        }
+
+        for my $queue ( keys %state ) {
+            $state{$queue}->SetDisabled(1);
+        }
+    },
+
+    # remove state scrips: 2 actions and 2 scrips
+    sub {
+        for my $name (qw/Incident Investigation/) {
+            my $queue = RT::Queue->new($RT::SystemUser);
+            $queue->Load( $name . 's' );
+            next unless $queue->id;
+
+            my $action = RT::ScripAction->new($RT::SystemUser);
+            $action->Load("RTIR Set $name State");
+            next unless $action->id;
+
+            my $scrip = RT::Scrip->new($RT::SystemUser);
+            $scrip->LoadByCols(
+                Description => 'SetRTIRState',
+                Queue       => $queue->id,
+                ScripAction => $action->id,
+            );
+
+            if ( $scrip->id ) {
+                $scrip->Delete;
+            }
+
+            # hmm, RT::ScripAction currently doesn't allow Delete
+            # so the following code doesn't actually work.
+            $action->Delete();
+        }
+    },
+);

commit 8bea22223848861aa0e08c2c268ab23083efa964
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 23 13:29:09 2010 +0800

    make rtir version 2.9 to work with rt-3.9

diff --git a/etc/upgrade/2.7.0/content b/etc/upgrade/2.9.0/content
similarity index 100%
rename from etc/upgrade/2.7.0/content
rename to etc/upgrade/2.9.0/content

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


More information about the Rt-commit mailing list