diff options
Diffstat (limited to 'rt/lib/RT/Condition')
-rw-r--r-- | rt/lib/RT/Condition/BeforeDue.pm | 23 | ||||
-rw-r--r-- | rt/lib/RT/Condition/Overdue.pm | 10 | ||||
-rw-r--r-- | rt/lib/RT/Condition/OwnerChange.pm | 16 | ||||
-rw-r--r-- | rt/lib/RT/Condition/PriorityChange.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Condition/PriorityExceeds.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Condition/QueueChange.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Condition/StatusChange.pm | 4 |
7 files changed, 46 insertions, 25 deletions
diff --git a/rt/lib/RT/Condition/BeforeDue.pm b/rt/lib/RT/Condition/BeforeDue.pm index 9ff641bc0..6e1b60272 100644 --- a/rt/lib/RT/Condition/BeforeDue.pm +++ b/rt/lib/RT/Condition/BeforeDue.pm @@ -46,6 +46,23 @@ # # 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'; @@ -61,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 = 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 ) { diff --git a/rt/lib/RT/Condition/Overdue.pm b/rt/lib/RT/Condition/Overdue.pm index 240d7febb..f9c0c498a 100644 --- a/rt/lib/RT/Condition/Overdue.pm +++ b/rt/lib/RT/Condition/Overdue.pm @@ -70,12 +70,12 @@ If the due date is before "now" return true sub IsApplicable { my $self = shift; - if ($self->TicketObj->DueObj->Unix > 0 and - $self->TicketObj->DueObj->Unix < time()) { - return(1); - } + if ($self->TicketObj->DueObj->IsSet and + $self->TicketObj->DueObj->Unix < time()) { + return(1); + } else { - return(undef); + return(undef); } } diff --git a/rt/lib/RT/Condition/OwnerChange.pm b/rt/lib/RT/Condition/OwnerChange.pm index 867e632a8..73689710c 100644 --- a/rt/lib/RT/Condition/OwnerChange.pm +++ b/rt/lib/RT/Condition/OwnerChange.pm @@ -62,12 +62,16 @@ If we're changing the owner return true, otherwise return false sub IsApplicable { my $self = shift; - if ( ( $self->TransactionObj->Field || '' ) eq 'Owner' ) { - return(1); - } - else { - return(undef); - } + return unless ( $self->TransactionObj->Field || '' ) eq 'Owner'; + + # For tickets, there is both a Set txn (for the column) and a + # SetWatcher txn (for the group); we fire on the former for + # historical consistency. Non-ticket objects will not have a + # denormalized Owner column, and thus need fire on the SetWatcher. + return if $self->TransactionObj->Type eq "SetWatcher" + and $self->TransactionObj->ObjectType eq "RT::Ticket"; + + return(1); } RT::Base->_ImportOverlays(); diff --git a/rt/lib/RT/Condition/PriorityChange.pm b/rt/lib/RT/Condition/PriorityChange.pm index 06b5b06f7..8992e7bd3 100644 --- a/rt/lib/RT/Condition/PriorityChange.pm +++ b/rt/lib/RT/Condition/PriorityChange.pm @@ -62,10 +62,10 @@ the Priority Obj sub IsApplicable { my $self = shift; if ($self->TransactionObj->Field eq 'Priority') { - return(1); - } + return(1); + } else { - return(undef); + return(undef); } } diff --git a/rt/lib/RT/Condition/PriorityExceeds.pm b/rt/lib/RT/Condition/PriorityExceeds.pm index 16f250ef1..808595bf5 100644 --- a/rt/lib/RT/Condition/PriorityExceeds.pm +++ b/rt/lib/RT/Condition/PriorityExceeds.pm @@ -60,10 +60,10 @@ If the priority exceeds the argument value sub IsApplicable { my $self = shift; if ($self->TicketObj->Priority > $self->Argument) { - return(1); - } + return(1); + } else { - return(undef); + return(undef); } } diff --git a/rt/lib/RT/Condition/QueueChange.pm b/rt/lib/RT/Condition/QueueChange.pm index 0de9d719c..d4be9650b 100644 --- a/rt/lib/RT/Condition/QueueChange.pm +++ b/rt/lib/RT/Condition/QueueChange.pm @@ -60,10 +60,10 @@ If the queue has changed. sub IsApplicable { my $self = shift; if ($self->TransactionObj->Field eq 'Queue') { - return(1); - } + return(1); + } else { - return(undef); + return(undef); } } diff --git a/rt/lib/RT/Condition/StatusChange.pm b/rt/lib/RT/Condition/StatusChange.pm index 668c5bcb4..f665e45e0 100644 --- a/rt/lib/RT/Condition/StatusChange.pm +++ b/rt/lib/RT/Condition/StatusChange.pm @@ -114,11 +114,11 @@ sub IsApplicable { } else { $RT::Logger->error("Argument '$argument' is incorrect.") - unless RT::Lifecycle->Load('')->IsValid( $argument ); + unless RT::Lifecycle->Load(Type => 'ticket')->IsValid( $argument ); return 0; } - my $lifecycle = $self->TicketObj->QueueObj->Lifecycle; + my $lifecycle = $self->TicketObj->LifecycleObj; if ( $new_must_be ) { return 0 unless grep lc($new) eq lc($_), map {m/^(initial|active|inactive)$/i? $lifecycle->Valid(lc $_): $_ } |