[rt-devel] [PATCH] Implement overriding global templates by queue templates with the same name
Anton Berezin
tobez at tobez.org
Tue Jul 15 07:59:34 EDT 2003
Hi,
The patch follows. I am wondering about two things, though:
1. Whether the approach I've taken is sound, and
2. Whether this is something better left for user extensions.
As for (2), I am pretty sure this functionality belongs to the core RT,
since currently, as soon as a single queue requires a single slightly
customized template, one has to get rid of a global scrip (or several
global scrips), re-create identical scripts for each queue, and so on -
clearly too much trouble for a simple action.
What do you think?
--- rt-3-0-4.o/lib/RT/ScripAction_Overlay.pm Sat Jul 12 10:24:37 2003
+++ rt-3-0-4/lib/RT/ScripAction_Overlay.pm Tue Jul 15 13:52:43 2003
@@ -135,6 +135,8 @@ sub LoadAction {
my %args = ( TransactionObj => undef,
TicketObj => undef,
@_ );
+
+ $self->{_TicketObj} = $args{TicketObj};
#TODO: Put this in an eval
$self->ExecModule =~ /^(\w+)$/;
@@ -168,6 +170,16 @@ sub TemplateObj {
require RT::Template;
$self->{'TemplateObj'} = RT::Template->new($self->CurrentUser);
$self->{'TemplateObj'}->LoadById($self->{'Template'});
+
+ if ($self->{'TemplateObj'}->__Value('Queue') == 0) {
+ my $to = $self->{_TicketObj};
+ my $tmptemplate = RT::Template->new($self->CurrentUser);
+ my ($ok, $err) = $tmptemplate->LoadQueueTemplate(Queue => $to->Queue, Name => $self->{TemplateObj}->Name);
+ if ($ok) {
+ # found the queue-specific template with the same name
+ $self->{TemplateObj} = $tmptemplate;
+ }
+ }
}
@@ -206,6 +218,7 @@ sub Describe {
# {{{ sub DESTROY
sub DESTROY {
my $self=shift;
+ $self->{_TicketObj} = undef;
$self->{'Action'} = undef;
$self->{'TemplateObj'} = undef;
}
\Anton.
--
A topologist is someone who can't tell the difference between a donut
and a coffee cup.
More information about the Rt-devel
mailing list