summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Condition
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Condition')
-rw-r--r--rt/lib/RT/Condition/AnyTransaction.pm2
-rw-r--r--rt/lib/RT/Condition/BeforeDue.pm25
-rw-r--r--rt/lib/RT/Condition/CloseTicket.pm2
-rw-r--r--rt/lib/RT/Condition/Overdue.pm12
-rw-r--r--rt/lib/RT/Condition/OwnerChange.pm18
-rw-r--r--rt/lib/RT/Condition/PriorityChange.pm8
-rw-r--r--rt/lib/RT/Condition/PriorityExceeds.pm8
-rw-r--r--rt/lib/RT/Condition/QueueChange.pm8
-rw-r--r--rt/lib/RT/Condition/ReopenTicket.pm2
-rw-r--r--rt/lib/RT/Condition/StatusChange.pm6
-rw-r--r--rt/lib/RT/Condition/UserDefined.pm2
11 files changed, 57 insertions, 36 deletions
diff --git a/rt/lib/RT/Condition/AnyTransaction.pm b/rt/lib/RT/Condition/AnyTransaction.pm
index 5d8b3bc76..f63508b03 100644
--- a/rt/lib/RT/Condition/AnyTransaction.pm
+++ b/rt/lib/RT/Condition/AnyTransaction.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/lib/RT/Condition/BeforeDue.pm b/rt/lib/RT/Condition/BeforeDue.pm
index 73015bcc8..6e1b60272 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-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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/CloseTicket.pm b/rt/lib/RT/Condition/CloseTicket.pm
index 2e027f4de..67f4dd98b 100644
--- a/rt/lib/RT/Condition/CloseTicket.pm
+++ b/rt/lib/RT/Condition/CloseTicket.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/lib/RT/Condition/Overdue.pm b/rt/lib/RT/Condition/Overdue.pm
index 462fa407c..f9c0c498a 100644
--- a/rt/lib/RT/Condition/Overdue.pm
+++ b/rt/lib/RT/Condition/Overdue.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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 407d5a5ae..73689710c 100644
--- a/rt/lib/RT/Condition/OwnerChange.pm
+++ b/rt/lib/RT/Condition/OwnerChange.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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 25e6bfb5b..8992e7bd3 100644
--- a/rt/lib/RT/Condition/PriorityChange.pm
+++ b/rt/lib/RT/Condition/PriorityChange.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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 e35d0b5b8..808595bf5 100644
--- a/rt/lib/RT/Condition/PriorityExceeds.pm
+++ b/rt/lib/RT/Condition/PriorityExceeds.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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 91cd88c4e..d4be9650b 100644
--- a/rt/lib/RT/Condition/QueueChange.pm
+++ b/rt/lib/RT/Condition/QueueChange.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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/ReopenTicket.pm b/rt/lib/RT/Condition/ReopenTicket.pm
index 69ef8f9ab..f082eb8e9 100644
--- a/rt/lib/RT/Condition/ReopenTicket.pm
+++ b/rt/lib/RT/Condition/ReopenTicket.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/lib/RT/Condition/StatusChange.pm b/rt/lib/RT/Condition/StatusChange.pm
index 55fe2347f..f665e45e0 100644
--- a/rt/lib/RT/Condition/StatusChange.pm
+++ b/rt/lib/RT/Condition/StatusChange.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -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 $_): $_ }
diff --git a/rt/lib/RT/Condition/UserDefined.pm b/rt/lib/RT/Condition/UserDefined.pm
index 4f4ff1816..7d58eb02f 100644
--- a/rt/lib/RT/Condition/UserDefined.pm
+++ b/rt/lib/RT/Condition/UserDefined.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)