Added functionality to save an email as draft.
authorfallas <fallas@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 28 Oct 2001 11:15:56 +0000 (11:15 +0000)
committerfallas <fallas@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 28 Oct 2001 11:15:56 +0000 (11:15 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1634 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/compose.php

index ae21388..4569883 100644 (file)
@@ -33,7 +33,8 @@
    // This function is used when not sending or adding attachments
    function newMail () {
       global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
-             $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size;
+             $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size,
+             $draft_id, $use_signature;
 
       $send_to = decodeHeader($send_to);
       $send_to_cc = decodeHeader($send_to_cc);
       elseif ($reply_id)
          $id = $reply_id;
 
+      if ($draft_id){
+         $id = $draft_id;
+         $use_signature = FALSE;
+      }
 
       if (isset($id)) {
          sqimap_mailbox_select($imapConnection, $mailbox);
@@ -73,7 +78,7 @@
          }
          $body = "";
          for ($i=0; isset($body_ary[$i]); $i++) {
-            if (! $forward_id)
+            if ($reply_id)
             {
                 if (ereg('^[ >]+', $body_ary[$i]))
                 {
 
    function getAttachments($message) {
       global $mailbox, $attachments, $attachment_dir, $imapConnection,
-             $ent_num, $forward_id;
+             $ent_num, $forward_id, $draft_id;
+     if (isset($draft_id))
+         $id = $draft_id;
+      else
+         $id = $forward_id;
 
       if (!$message) {
            sqimap_mailbox_select($imapConnection, $mailbox);
-           $message = sqimap_get_message($imapConnection, $forward_id,
+           $message = sqimap_get_message($imapConnection, $id,
                $mailbox);
       }
 
               // Write Attachment to file
               $fp = fopen ($attachment_dir.$localfilename, 'w');
               fputs ($fp, decodeBody(mime_fetch_body($imapConnection,
-                  $forward_id, $message->header->entity_id),
+                  $id, $message->header->entity_id),
                   $message->header->encoding));
               fclose ($fp);
 
          $editor_size, $attachments, $subject, $newmail,
          $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
          $from_htmladdr_search, $location_of_buttons, $attachment_dir,
-         $username, $data_dir, $identity;
+         $username, $data_dir, $identity, $draft_id;
 
       $subject = decodeHeader($subject);
       $reply_subj = decodeHeader($reply_subj);
       do_hook("compose_form");
           echo ">\n";
 
+      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";
 
       if ($location_of_buttons == 'top') showComposeButtonRow();
    }
 
    function showComposeButtonRow() {
-      global $use_javascript_addr_book;
+      global $use_javascript_addr_book, $save_as_draft;
 
       echo "   <TR><td>\n   </td><td>\n";
       if ($use_javascript_addr_book) {
       }
       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";
+
+
       do_hook("compose_button_row");
 
       echo "   </TD>\n";
    if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None"))
       $mailbox = "INBOX";
 
+   if (isset($draft)) {
+      require_once ('../src/draft_actions.php');
+      if(! saveMessagetoDraft($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();
+      }
+   }
+
    if (isset($send)) {
       if (isset($HTTP_POST_FILES['attachfile']) &&
           $HTTP_POST_FILES['attachfile']['tmp_name'] &&
             showInputForm();
             exit();
          }
+         if ( isset($delete_draft)) {
+            Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1"$
+            exit();
+         }
+         
          Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
          //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
       if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num)
           getAttachments(0);
 
+      if (isset($draft_id) && $draft_id && isset($ent_num) && $ent_num)
+          getAttachments(0);
+
       newMail();
       showInputForm();
       sqimap_logout($imapConnection);
       /* Build and return the citation string. */
       return ($start . $orig_from . $end . "\n");
    }
-?>
\ No newline at end of file
+?>