Eliminated an error when saving attachments for a draft.
[squirrelmail.git] / src / compose.php
index 4569883fd172dfb1f5fece4eb9fbfa75e50d8079..d3536cac8cc07121c5a7a762f97d30e1004cd46e 100644 (file)
@@ -1,18 +1,19 @@
 <?php
    /**
-    ** compose.php
-    **
-    **  Copyright (c) 1999-2000 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    ** This code sends a mail.
-    **
-    ** There are 3 modes of operation:
-    **  - Start new mail
-    **  - Add an attachment
-    **  - Send mail
-    **
-    ** $Id$
+    * compose.php
+    *
+    * Copyright (c) 1999-2000 The SquirrelMail development team
+    * Licensed under the GNU GPL. For full terms see the file COPYING.
+    *
+    * This code sends a mail.
+    *
+    * There are 4 modes of operation:
+    *    - Start new mail
+    *    - Add an attachment
+    *    - Send mail
+    *    - Save As Draft
+    *  
+    * $Id$
     **/
 
    require_once('../src/validate.php');
@@ -89,7 +90,9 @@
                     $body_ary[$i] = '> ' . $body_ary[$i];
                 }
             }
-            sqWordWrap($body_ary[$i], $editor_size - 1);
+            if (!$draft_id) {
+               sqWordWrap($body_ary[$i], $editor_size - 1);
+            }
             $body .= $body_ary[$i] . "\n";
             unset($body_ary[$i]);
          }
       do_hook("compose_form");
           echo ">\n";
 
-      if ( isset($draft_id))
+      if (isset($draft_id)) {
          echo "<input type=\"hidden\" name=\"delete_draft\" value=\"$draft_id\">\n";
+      }
 
       echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";
 
       }
       echo "\n    <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
 
-      if ($save_as_draft == true)
-         echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
-
+      if ($save_as_draft) {
+          echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
+      }
 
       do_hook("compose_button_row");
 
 
    if (isset($draft)) {
       require_once ('../src/draft_actions.php');
-      if(! saveMessagetoDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $$reply_id)) {
+      if (!saveMessageAsDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
          showInputForm();
          exit();
       } else {
-         Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1&note=Draft%20Email%20Saved");
-         exit();
+         $draft_message = _("Draft Email Saved");
+         /* If this is a resumed draft, then delete the original */
+         if(isset($delete_draft)) {
+            Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1");
+            exit();
+         } else {
+            Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1&note=$draft_message");
+            exit();
+         }
       }
    }
 
             exit();
          }
          if ( isset($delete_draft)) {
-            Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1"$
+            Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1");
             exit();
          }