From: Michael M Slusarz Date: Wed, 14 Jul 2010 00:42:34 +0000 (-0600) Subject: Remove (some) horde/Core dependencies in horde/Mime X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=808a4d46879f908e87cb97e2735ef5e9076105ea;p=horde.git Remove (some) horde/Core dependencies in horde/Mime --- diff --git a/framework/Mime/lib/Horde/Mime.php b/framework/Mime/lib/Horde/Mime.php index e21d8835d..a49410bd7 100644 --- a/framework/Mime/lib/Horde/Mime.php +++ b/framework/Mime/lib/Horde/Mime.php @@ -94,11 +94,8 @@ class Horde_Mime * @return string The text, encoded only if it contains non-ASCII * characters. */ - static public function encode($text, $charset = null) + static public function encode($text, $charset) { - if (is_null($charset)) { - $charset = $GLOBALS['registry']->getCharset(); - } $charset = Horde_String::lower($charset); if (($charset == 'us-ascii') || !self::is8bit($text, $charset)) { @@ -231,7 +228,7 @@ class Horde_Mime * characters. * @throws Horde_Mime_Exception */ - static public function encodeAddress($addresses, $charset = null, + static public function encodeAddress($addresses, $charset, $defserver = null) { if (!is_array($addresses)) { @@ -284,7 +281,7 @@ class Horde_Mime * * @return string The decoded text. */ - static public function decode($string, $to_charset = null) + static public function decode($string, $to_charset) { if (($pos = strpos($string, '=?')) === false) { return $string; @@ -321,10 +318,6 @@ class Horde_Mime $encoded_text = substr($search, 0, $end); $rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text) + 6)); - if (is_null($to_charset)) { - $to_charset = $GLOBALS['registry']->getCharset(); - } - switch ($encoding) { case 'Q': case 'q': diff --git a/framework/Mime/lib/Horde/Mime/Mdn.php b/framework/Mime/lib/Horde/Mime/Mdn.php index e5513d326..dd89bf6c0 100644 --- a/framework/Mime/lib/Horde/Mime/Mdn.php +++ b/framework/Mime/lib/Horde/Mime/Mdn.php @@ -30,9 +30,9 @@ class Horde_Mime_Mdn /** * Constructor. * - * @param Horde_Mime_Headers $mime_headers A Horde_Mime_Headers object. + * @param Horde_Mime_Headers $mime_headers A headers object. */ - public function __construct($headers = null) + public function __construct(Horde_Mime_Headers $headers) { $this->_headers = $headers; } @@ -45,7 +45,7 @@ class Horde_Mime_Mdn */ public function getMdnReturnAddr() { - /* RFC 3798 [2.1] requires the Disposition-Notificaion-To header + /* RFC 3798 [2.1] requires the Disposition-Notification-To header * for an MDN to be created. */ return $this->_headers->getValue('Disposition-Notification-To'); } @@ -126,6 +126,13 @@ class Horde_Mime_Mdn * * @param string $name The name of the local server. * @param Mail $mailer A Mail driver. + * @param array $opts Additional options: + *
+     * 'charset' - (string) Default charset.
+     *             DEFAULT: NONE
+     * 'from_addr' - (string) From address.
+     *               DEFAULT: NONE
+     * 
* @param array $mod The list of modifications. *
      * Per RFC 3798 [3.2.6.3] the following modifications are valid:
@@ -138,11 +145,13 @@ class Horde_Mime_Mdn
      * @throws Horde_Mime_Exception
      */
     public function generate($action, $sending, $type, $name, $mailer,
-                             $mod = array(), $err = array())
+                             array $opts = array(), array $mod = array(),
+                             array $err = array())
     {
-        /* Set up some variables we use later. */
-        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getIdentity();
-        $from_addr = $identity->getDefaultFromAddress();
+        $opts = array_merge(array(
+            'charset' => null,
+            'from_addr' => null
+        ), $opts);
 
         $to = $this->getMdnReturnAddr();
         $ua = $this->_headers->getUserAgent();
@@ -170,7 +179,9 @@ class Horde_Mime_Mdn
         $msg_headers->addMessageIdHeader();
         $msg_headers->addUserAgentHeader($ua);
         $msg_headers->addHeader('Date', date('r'));
-        $msg_headers->addHeader('From', $from_addr);
+        if ($opts['from_addr']) {
+            $msg_headers->addHeader('From', $opts['from_addr']);
+        }
         $msg_headers->addHeader('To', $this->getMdnReturnAddr());
         $msg_headers->addHeader('Subject', _("Disposition Notification"));
 
@@ -179,14 +190,12 @@ class Horde_Mime_Mdn
         $msg->setType('multipart/report');
         $msg->setContentTypeParameter('report-type', 'disposition-notification');
 
-        $charset = $GLOBALS['registry']->getCharset();
-
         /* The first part is a human readable message. */
         $part_one = new Horde_Mime_Part('text/plain');
-        $part_one->setCharset($charset);
+        $part_one->setCharset($opts['charset']);
         if ($type == 'displayed') {
             $contents = sprintf(_("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('Subject'));
-            $flowed = new Horde_Text_Flowed($contents, $charset);
+            $flowed = new Horde_Text_Flowed($contents, $opts['charset']);
             $flowed->setDelSp(true);
             $part_one->setContentTypeParameter('format', 'flowed');
             $part_one->setContentTypeParameter('DelSp', 'Yes');
@@ -201,7 +210,9 @@ class Horde_Mime_Mdn
         if (!empty($orig_recip)) {
             $part_two_text[] = 'Original-Recipient: rfc822;' . $orig_recip . "\n";
         }
-        $part_two_text[] = 'Final-Recipient: rfc822;' . $from_addr . "\n";
+        if ($opts['from_addr']) {
+            $part_two_text[] = 'Final-Recipient: rfc822;' . $from_addr . "\n";
+        }
         if (!empty($msg_id)) {
             $part_two_text[] = 'Original-Message-ID: rfc822;' . $msg_id . "\n";
         }
@@ -230,14 +241,12 @@ class Horde_Mime_Mdn
      * Add a MDN (read receipt) request headers to the Horde_Mime_Headers::
      * object.
      *
-     * @param Horde_Mime_Headers $ob   The object to add the headers to.
-     * @param string $to               The address the receipt should be
-     *                                 mailed to.
+     * @param string $to  The address the receipt should be mailed to.
      */
-    public function addMdnRequestHeaders($ob, $to)
+    public function addMdnRequestHeaders($to)
     {
         /* This is the RFC 3798 way of requesting a receipt. */
-        $ob->addHeader('Disposition-Notification-To', $to);
+        $this->_headers->addHeader('Disposition-Notification-To', $to);
     }
 
 }
diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php
index 277d6f589..069329240 100644
--- a/imp/lib/Compose.php
+++ b/imp/lib/Compose.php
@@ -533,8 +533,8 @@ class IMP_Compose
         $mdn = null;
         if (!empty($opts['readreceipt']) &&
             $conf['compose']['allow_receipts']) {
-            $mdn = new Horde_Mime_Mdn();
-            $mdn->addMDNRequestHeaders($headers, $barefrom);
+            $mdn = new Horde_Mime_Mdn($headers);
+            $mdn->addMdnRequestHeaders($barefrom);
         }
 
         $browser_charset = $GLOBALS['registry']->getCharset();
diff --git a/imp/lib/Ui/Message.php b/imp/lib/Ui/Message.php
index 112f75e42..c726cff31 100644
--- a/imp/lib/Ui/Message.php
+++ b/imp/lib/Ui/Message.php
@@ -79,7 +79,7 @@ class IMP_Ui_Message
 
         /* Check to see if an MDN has been requested. */
         $mdn = new Horde_Mime_Mdn($headers);
-        $return_addr = $mdn->getMDNReturnAddr();
+        $return_addr = $mdn->getMdnReturnAddr();
         if (!$return_addr) {
             return false;
         }
@@ -119,7 +119,17 @@ class IMP_Ui_Message
 
         /* Send out the MDN now. */
         try {
-            $mdn->generate(false, $confirmed, 'displayed', $GLOBALS['conf']['server']['name'], $GLOBALS['injector']->getInstance('IMP_Mail'));
+            $mdn->generate(
+                false,
+                $confirmed,
+                'displayed',
+                $GLOBALS['conf']['server']['name'],
+                $GLOBALS['injector']->getInstance('IMP_Mail'),
+                array(
+                    'charset' => $GLOBALS['registry']->getCharset(),
+                    'from_addr' => $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getIdentity()->getDefaultFromAddress()
+                )
+            );
             IMP_Maillog::log('mdn', $msg_id, 'displayed');
             $success = true;
 
diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php
index cbc71995c..2e8c9c2b2 100644
--- a/kronolith/lib/Kronolith.php
+++ b/kronolith/lib/Kronolith.php
@@ -2089,7 +2089,7 @@ class Kronolith
                     : $newAttendeeParsedPart->personal;
 
                 try {
-                    $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name));
+                    $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name), $GLOBALS['registry']->getCharset());
                     $newAttendeeParsedPartValidated = $parser->parseAddressList($newAttendeeParsedPartNew, array(
                         'default_domain' => null
                     ));