From 1b821166888962897d6f4b0c87acb00d6b9f392d Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 10 Dec 2015 01:01:21 -0800 Subject: fix some problems with creation of subtask tickets, #34061 --- rt/lib/RT/Condition/CustomFieldEquals.pm | 7 ++++--- rt/lib/RT/Template_Vendor.pm | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 rt/lib/RT/Template_Vendor.pm (limited to 'rt/lib/RT') diff --git a/rt/lib/RT/Condition/CustomFieldEquals.pm b/rt/lib/RT/Condition/CustomFieldEquals.pm index 69dedcbca..8ebf94b2b 100644 --- a/rt/lib/RT/Condition/CustomFieldEquals.pm +++ b/rt/lib/RT/Condition/CustomFieldEquals.pm @@ -28,9 +28,10 @@ sub IsApplicable { 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 ( $trans->Field == $cf->Id + and $trans->NewValue eq $value + and $trans->OldValue ne $value + ); } return undef; } diff --git a/rt/lib/RT/Template_Vendor.pm b/rt/lib/RT/Template_Vendor.pm new file mode 100644 index 000000000..f1a276c3d --- /dev/null +++ b/rt/lib/RT/Template_Vendor.pm @@ -0,0 +1,34 @@ +package RT::Template; + +=item LoadByName + +Takes Name and Queue arguments. Tries to load queue specific template +first, then global. If Queue argument is omitted then global template +is tried, not template with the name in any queue. + +=cut + +sub LoadByName { + my $self = shift; + my %args = ( + Queue => undef, + Name => undef, + @_ + ); + my $queue = $args{'Queue'}; + if ( blessed $queue ) { + $queue = $queue->id; + } elsif ( defined $queue and $queue =~ /\D/ ) { + my $tmp = RT::Queue->new( $self->CurrentUser ); + $tmp->Load($queue); + $queue = $tmp->id; + } + + return $self->LoadGlobalTemplate( $args{'Name'} ) unless $queue; + + $self->LoadQueueTemplate( Queue => $queue, Name => $args{'Name'} ); + return $self->id if $self->id; + return $self->LoadGlobalTemplate( $args{'Name'} ); +} + +1; -- cgit v1.2.1