Correctly handle close_draft preference in all views
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 10 Dec 2009 21:04:38 +0000 (14:04 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 10 Dec 2009 21:10:07 +0000 (14:10 -0700)
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php

index 2fce2fd..6c7db28 100644 (file)
@@ -98,12 +98,13 @@ if (count($_POST)) {
                 $res = $imp_compose->saveDraft($header, Horde_Util::getFormData('message', ''), Horde_Nls::getCharset(), Horde_Util::getFormData('html'));
                 $result->success = 1;
 
-                $imp_compose->destroy();
-
                 if ($action == 'auto_save_draft') {
                     $notification->push(_("Draft automatically saved."), 'horde.message');
                 } else {
                     $notification->push($res);
+                    if ($prefs->getValue('close_draft')) {
+                        $imp_compose->destroy();
+                    }
                 }
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e, 'horde.error');
index 6f9248a..60943d1 100644 (file)
@@ -245,9 +245,11 @@ case _("Send"):
     case _("Save Draft"):
         try {
             $notification->push($imp_compose->saveDraft($header, $message, Horde_Nls::getCharset(), false), 'horde.success');
-            $imp_compose->destroy();
-            require IMP_BASE . '/mailbox-mimp.php';
-            exit;
+            if ($prefs->getValue('close_draft')) {
+                $imp_compose->destroy();
+                require IMP_BASE . '/mailbox-mimp.php';
+                exit;
+            }
         } catch (IMP_Compose_Exception $e) {
             $notification->push($e, 'horde.error');
         }
index 41c0686..7914783 100644 (file)
@@ -404,19 +404,21 @@ case 'send_message':
 
                 /* Closing draft if requested by preferences. */
                 if ($actionID == 'save_draft') {
-                    $imp_compose->destroy();
-
                     if ($isPopup) {
                         if ($prefs->getValue('close_draft')) {
+                            $imp_compose->destroy();
                             Horde_Util::closeWindowJS();
                             exit;
                         } else {
                             $notification->push($result, 'horde.success');
                         }
                     } else {
-                        $notification->push($result);
-                        header('Location: ' . _mailboxReturnURL(false));
-                        exit;
+                        $notification->push($result, 'horde.success');
+                        if ($prefs->getValue('close_draft')) {
+                            $imp_compose->destroy();
+                            header('Location: ' . _mailboxReturnURL(false));
+                            exit;
+                        }
                     }
                 }
             } catch (IMP_Compose_Exception $e) {