%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2002 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE BLOCK <& /Admin/Elements/Header, title => loc("Modify Template [_1]", $TemplateObj->Id) &> <& /Admin/Elements/SystemTabs &> <& /Elements/ListActions, actions => \@results &>
%# hang onto the queue id % if ($WFId) { % } % if ($WFAction) { % } else { % } <& /Elements/TitleBoxStart, title => 'Modify Approval' &> <& /Admin/Elements/ModifyTemplateAsWorkflow, URL => "/Admin/Global/Workflow.html", Queue => $Queue, template => $template, WFId => $WFId, WFType => $WFType, WFQueue => $WFQueue, WFQueue => $WFQueue, WFDescription => $WFDescription, WFContent => $WFContent &> <& /Elements/TitleBoxEnd &> <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Name => 'WFSubmit', Label => loc("Submit Workflow"), color => "#cccc00" &> <& /Admin/Elements/ModifyTemplate, Name => $TemplateObj->Name, Description => $TemplateObj->Description, Content => $TemplateObj->Content &> <& /Elements/TitleBoxEnd &> <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Name => 'TemplateSubmit', Reset => 1 &>
<%INIT> Abort( loc("Queue is not specified.") ) unless defined($Queue); # utf-8 business #require Encode; Encode::_utf8_on($WFDescription) if $WFDescription; Encode::_utf8_on($WFContent) if $WFContent; Encode::_utf8_on($Name) if $Name; Encode::_utf8_on($Description) if $Description; Encode::_utf8_on($Content) if $Content; my $TemplateObj = new RT::Template( $session{'CurrentUser'} ); my ( $title, @results ); # workflow entry business if ( exists $ARGS{WFSubmit} ) { if ( $WFAction eq "create" ) { # commit a new workflow entry $RT::Logger->debug("commit a new workflow entry"); push @{ $session{WorkFlow} }, { Id => $WFId, Type => $WFType, Queue => $WFQueue, Owner => $WFOwner, Description => $WFDescription, Content => $WFContent, }; @{ $session{WorkFlow} } = sort { $a->{Id} cmp $b->{Id} } @{ $session{WorkFlow} }; $session{WorkFlow} = [ @{ $session{WorkFlow} } ]; } elsif ( $WFAction eq "modify" ) { # modify an existing workflow entry $RT::Logger->debug("modify an existing workflow entry"); my ($entry) = grep { $_->Id =~ "^$WFId" } @{ $session{WorkFlow} }; $entry = { Id => $WFId, Type => $WFType, Queue => $WFQueue, Owner => $WFOwner, Description => $WFDescription, Content => $WFContent, }; $session{WorkFlow} = [ @{ $session{WorkFlow} } ]; } } if ( $WFAction eq "delete" ) { # delete an existing workflow entry $RT::Logger->debug("delete an existing workflow entry"); @{ $session{WorkFlow} } = grep { $_->{Id} !~ "^$WFId" } @{ $session{WorkFlow} }; delete $session{WorkFlow} unless @{ $session{WorkFlow} }; $WFAction = ($WFId) ? "modify" : "create"; } # template business if ($create) { # show a new template $title = loc("Create a template"); $template = "new"; # this is a fresh start $RT::Logger->debug("show a new template"); delete $session{WorkFlow} if exists $session{WorkFlow}; # for a fresh test # and make a good start $WFId = 1; } elsif ( $template eq "new" && exists $ARGS{TemplateSubmit} ) { # commit a new template $RT::Logger->debug("commit a new template"); my ( $val, $msg ) = $TemplateObj->Create( Queue => $Queue, Name => $Name ); Abort( loc( "Could not create template: [_1]", $msg ) ) unless ($val); push @results, $msg; $title = loc( 'Created template [_1]', loc( $TemplateObj->Name() ) ); $template = $TemplateObj->Id; } elsif ( $template && exists $ARGS{TemplateSubmit} ) { # modify an existing template $RT::Logger->debug("modify an existing template"); } if ( $template ne 'new' ) { $TemplateObj->Load($template) || Abort( loc('No Template') ); $title = loc( 'Editing template [_1]', loc( $TemplateObj->Name() ) ); } if ( $TemplateObj->Id() ) { my @attribs = qw( Description Content Queue Name); my @aresults = UpdateRecordObject( AttributesRef => \@attribs, Object => $TemplateObj, ARGSRef => \%ARGS ); push @results, @aresults; } <%ARGS> $Queue => 0 $create => undef $template => undef $Name => undef $WFAction => undef $WFId => undef $WFType => undef $WFQueue => undef $WFOwner => undef $WFDescription => undef $WFContent => undef $Description => undef $Content => undef