Implement overriding global templates by queue templates with the same name

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.

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?

I think it is a wonderful idea; its speed impact is minimal,
and is unlikely to cause any problem for existing users.

I’d be very happy to see it merged into 3.0.x, or at least 3.1.x.

Thanks,
/Autrijus/

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.

I think this patch is wonderful. I’ve taken it into my branch
under the _Vendor space, and hopes to discuss with Jesse during
3.1.x if possible.

Also, what do you think about doing the same thing for Scrips?

Thanks,
/Autrijus/