format as attachment implemented
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 15 Aug 2002 14:17:05 +0000 (14:17 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 15 Aug 2002 14:17:05 +0000 (14:17 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3310 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/compose.php

index 6a21b57..b148710 100644 (file)
@@ -549,7 +549,11 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se
            }
           $body = getforwardHeader($orig_header) . $body;
           sqUnWordWrap($body);
-           getAttachments($message, $session, $passed_id, $entities, $imapConnection);      
+           getAttachments($message, $session, $passed_id, $entities, $imapConnection);
+          break;
+       case ('forward_as_attachment'):
+           getMessage_RFC822_Attachment($message, $session, $passed_id, $imapConnection);
+          $body = '';
           break;
         case ('reply_all'):
           $send_to_cc = replyAllString($orig_header);
@@ -656,6 +660,32 @@ function getAttachments($message, $session, $passed_id, $entities, $imapConnecti
     return;
 }
 
+function getMessage_RFC822_Attachment($message, $session, $passed_id, $imapConnection) {
+    global $attachments, $attachment_dir, $username, $data_dir, $uid_support;
+    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
+    $body_a = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, $uid_support);
+    if ($response = 'OK') {
+       $subject = encodeHeader($message->rfc822_header->subject);
+       array_shift($body_a);
+       $body = implode('', $body_a);
+       $body .= "\r\n";
+                       
+       $localfilename = GenerateRandomString(32, 'FILE', 7);
+       $full_localfilename = "$hashed_attachment_dir/$localfilename";
+               
+       $fp = fopen( $full_localfilename, 'w');
+       fwrite ($fp, $body);
+       fclose($fp);
+       $newAttachment = array();
+       $newAttachment['localfilename'] = $localfilename;
+       $newAttachment['type'] = "message/rfc822";
+       $newAttachment['remotefilename'] = $subject.'.eml';
+       $newAttachment['session'] = $session;
+       $attachments[] = $newAttachment;
+    }
+    return;
+}
+
 function showInputForm ($session, $values=false) {
     global $send_to, $send_to_cc, $body,
            $passed_body, $color, $use_signature, $signature, $prefix_sig,