X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCondition%2FBeforeDue.pm;h=d72b2c3516d2ea86f13765a3016b532447b49a70;hb=de9d037528895f7151a9aead6724ce2df95f9586;hp=cb19ccb5c98401005e6d1ebf1942cc143ed760b1;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git

diff --git a/rt/lib/RT/Condition/BeforeDue.pm b/rt/lib/RT/Condition/BeforeDue.pm
index cb19ccb5c..d72b2c351 100644
--- a/rt/lib/RT/Condition/BeforeDue.pm
+++ b/rt/lib/RT/Condition/BeforeDue.pm
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -46,12 +46,30 @@
 #
 # END BPS TAGGED BLOCK }}}
 
+=head1 NAME
+
+RT::Condition::BeforeDue
+
+=head1 DESCRIPTION
+
+Returns true if the ticket we're operating on is within the
+amount of time defined by the passed in argument.
+
+The passed in value is a date in the format "1d2h3m4s"
+for 1 day and 2 hours and 3 minutes and 4 seconds. Single
+units can also be passed such as 1d for just one day.
+
+
+=cut
+
+
 package RT::Condition::BeforeDue;
 use base 'RT::Condition';
 
 use RT::Date;
 
 use strict;
+use warnings;
 
 sub IsApplicable {
     my $self = shift;
@@ -60,15 +78,15 @@ sub IsApplicable {
     # 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 @vals = $self->Argument =~ m/(\d+)$_/i;
+        $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 );
+    my $cur = RT::Date->new( RT->SystemUser );
     $cur->SetToNow();
     my $due = $self->TicketObj->DueObj;
-    return (undef) if $due->Unix <= 0;
+    return (undef) unless $due->IsSet;
 
     my $diff = $due->Diff($cur);
     if ( $diff >= 0 and $diff <= $elapse ) {
@@ -78,9 +96,6 @@ sub IsApplicable {
     }
 }
 
-eval "require RT::Condition::BeforeDue_Vendor";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/BeforeDue_Vendor.pm});
-eval "require RT::Condition::BeforeDue_Local";
-die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/BeforeDue_Local.pm});
+RT::Base->_ImportOverlays();
 
 1;