rt 4.2.13 ticket#13852
[freeside.git] / rt / share / html / Admin / Global / Template.html
index 27b2a96..4e15dda 100755 (executable)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
 %# hang onto the queue id
 <input type="hidden" class="hidden" name="Queue" value="<%$Queue%>" />
 <& /Admin/Elements/ModifyTemplate,
-    Name        => $TemplateObj->Name,
-    Description => $TemplateObj->Description,
-    Content     => $TemplateObj->Content,
-    Type        => $TemplateObj->Type
+    Name        => $TemplateObj->Name // $ARGS{Name},
+    Description => $TemplateObj->Description // $ARGS{Description},
+    Content     => $TemplateObj->Content // $ARGS{Content},
+    Type        => $TemplateObj->Type // $ARGS{Type},
 &>
 <& /Elements/Submit, Label => $SubmitLabel, Reset => 1 &>
 </form>
 my $TemplateObj = RT::Template->new($session{'CurrentUser'});
 my  ($title, @results, $SubmitLabel);
 
-if ($Create) {
-  $title = loc("Create a template");
-  $SubmitLabel = loc('Create');
-}
-
-else {
-  if (defined ($Template) && $Template eq 'new') {
-      my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name, Type => $Type);
-      Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
-     push @results, $msg;
+if (!$Create) {
+    if (defined ($Template) && $Template eq 'new') {
+        my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name, Type => $Type);
+        push @results, $msg;
+    } else {
+        $TemplateObj->Load($Template) || Abort(loc('No Template'));
     }
-    else {
-       $TemplateObj->Load($Template) || Abort(loc('No Template'));
-    }
-     $title = loc('Modify template [_1]', loc($TemplateObj->Name())); 
-     $SubmitLabel = loc('Save Changes');
-    
 }
+
 if ($TemplateObj->Id()) {
-  my @attribs = qw( Name Description Queue Type Content );
-  my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
-                                    Object => $TemplateObj, 
-                                    ARGSRef => \%ARGS);
-  push @results, @aresults;
+    my @attribs = qw( Name Description Queue Type Content );
+    my @aresults = UpdateRecordObject( AttributesRef => \@attribs,
+                                       Object => $TemplateObj,
+                                       ARGSRef => \%ARGS);
+    push @results, @aresults;
 
-  my ($ok, $msg) = $TemplateObj->CompileCheck;
-  push @results, $msg if !$ok;
+    my ($ok, $msg) = $TemplateObj->CompileCheck;
+    push @results, $msg if !$ok;
+} else {
+    $Create = 1;
 }
 
+if ($Create) {
+    $title = loc("Create a template");
+    $SubmitLabel = loc('Create');
+} else {
+    $title = loc('Modify template [_1]', loc($TemplateObj->Name()));
+    $SubmitLabel = loc('Save Changes');
+}
+
+
 </%INIT>
 <%ARGS>
 $Queue => ''