[Rt-commit] rt branch, 4.2/forward-with-message, updated. rt-4.0.6-245-g3e5b0ef

? sunnavy sunnavy at bestpractical.com
Sat Jul 7 11:48:57 EDT 2012


The branch, 4.2/forward-with-message has been updated
       via  3e5b0efb4d4b7ea1d289bb7740792e6e77d70b4d (commit)
      from  252759fdcd4d50898eb3f09e4556f79fb8093dc6 (commit)

Summary of changes:
 lib/RT/Interface/Email.pm      | 91 +++++++++++-------------------------------
 share/html/Ticket/Forward.html |  9 ++---
 2 files changed, 27 insertions(+), 73 deletions(-)

- Log -----------------------------------------------------------------
commit 3e5b0efb4d4b7ea1d289bb7740792e6e77d70b4d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Jul 7 23:32:30 2012 +0800

    don't replace forward template's default content, just add the custom message
    
    the old code can't handle complex forward template well.
    besides, it feels more right to keep the default template content.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 7f8dea5..e16dbd2 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -745,41 +745,34 @@ sub SendForward {
         $RT::Logger->warning($msg);
     }
 
-    if ( $args{'Content'} ) {
-        if ($mail) {
-            my $io = $mail->bodyhandle->open("w");
-            $io->print( $args{'Content'} );
-            $io->close;
-            $mail->head->set( 'Content-Type' => $args{'ContentType'} );
+    unless ($mail) {
+        $RT::Logger->warning(
+            "Couldn't generate email using template '$args{Template}'");
+
+        my $description;
+        unless ( $args{'Transaction'} ) {
+            $description = 'This is forward of ticket #' . $ticket->id;
         }
         else {
-            $mail = MIME::Entity->build(
-                Type => $args{'ContentType'},
-                Data => $args{'Content'},
-            );
+            $description =
+                'This is forward of transaction #'
+              . $txn->id
+              . " of a ticket #"
+              . $txn->ObjectId;
         }
+        $mail = MIME::Entity->build(
+            Type => 'text/plain',
+            Data => $description,
+        );
     }
-    else {
-        unless ($mail) {
-            $RT::Logger->warning(
-                "Couldn't generate email using template '$args{Template}'");
 
-            my $description;
-            unless ( $args{'Transaction'} ) {
-                $description = 'This is forward of ticket #' . $ticket->id;
-            }
-            else {
-                $description =
-                    'This is forward of transaction #'
-                  . $txn->id
-                  . " of a ticket #"
-                  . $txn->ObjectId;
-            }
-            $mail = MIME::Entity->build(
-                Type => 'text/plain',
-                Data => $description,
-            );
-        }
+    if ( $args{'Content'} ) {
+        $mail->make_multipart unless $mail->is_multipart;
+        my $message = MIME::Entity->build(
+            Type => $args{'ContentType'},
+            Data => $args{'Content'},
+        );
+        $mail->add_part( $message, 0 ); # make it the first entity
     }
 
     $mail->head->set( $_ => EncodeToMIME( String => $args{$_} ) )
@@ -836,44 +829,6 @@ sub GetForwardFrom {
     }
 }
 
-=head2 GetForwardDefaultContent Ticket => undef, Transaction => undef
-
-Resolve the Content to use in forward mail
-
-=cut
-
-sub GetDefaultForwardContent {
-    my %args   = ( Ticket => undef, Transaction => undef, @_ );
-    my $txn    = $args{Transaction};
-    my $ticket = $args{Ticket} || $txn->Object;
-
-    my ( $template, $msg ) = PrepareEmailUsingTemplate(
-        Template => $txn ? 'Forward' : 'Forward Ticket',
-        Arguments => {
-            Ticket      => $ticket,
-            Transaction => $txn,
-        },
-    );
-
-    if ($template) {
-        return $template->MIMEObj->stringify_body();
-    }
-    else {
-        $RT::Logger->warning($msg);
-
-        if ($txn) {
-            return 'This is forward of ticket #' . $ticket->id;
-        }
-        else {
-            return
-                'This is forward of transaction #'
-              . $txn->id
-              . " of a ticket #"
-              . $txn->ObjectId;
-        }
-    }
-}
-
 =head2 GetForwardAttachments Ticket => undef, Transaction => undef
 
 Resolve the Attachments to forward
diff --git a/share/html/Ticket/Forward.html b/share/html/Ticket/Forward.html
index f337bfb..d4bc701 100644
--- a/share/html/Ticket/Forward.html
+++ b/share/html/Ticket/Forward.html
@@ -75,7 +75,11 @@
 <tr>
 <td><&|/l&>Content</&>:</td>
 <td>
+% if (exists $ARGS{Content}) {
 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
+% } else {
+<& /Elements/MessageBox  &>
+%}
 </td>
 </tr>
 
@@ -128,11 +132,6 @@ my $subject = $TicketObj->Subject;
 $subject = RT::Interface::Email::AddSubjectTag( $subject, $TicketObj )
     unless RT->Config->Get('ForwardFromUser');
 
-$ARGS{Content} ||= RT::Interface::Email::GetDefaultForwardContent(
-    Ticket => $TicketObj,
-    $txn ? ( Transaction => $txn ) : (),
-);
-
 my $attachments = RT::Interface::Email::GetForwardAttachments(
     Ticket => $TicketObj,
     $txn ? ( Transaction => $txn ) : (),

-----------------------------------------------------------------------


More information about the Rt-commit mailing list