summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Condition/CustomFieldEquals.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-12-09 16:00:14 -0800
committerMark Wells <mark@freeside.biz>2015-12-09 16:01:33 -0800
commitd0c5ecc6d52a28f583ec45afc3460dc613b38eba (patch)
tree6ad58855a356e18138f5c23055de7e820379da9e /rt/lib/RT/Condition/CustomFieldEquals.pm
parent0efd28a530593574f40dcfab69eaae2b3f0da388 (diff)
automatic creation of subtask tickets, #34061
Diffstat (limited to 'rt/lib/RT/Condition/CustomFieldEquals.pm')
-rw-r--r--rt/lib/RT/Condition/CustomFieldEquals.pm39
1 files changed, 39 insertions, 0 deletions
diff --git a/rt/lib/RT/Condition/CustomFieldEquals.pm b/rt/lib/RT/Condition/CustomFieldEquals.pm
new file mode 100644
index 000000000..69dedcbca
--- /dev/null
+++ b/rt/lib/RT/Condition/CustomFieldEquals.pm
@@ -0,0 +1,39 @@
+package RT::Condition::CustomFieldEquals;
+use base 'RT::Condition';
+use strict;
+
+=head2 IsApplicable
+
+If a custom field has a value equal to some specified value.
+
+=cut
+
+# Based on Chuck Boeheim's code posted on the RT Wiki 3/13/06
+# Simplified to avoid carrying old schema around. The new mechanics are that
+# the ScripCondition's "Argument" is the custom field name = value. If the
+# transaction initially sets the CF value to a the specified value, or
+# changes it from not equaling to equaling the specified value, the condition
+# returns true.
+# Don't use this on custom fields that allow multiple values.
+
+sub IsApplicable {
+ my $self = shift;
+ my $trans = $self->TransactionObj;
+ my $scrip = $self->ScripObj;
+ my ($field, $value) = split('=', $self->Argument, 2);
+
+ if ($trans->Type eq 'Create') {
+ return ($trans->TicketObj->FirstCustomFieldValue($field) eq $value);
+ }
+ if ($trans->Type eq 'CustomField') {
+ my $cf = RT::CustomField->new($self->CurrentUser);
+ $cf->Load($field);
+ return $trans->Field == $cf->Id
+ and ($trans->NewValue eq $value)
+ and ($trans->OldValue ne $value)
+ }
+ return undef;
+}
+
+1;
+