[Rt-devel] Backdating transactions

Chris Adams chris at improbable.org
Thu Feb 12 22:02:26 EST 2009


On Feb 12, 2009, at 3:19 PM, Todd Chapman wrote:
> It's no bug that RT doesn't let you change the past. I would hit the  
> DB directly.


Bug was definitely too strong - I guess I was just thinking that it  
seems like this ended up being surprisingly invasive. Here's what the  
final code ended up looking like - one curiosity which this exposed is  
that on my 3.8.2 install simply displaying Update.html will create a  
transaction.

Chris

Interface/Web_Local.pm

ProcessUpdateMessage: copied & added to the %message_args  
initialization:
    if ($args{ARGSRef}->{'Created'}) {
      $message_args{'Created'} = $args{ARGSRef}->{'Created'};
    }

RT/Ticket_Local.pm:

_RecordNote: copied and added after _NewTransaction call:

    if ( $args{'Created'} ) {
      RT::Logger->warning("Updating transaction #" . $TransObj->id .  
": setting created date to " . $args{'Created'} );
      $TransObj->_Handle->UpdateRecordValue( Table => 'Transactions',  
Column => 'Created', Value => $args{'Created'}, PrimaryKeys => { id =>  
$TransObj->id } );
    }

Ticket/Update.html - forked to add the date select since there's not a  
callback for it and running the field through RT::Date:
<table width="100%" border="0">
+<tr><td class="label"><&|/l&>Date</&>:</td><td><& /Elements/ 
SelectDate, Name => "Created", Default => undef &></td></tr>

...

$m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, results =>  
\@results, CallbackName => 'Initial' );

+if ( $ARGS{'Created'} ) {
+       my $created_date = RT::Date->new( $TicketObj->CurrentUser );
+       $created_date->Set( Format => 'Unknown', Value =>  
$ARGS{'Created'}, Timezone => "user" );
+       $ARGS{'Created'} = $created_date->ISO;
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2423 bytes
Desc: not available
Url : http://lists.bestpractical.com/pipermail/rt-devel/attachments/20090212/038d938d/attachment-0001.bin 


More information about the Rt-devel mailing list