summaryrefslogtreecommitdiff
path: root/rt/lib
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:00:28 -0800
commit548b94eafa4bc90680e13f015445b6833b065c73 (patch)
tree7d8323efeb9fac22ea487bcfdc2adb8659cd15d6 /rt/lib
parentf263d9c5f3fa07442faadd9000aaad7275892f8e (diff)
automatic creation of subtask tickets, #34061
Diffstat (limited to 'rt/lib')
-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;
+