[Rt-commit] r4239 - in rtir/branches/1.9-EXPERIMENTAL: .
lib/RT/Action
ruz at bestpractical.com
ruz at bestpractical.com
Sun Dec 4 19:07:51 EST 2005
Author: ruz
Date: Sun Dec 4 19:07:51 2005
New Revision: 4239
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm
Log:
r418 at cubic-pc: cubic | 2005-12-05 03:09:08 +0300
r397 at cubic-pc: cubic | 2005-12-04 13:25:44 +0300
* hash instead of if-elsif chain
Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm Sun Dec 4 19:07:51 2005
@@ -48,21 +48,12 @@
use strict;
use base 'RT::Action::RTIR';
-
-
-
-
-use strict;
-
-use base 'RT::Action::RTIR';
-
=head2 Prepare
Always run this.
=cut
-
sub Prepare {
my $self = shift;
@@ -77,28 +68,24 @@
=cut
+my %state = (
+ new => 'pending activation',
+ open => 'active',
+ stalled => 'pending removal',
+ resolved => 'removed',
+);
+
sub Commit {
my $self = shift;
- 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') {
- $State = 'pending activation';
- } elsif ($self->TicketObj->Status eq 'open') {
- $State = 'active';
- } elsif ($self->TicketObj->Status eq 'stalled') {
- $State = 'pending removal';
- } elsif ($self->TicketObj->Status eq 'resolved') {
- $State = 'removed';
- } else {
- return 0;
- }
- $self->TicketObj->AddCustomFieldValue(Field => $cf->id, Value => $State);
+ my $cf = new RT::CustomField( $self->TransactionObj->CurrentUser );
+ $cf->LoadByNameAndQueue( Queue => $self->TicketObj->QueueObj->Id, Name => '_RTIR_State' );
+ return 1 unless $cf->Id;
+
+ my $state = $state{ $self->TicketObj->Status };
+ return 1 unless $state;
+
+ $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => $state );
return 1;
}
More information about the Rt-commit
mailing list