From 624b7ef21646696809d91edf8d282b04b8d35df6 Mon Sep 17 00:00:00 2001
From: Joel Pittet <joel@pittet.ca>
Date: Wed, 8 Feb 2012 17:54:33 -0800
Subject: [PATCH] fix redeclare errors with mimemail

---
 messaging_htmlmail/messaging_htmlmail.inc |   38 +++++++++++++---------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/messaging_htmlmail/messaging_htmlmail.inc b/messaging_htmlmail/messaging_htmlmail.inc
index 03fe0a6..544de58 100644
--- a/messaging_htmlmail/messaging_htmlmail.inc
+++ b/messaging_htmlmail/messaging_htmlmail.inc
@@ -77,9 +77,7 @@ class Messaging_HTML_Mail_Method extends Messaging_Mail_Method {
     // Format the message body, last chance for formatting
     $mail = self::$mail_system->format($mail);
     return self::$mail_system->mail($mail);    
-  }
-
-  
+  }  
 }
 
 /**
@@ -215,7 +213,7 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
      * @todo When replacing links we break the ones that are yet to be replaced (tokens)
     //expand all local links
     $pattern = '/(<a[^>]+href=")([^"]*)/mi';
-    $body = preg_replace_callback($pattern, '_mimemail_expand_links', $body);
+    $body = preg_replace_callback($pattern, '_messaging_htmlmail_expand_links', $body);
     **/
     
     $mime_parts = $this->mimemail_extract_files($body);
@@ -232,8 +230,8 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
       $a = (object) $a;
       // Check the list parameter if its set or ignore it (Upload module support).
       if(!isset($a->list) || $a->list) {
-        _mimemail_file($a->filepath, $a->filename, $a->filemime, 'attachment');
-        $parts = array_merge($parts, _mimemail_file());
+        _messaging_htmlmail_file($a->filepath, $a->filename, $a->filemime, 'attachment');
+        $parts = array_merge($parts, _messaging_htmlmail_file());
       }
     }
   
@@ -366,7 +364,7 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
    */
   function mimemail_extract_files($html) {
     $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |[\s]src=[\'"]?)([^\'>"]+)([\'"]?)/mis';
-    $html = preg_replace_callback($pattern, '_mimemail_replace_files', $html);
+    $html = preg_replace_callback($pattern, '_messaging_htmlmail_replace_files', $html);
   
     $document = array(array(
       'Content-Type' => "text/html; charset=utf-8",
@@ -374,7 +372,7 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
       'content' => $html,
     ));
   
-    $files = _mimemail_file();
+    $files = _messaging_htmlmail_file();
   
     return array_merge($document, $files);
   }
@@ -419,8 +417,8 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
 /**
  * Callback for preg_replace_callback()
  */
-function _mimemail_replace_files($matches) {
-  return stripslashes($matches[1]) . _mimemail_file($matches[2]) . stripslashes($matches[3]);
+function _messaging_htmlmail_replace_files($matches) {
+  return stripslashes($matches[1]) . _messaging_htmlmail_file($matches[2]) . stripslashes($matches[3]);
 }
 
 /**
@@ -430,12 +428,12 @@ function _mimemail_replace_files($matches) {
  *
  * @return an absolute :
  */
-function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
+function _messaging_htmlmail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
   static $files = array();
   static $filenames = array();
 
   if ($url) {
-    $url = _mimemail_url($url, 'TRUE');
+    $url = _messaging_htmlmail_url($url, 'TRUE');
 
     // If the $url is absolute, we're done here.
     if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
@@ -490,14 +488,14 @@ function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'rel
 /**
  * Callback for preg_replace_callback()
  */
-function _mimemail_expand_links($matches) {
-  return $matches[1] . _mimemail_url($matches[2]);
+function _messaging_htmlmail_expand_links($matches) {
+  return $matches[1] . _messaging_htmlmail_url($matches[2]);
 }
 
 /*
  * Split a multi-part message using mime boundaries
  */
-function mimemail_parse_boundary($part) {
+function messaging_htmlmail_parse_boundary($part) {
   $m = array();
   if (preg_match('/.*boundary="?([^";]+)"?.*/', $part['headers']['Content-Type'], $m)) {
     $boundary = "\n--". $m[1];
@@ -510,7 +508,7 @@ function mimemail_parse_boundary($part) {
 /*
  * Split a message (or message part) into its headers and body section
  */
-function mimemail_parse_headers($message) {
+function messaging_htmlmail_parse_headers($message) {
   // Split out body and headers
   if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $message, $match)) {
     list($hdr, $body) = array($match[1], $match[2]);
@@ -535,7 +533,7 @@ function mimemail_parse_headers($message) {
 /*
  * Return a decoded mime part in UTF8
  */
-function mimemail_parse_content($part) {
+function messaging_htmlmail_parse_content($part) {
   $content = $part['body'];
 
   // Decode this part
@@ -567,7 +565,7 @@ function mimemail_parse_content($part) {
 /*
  * Convert a mime part into a file array
  */
-function mimemail_parse_attachment($part) {
+function messaging_htmlmail_parse_attachment($part) {
   $m = array();
   if (preg_match('/.*filename="?([^";])"?.*/', $part['headers']['Content-Disposition'], $m)) {
     $name = $m[1];
@@ -579,7 +577,7 @@ function mimemail_parse_attachment($part) {
   return array(
     'filename' => $name,
     'filemime' => $part['content-type'],
-    'content'  => mimemail_parse_content($part),
+    'content'  => messaging_htmlmail_parse_content($part),
   );
 }
 
@@ -590,7 +588,7 @@ function mimemail_parse_attachment($part) {
  *
  * @return an absolute url, sans mailto:
  */
-function _mimemail_url($url, $embed_file = NULL) {
+function _messaging_htmlmail_url($url, $embed_file = NULL) {
   global $base_url;
   $url = urldecode($url);
 
-- 
1.7.4.4

