[Rt-commit] r16095 - in rt/branches/3.999-DANGEROUS: lib/RT/Action

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Sep 26 07:42:39 EDT 2008


Author: sunnavy
Date: Fri Sep 26 07:42:39 2008
New Revision: 16095

Added:
   rt/branches/3.999-DANGEROUS/lib/RT/Action/TicketUpdateDates.pm
Modified:
   rt/branches/3.999-DANGEROUS/   (props changed)

Log:
 r16828 at sunnavys-mb:  sunnavy | 2008-09-26 18:19:25 +0800
 have to add TicketUpdateDates because UpdateTicket can't treat dates right: the criminal is the timezone. the db stores time as UTC, when retrieving from db, it do the timezone convert thing(which is right), but seems it doesn't do the reverse thing when updating dates to db


Added: rt/branches/3.999-DANGEROUS/lib/RT/Action/TicketUpdateDates.pm
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Action/TicketUpdateDates.pm	Fri Sep 26 07:42:39 2008
@@ -0,0 +1,50 @@
+package RT::Action::TicketUpdateDates;
+use strict;
+use warnings;
+
+use base qw/Jifty::Action::Record::Update/;
+
+sub record_class { 'RT::Model::Ticket' }
+
+=head2 take_action
+
+=cut
+
+sub take_action {
+    my $self        = shift;
+    my @date_fields = qw/told starts started due/;
+
+    foreach my $field (@date_fields) {
+        my $value = $self->argument_value($field);
+        if ( defined $value ) {
+            my $date = RT::Date->new();
+            $date->set(
+                format => 'unknown',
+                value  => $value,
+            );
+
+            my $obj = $field . '_obj';
+            if ( $date->unix != $self->record->$obj()->unix() ) {
+                my $set = "set_$field";
+                my ( $status, $msg ) = $self->record->$set( $date->iso );
+                unless ($status) {
+                    $self->result->failure(
+                        _( 'Update [_1] failed: [_2]', $field, $msg ) );
+                    last;
+                }
+            }
+        }
+    }
+
+    $self->report_success unless $self->result->failure;
+    return 1;
+}
+
+sub report_success {
+    my $self = shift;
+
+    # Your success message here
+    $self->result->message( _('Dates Updated') );
+}
+
+1;


More information about the Rt-commit mailing list