RT::Action::BeforeDue

hi there,

I’ve created a module named RT::Action::BeforeDue. It could spot
those tickets are within specified period of time given by arguments.
The arguments has the format of ‘1d2h3m4s’, meaning tictks will be
spotted if its due time is in 1 day, 2 hours, 3 minutes and 4 seconds.
(Hope you can understand what I mean by my poor english expressions.)

Hope it can be helpful.

plasma

RT::Action::BeforeDue
package RT::Condition::BeforeDue;
require RT::Condition::Generic;

use RT::Date;

@ISA = qw(RT::Condition::Generic);

sub IsApplicable {
my $self = shift;

# Parse date string.  Format is "1d2h3m4s" for 1 day and 2 hours
# and 3 minutes and 4 seconds.
my %e;
foreach (qw(d h m s)) {
my @vals = $self->Argument =~ m/(\d+)$_/;
$e{$_} = pop @vals || 0;
}
my $elapse = $e{'d'} * 24*60*60 + $e{'h'} * 60*60 + $e{'m'} * 60 + $e{'s'};

my $cur = new RT::Date( $RT::SystemUser );
$cur->SetToNow();
my $due = $self->TicketObj->DueObj;
return (undef) if $due->Unix <= 0;

my $diff = $due->Diff($cur);
if ( $diff > = and $diff <= $elapse ) {
    return(1);
} else {
    return(undef);
}

}

1;
</RT::Action::BeforeDue>

PC home �q�l�H�c�A�ӽнЦ�: http://www.pchome.com.tw
PC home Online �����a�x�G�|���Ĥ@�A�x�W�̤j���J�f����