import of rt 3.0.9
[freeside.git] / rt / lib / RT / Template_Overlay.pm
index 0b5e67d..5950aa3 100644 (file)
@@ -203,10 +203,11 @@ sub LoadQueueTemplate {
     my $self = shift;
     my %args = (
         Queue => undef,
-        Name  => undef
+        Name  => undef,
+        @_
     );
 
-    return ( $self->LoadByCols( Name => $args{'Name'}, Queue => {'Queue'} ) );
+    return ( $self->LoadByCols( Name => $args{'Name'}, Queue => $args{'Queue'} ) );
 
 }
 
@@ -318,24 +319,30 @@ sub Parse {
     my $parser = MIME::Parser->new();
 
     # Setup output directory for files. from RT::EmailParser::_SetupMIMEParser
-    if (my $AttachmentDir = eval { File::Temp::tempdir( TMPDIR => 1, CLEANUP => 1 ) }) {
-       # Set up output directory for files:
-       $parser->output_dir("$AttachmentDir");
+    if ( my $AttachmentDir =
+        eval { File::Temp::tempdir( TMPDIR => 1, CLEANUP => 1 ) } )
+    {
+
+        # Set up output directory for files:
+        $parser->output_dir("$AttachmentDir");
     }
     else {
-       # On some situations TMPDIR is non-writable. sad but true.
-       $parser->output_to_core(1);
-       $parser->tmp_to_core(1);
+        $RT::Logger->error("Couldn't write attachments to temp dir on disk. using more memory and processor.");
+        # On some situations TMPDIR is non-writable. sad but true.
+        $parser->output_to_core(1);
+        $parser->tmp_to_core(1);
     }
+
     #If someone includes a message, don't extract it
     $parser->extract_nested_messages(1);
+
     # Set up the prefix for files with auto-generated names:
     $parser->output_prefix("part");
+
     # If content length is <= 50000 bytes, store each msg as in-core scalar;
     # Else, write to a disk file (the default action):
     $parser->output_to_core(50000);
 
-
     ### Should we forgive normally-fatal errors?
     $parser->ignore_errors(1);
     $self->{'MIMEObj'} = eval { $parser->parse_data($content) };
@@ -350,7 +357,6 @@ sub Parse {
     $self->{'MIMEObj'}->head->unfold();
 
     return ( 1, $self->loc("Template parsed") );
-   
 
 }
 
@@ -369,12 +375,13 @@ sub _ParseContent {
         @_
     );
 
-
+    no warnings 'redefine';
     $T::Ticket      = $args{'TicketObj'};
     $T::Transaction = $args{'TransactionObj'};
     $T::Argument    = $args{'Argument'};
     $T::Requestor   = eval { $T::Ticket->Requestors->UserMembersObj->First->Name };
     $T::rtname      = $RT::rtname;
+    *T::loc         = sub { $T::Ticket->loc(@_) };
 
     # We need to untaint the content of the template, since we'll be working
     # with it