Fix for Ticket #4221.
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 8 Dec 2008 06:44:51 +0000 (23:44 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 8 Dec 2008 06:44:51 +0000 (23:44 -0700)
Fix stripping attachments when saving to sent-mail folder when attaching
the PGP public key.

imp/docs/CHANGES
imp/lib/Compose.php

index c3475cf..d7061f0 100644 (file)
@@ -2,6 +2,8 @@
 v5.0-cvs
 --------
 
+[mms] Fix stripping attachments when saving to sent-mail folder when attaching
+      the PGP public key (Bug #4221).
 [mms] Removed Special Characters menu.
 [mms] Add 'undelete' to Other Actions menu (Bug #7496) (DIMP).
 [mms] PGP functions now work in DIMP (Bug #5388).
index edb6bfa..6f44368 100644 (file)
@@ -556,15 +556,17 @@ class IMP_Compose
             if (($save_attach == 'never') ||
                 ((strpos($save_attach, 'prompt') === 0) &&
                  empty($opts['save_attachments']))) {
-                foreach (array_keys($this->getAttachments()) as $i) {
-                    $oldPart = $mime_message->getPart(++$i);
-                    if ($oldPart !== false) {
-                        $replace_part = new Horde_Mime_Part();
-                        $replace_part->setType('text/plain');
-                        $replace_part->setCharset($charset);
-                        $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit');
-                        $mime_message->alterPart($i, $replace_part);
+                $mime_message->buildMimeIds();
+                for ($i = 2; ; ++$i) {
+                    if (!($oldPart = $mime_message->getPart($i))) {
+                        break;
                     }
+
+                    $replace_part = new Horde_Mime_Part();
+                    $replace_part->setType('text/plain');
+                    $replace_part->setCharset($charset);
+                    $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit');
+                    $mime_message->alterPart($i, $replace_part);
                 }
             }