[Bps-public-commit] r9488 - RT-Extension-SLA/lib/RT/Action
ruz at bestpractical.com
ruz at bestpractical.com
Fri Oct 26 23:27:12 EDT 2007
Author: ruz
Date: Fri Oct 26 23:27:12 2007
New Revision: 9488
Modified:
RT-Extension-SLA/lib/RT/Action/SLA.pm
RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm
Log:
* abstract setting up date field
Modified: RT-Extension-SLA/lib/RT/Action/SLA.pm
==============================================================================
--- RT-Extension-SLA/lib/RT/Action/SLA.pm (original)
+++ RT-Extension-SLA/lib/RT/Action/SLA.pm Fri Oct 26 23:27:12 2007
@@ -6,4 +6,30 @@
use base qw(RT::Extension::SLA RT::Action::Generic);
+sub SetDateField {
+ my $self = shift;
+ my ($type, $value) = (@_);
+
+ my $ticket = $self->TicketObj;
+
+ my $method = $type .'Obj';
+ if ( defined $value ) {
+ return 1 if $ticket->$method->Unix == $value;
+ } else {
+ return 1 if $ticket->$method->Unix <= 0;
+ }
+
+ my $date = RT::Date->new( $RT::SystemUser );
+ $date->Set( Format => 'unix', Value => $value );
+
+ my $method = 'Set'. $type;
+ my ($status, $msg) = $ticket->$method( $date->ISO );
+ unless ( $status ) {
+ $RT::Logger->error("Couldn't set $type date: $msg");
+ return 0;
+ }
+
+ return 1;
+}
+
1;
Modified: RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm
==============================================================================
--- RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm (original)
+++ RT-Extension-SLA/lib/RT/Action/SLA_SetDue.pm Fri Oct 26 23:27:12 2007
@@ -65,21 +65,7 @@
$due = $resolve_due unless defined $due;
$due = $resolve_due if defined $due && defined $resolve_due && $resolve_due < $due;
- if ( defined $due ) {
- return 1 if $ticket->DueObj->Unix == $due;
- } else {
- return 1 if $ticket->DueObj->Unix <= 0;
- }
-
- my $date = RT::Date->new( $RT::SystemUser );
- $date->Set( Format => 'unix', Value => $due );
- my ($status, $msg) = $self->TicketObj->SetDue( $date->ISO );
- unless ( $status ) {
- $RT::Logger->error("Couldn't set due date: $msg");
- return 0;
- }
-
- return 1;
+ return $self->SetDateField( Due => $due );
}
sub IsRequestorsAct {
More information about the Bps-public-commit
mailing list