%# "Of _course_ it's the murder weapon. Who would frame someone with a fake?" <& /Edit/Elements/104Header, Buttons => [ Add => "?Queue=$Queue&Action-Add=1", Save => ($Template ? "javascript:document.getElementById('mainform').submit()" : ''), Delete => 1, Copy => '', Search => '', ], Method => 'POST', &> % if ($Queue) { $m->print($m->content) } else {

<& /Edit/Elements/Tab, Text => 'Global' &>
<& /Edit/Elements/Tabs, Map => $ARGS{Map}, URL => '../Template/' &>
% }
<& Top, Item => $Item, List => $List &>
<& List, Delete => 1, List => $List, Begin => $Begin, Item => $Item, ARGS => \%ARGS &>

<%INIT> my $List = []; my $Item = $RT::Nothing; my $Templates = RT::Templates->new($session{'CurrentUser'}); my $QueueObj = RT::Queue->new($session{'CurrentUser'}); my @actions; if ($Queue) { $QueueObj->Load($Queue); } if ($QueueObj->id) { $Templates->LimitToQueue($Queue); } else { $Templates->LimitToGlobal(); } $Templates->Limit( FIELD => 'Content', VALUE => '%===Create-Ticket:%', OPERATOR => 'NOT LIKE' ); if ($Template) { $Item = RT::Template->new($session{'CurrentUser'}); $Item->Load( $Template ); } if ($Action eq 'Save' and $r->method eq 'POST') { $Item->SetName($ARGS{Name}) if exists $ARGS{Name}; $Item->SetDescription($ARGS{Description}) if exists $ARGS{Description}; $Item->SetContent($ARGS{Content}) if exists $ARGS{Content}; } elsif ($Action eq 'Add') { $Item = RT::Template->new($session{'CurrentUser'}); my ($val, $msg) = $Item->Create( Queue => $Queue, Name => loc('(new)'), Description => '', Content => '' ); Abort(loc("Could not create Template", $msg)) unless ($val); $Template = $Item->id; $Begin = -1; } elsif ($Action eq 'Delete') { foreach my $Id (@ListDelete) { my $item = RT::Template->new($session{'CurrentUser'}); $item->Load( $Id ); $item->Delete; } $Templates->RedoSearch; $Item = $Templates->First || $RT::Nothing; $Begin = $Template = 0; } else { undef $Action; } $m->redirect("?Queue=$Queue&Template=$Template&Begin=$Begin") if $Action; $List = $Templates->ItemsArrayRef; $Begin = int($#$List / 8) * 8 if $Begin == -1; <%ARGS> $Begin => 0 $Template => undef $Queue => 0 $Action => '' @ListDelete => ()