[Rt-commit] r8856 - rt/branches/3.7-EXPERIMENTAL/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Fri Aug 31 08:10:23 EDT 2007


Author: ruz
Date: Fri Aug 31 08:10:22 2007
New Revision: 8856

Modified:
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Template_Overlay.pm

Log:
* docs update

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Template_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Template_Overlay.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Template_Overlay.pm	Fri Aug 31 08:10:22 2007
@@ -67,12 +67,12 @@
 package RT::Template;
 
 use strict;
+use warnings;
 no warnings qw(redefine);
 
 use Text::Template;
 use MIME::Entity;
 use MIME::Parser;
-use File::Temp qw /tempdir/;
 
 sub _Accessible {
     my $self = shift;
@@ -148,15 +148,29 @@
 
 sub LoadGlobalTemplate {
     my $self = shift;
-    my $id   = shift;
+    my $name = shift;
 
-    return ( $self->LoadQueueTemplate( Queue => 0, Name => $id ) );
+    return ( $self->LoadQueueTemplate( Queue => 0, Name => $name ) );
 }
 
 =head2 LoadQueueTemplate (Queue => QUEUEID, Name => NAME)
 
 Loads the Queue template named NAME for Queue QUEUE.
 
+Note that this method doesn't load a global template with the same name
+if template in the queue doesn't exist. THe following code can be used:
+
+    $template->LoadQueueTemplate( Queue => $queue_id, Name => $template_name );
+    unless ( $template->id ) {
+        $template->LoadGlobalTemplate( $template_name );
+        unless ( $template->id ) {
+            # no template
+            ...
+        }
+    }
+    # ok, template either queue's or global
+    ...
+
 =cut
 
 sub LoadQueueTemplate {
@@ -238,6 +252,13 @@
     return ( $self->SUPER::Delete(@_) );
 }
 
+=head2 MIMEObj
+
+Returns L<MIME::Entity> object parsed using L</Parse> method. Returns
+undef if last call to L</Parse> failed or never be called.
+
+=cut
+
 sub MIMEObj {
     my $self = shift;
     return ( $self->{'MIMEObj'} );
@@ -246,9 +267,11 @@
 =head2 Parse
 
 This routine performs L<Text::Template> parsing on the template and then
-imports the results into a L<MIME::Entity> so we can really use it.
+imports the results into a L<MIME::Entity> so we can really use it. Use
+L</MIMEObj> method to get the L<MIME::Entity> object.
 
-Takes a hash containing Argument, TicketObj, and TransactionObj.
+Takes a hash containing Argument, TicketObj, and TransactionObj and other
+arguments that will be available in the template's code.
 
 It returns a tuple of (val, message). If val is false, the message contains
 an error message.
@@ -258,6 +281,9 @@
 sub Parse {
     my $self = shift;
 
+    # clear prev MIME object
+    $self->{'MIMEObj'} = undef;
+
     #We're passing in whatever we were passed. it's destined for _ParseContent
     my ($content, $msg) = $self->_ParseContent(@_);
     return ( 0, $msg ) unless defined $content && length $content;


More information about the Rt-commit mailing list