* modifications for using ent_id=0 for downloading full messages
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 14 Jan 2003 16:07:26 +0000 (16:07 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 14 Jan 2003 16:07:26 +0000 (16:07 +0000)
* patch from Seth E. Randall for setting the filename of the mime-entities

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4418 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/download.php

index 28fe5c8..1be2b9e 100644 (file)
@@ -50,18 +50,26 @@ if (!is_object($message)) {
     $message = sqimap_get_message($imapConnection,$passed_id, $mailbox);
 }
 $subject = $message->rfc822_header->subject;
-$message = &$message->getEntity($ent_id);
-$header = $message->header;
-if ($message->rfc822_header) {
-   $subject = $message->rfc822_header->subject;
-   $charset = $header->content_type->properties['charset'];
+if ($ent_id) {
+    $message = &$message->getEntity($ent_id);
+    $header = $message->header;
+    
+    if ($message->rfc822_header) {
+       $subject = $message->rfc822_header->subject;
+       $charset = $header->content_type->properties['charset'];
+    } else {
+       $header = $message->header;
+       $charset = $header->getParameter('charset');
+    }
+    $type0 = $header->type0;
+    $type1 = $header->type1;
+    $encoding = strtolower($header->encoding);
 } else {
-   $header = $message->header;
-   $charset = $header->getParameter('charset');
+    /* raw message */
+    $type0 = 'message';
+    $type1 = 'rfc822';
+    $encoding = "US-ASCII";
 }
-$type0 = $header->type0;
-$type1 = $header->type1;
-$encoding = strtolower($header->encoding);
 
 /*
  * lets redefine message as this particular entity that we wish to display.
@@ -81,6 +89,9 @@ if (is_object($message->header->disposition)) {
     if (!$filename) {
        $filename = decodeHeader($header->disposition->getProperty('name'));
     }
+    if (!$filename) {
+        $filename = decodeHeader($header->getParameter('name'));
+    }    
 }
 if (strlen($filename) < 1) {
     if ($type1 == 'plain' && $type0 == 'text') {