Fix determination of reply_type for logging purposes.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 6 Aug 2010 21:19:39 +0000 (15:19 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 6 Aug 2010 22:07:57 +0000 (16:07 -0600)
imp/lib/Compose.php

index d66f6af..4939120 100644 (file)
@@ -580,33 +580,37 @@ class IMP_Compose
         $sentmail = $GLOBALS['injector']->getInstance('IMP_Sentmail');
 
         /* Send the messages out now. */
+        if (!($reply_type = $this->getMetadata('reply_type'))) {
+            $reply_type = 'new';
+        }
+
         foreach ($send_msgs as $val) {
             try {
                 $this->sendMessage($val['to'], $headers, $val['msg']);
             } catch (IMP_Compose_Exception $e) {
                 /* Unsuccessful send. */
                 Horde::logMessage($e, 'ERR');
-                $sentmail->log($this->getMetadata('reply_type') || 'new', $headers->getValue('message-id'), $val['recipients'], false);
+                $sentmail->log($reply_type, $headers->getValue('message-id'), $val['recipients'], false);
                 throw new IMP_Compose_Exception(sprintf(_("There was an error sending your message: %s"), $e->getMessage()));
             }
 
             /* Store history information. */
-            $sentmail->log($this->getMetadata('reply_type') || 'new', $headers->getValue('message-id'), $val['recipients'], true);
+            $sentmail->log($reply_type, $headers->getValue('message-id'), $val['recipients'], true);
         }
 
         $sent_saved = true;
 
-        if ($this->getMetadata('reply_type')) {
+        if ($reply_type != 'new') {
             /* Log the reply. */
             if ($this->getMetadata('in_reply_to') &&
                 !empty($conf['maillog']['use_maillog'])) {
-                IMP_Maillog::log($this->getMetadata('reply_type'), $this->getMetadata('in_reply_to'), $recipients);
+                IMP_Maillog::log($reply_type, $this->getMetadata('in_reply_to'), $recipients);
             }
 
             $imp_message = $GLOBALS['injector']->getInstance('IMP_Message');
             $reply_uid = new IMP_Indices($this);
 
-            switch ($this->getMetadata('reply_type')) {
+            switch ($reply_type) {
             case 'forward':
                 /* Set the '$Forwarded' flag, if possible, in the mailbox.
                  * See RFC 5550 [5.9] */