[Rt-commit] r4244 - in rtir/branches/1.9-EXPERIMENTAL: . lib/RT/Action

ruz at bestpractical.com ruz at bestpractical.com
Sun Dec 4 19:09:09 EST 2005


Author: ruz
Date: Sun Dec  4 19:09:09 2005
New Revision: 4244

Modified:
   rtir/branches/1.9-EXPERIMENTAL/   (props changed)
   rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetIncidentState.pm
Log:
 r423 at cubic-pc:  cubic | 2005-12-05 03:09:09 +0300
  r402 at cubic-pc:  cubic | 2005-12-05 02:08:39 +0300
  * move if-elsif chain into hash
  * add logging on error
 


Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetIncidentState.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetIncidentState.pm	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetIncidentState.pm	Sun Dec  4 19:09:09 2005
@@ -46,9 +46,7 @@
 #
 package RT::Action::RTIR_SetIncidentState;
 
-
 use strict;
-
 use base 'RT::Action::RTIR';
 
 =head2 Prepare
@@ -57,7 +55,6 @@
 
 =cut
 
-
 sub Prepare {
     my $self = shift;
 
@@ -72,27 +69,27 @@
 
 =cut
 
+my %state = (
+    new      => 'open',
+    open     => 'open',
+    stalled  => 'open',
+    resolved => 'resolved',
+    rejected => 'abandoned',
+);
+
 sub Commit {
     my $self = shift;
+    my $t = $self->TicketObj;
 
-    my $State;
     my $cf = RT::CustomField->new($self->TransactionObj->CurrentUser);
-    $cf->LoadByNameAndQueue(Queue => $self->TicketObj->QueueObj->Id, Name => '_RTIR_State');
-    unless ($cf->Id) { 
-        return(1);
-    }
-    if ($self->TicketObj->Status eq 'new' ||
-	$self->TicketObj->Status eq 'open' ||
-	$self->TicketObj->Status eq 'stalled') {
-	$State = 'open';
-    } elsif ($self->TicketObj->Status eq 'resolved') {
-	$State = 'resolved';
-    } elsif ($self->TicketObj->Status eq 'rejected') {
-	$State = 'abandoned';
-    } else {
-	return 0;
-    }
-    $self->TicketObj->AddCustomFieldValue(Field => $cf->id, Value => $State);
+    $cf->LoadByNameAndQueue(Queue => $t->QueueObj->Id, Name => '_RTIR_State');
+    return 1 unless $cf->Id;
+
+    my $state = $state{ $t->Status };
+    return 1 unless $state;
+
+    my ($res, $msg) = $t->AddCustomFieldValue(Field => $cf->id, Value => $State);
+    $RT::Logger->info("Couldn't add custom field value: $msg") unless $res;
     return 1;
 }
 


More information about the Rt-commit mailing list