[Svn] r2361 - in branches/devel-api/program: include steps/mail

trac at roundcube.net trac at roundcube.net
Thu Mar 26 08:54:26 CET 2009


Author: thomasb
Date: 2009-03-26 02:54:26 -0500 (Thu, 26 Mar 2009)
New Revision: 2361

Modified:
   branches/devel-api/program/include/rcube_plugin_api.php
   branches/devel-api/program/steps/mail/sendmail.inc
Log:
Add hook for outgoing message body

Modified: branches/devel-api/program/include/rcube_plugin_api.php
===================================================================
--- branches/devel-api/program/include/rcube_plugin_api.php	2009-03-26 07:52:04 UTC (rev 2360)
+++ branches/devel-api/program/include/rcube_plugin_api.php	2009-03-26 07:54:26 UTC (rev 2361)
@@ -285,7 +285,6 @@
    */
   public function add_content($html, $container)
   {
-    console($html, $container);
     $this->template_contents[$container] .= $html . "\n";
   }
   

Modified: branches/devel-api/program/steps/mail/sendmail.inc
===================================================================
--- branches/devel-api/program/steps/mail/sendmail.inc	2009-03-26 07:52:04 UTC (rev 2360)
+++ branches/devel-api/program/steps/mail/sendmail.inc	2009-03-26 07:54:26 UTC (rev 2361)
@@ -261,34 +261,34 @@
 // For HTML-formatted messages, construct the MIME message with both
 // the HTML part and the plain-text part
 
-if ($isHtml)
-  {
-  $MAIL_MIME->setHTMLBody($message_body);
+if ($isHtml) {
+  $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $message_body, 'type' => 'html', 'message' => $MAIL_MIME));
+  $MAIL_MIME->setHTMLBody($plugin['body']);
 
   // add a plain text version of the e-mail as an alternative part.
   $h2t = new html2text($message_body);
   $plainTextPart = wordwrap($h2t->get_text(), 998, "\r\n", true);
-  if (!strlen($plainTextPart)) 
-    { 
+  if (!strlen($plainTextPart)) {
     // empty message body breaks attachment handling in drafts 
     $plainTextPart = "\r\n"; 
-    }
-  $MAIL_MIME->setTXTBody($plainTextPart);
+  }
+  $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
+  $MAIL_MIME->setTXTBody($plugin['body']);
 
   // look for "emoticon" images from TinyMCE and copy into message as attachments
   rcmail_attach_emoticons($MAIL_MIME);
-  }
+}
 else
   {
   $message_body = wordwrap($message_body, 75, "\r\n");
   $message_body = wordwrap($message_body, 998, "\r\n", true);
-  if (!strlen($message_body))  
-    { 
+  if (!strlen($message_body)) { 
     // empty message body breaks attachment handling in drafts 
     $message_body = "\r\n"; 
-    } 
-  $MAIL_MIME->setTXTBody($message_body, FALSE, TRUE);
   }
+  $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $message_body, 'type' => 'plain', 'message' => $MAIL_MIME));
+  $MAIL_MIME->setTXTBody($plugin['body'], false, true);
+}
 
 // chose transfer encoding
 $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15');
@@ -297,14 +297,15 @@
 // add stored attachments, if any
 if (is_array($_SESSION['compose']['attachments'])) {
   foreach ($_SESSION['compose']['attachments'] as $id => $attachment) {
-    // This hook gives attachment handlers a chance to place the file on disk
+    // This hook retrieves the attachment contents from the file storage backend
     $attachment = $RCMAIL->plugins->exec_hook('get_attachment', $attachment);
 
     $dispurl = '/\ssrc\s*=\s*[\'"]?\S+display-attachment\S+file=rcmfile' . $attachment['id'] . '[\'"]?/';
-    $match = preg_match($dispurl, $message_body);
-    if ($isHtml && ($match > 0)) {
+    $message_body = $MAL_MIME->getHTMLBody();
+    if ($isHtml && (preg_match($dispurl, $message_body) > 0)) {
       $message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'"', $message_body);
       $MAIL_MIME->setHTMLBody($message_body);
+      
       if ($attachment['data'])
         $MAIL_MIME->addHTMLImage($attachment['data'], $attachment['mimetype'], $attachment['name'], false);
       else
@@ -354,6 +355,9 @@
   'text_charset'  => $message_charset,
 ));
 
+$data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers));
+$headers = $data['headers'];
+
 // encoding subject header with mb_encode provides better results with asian characters
 if (function_exists("mb_encode_mimeheader"))
 {
@@ -362,9 +366,6 @@
   mb_internal_encoding(RCMAIL_CHARSET);
 }
 
-$data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers));
-$headers = $data['headers'];
-
 // pass headers to message object
 $MAIL_MIME->headers($headers);
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list