Replacing tabs with spaces, trimming white space at EOL and newline at EOF
[squirrelmail.git] / class / mime / Message.class.php
index 1480534f8d05ffd60be3711a544a3a4303f93e30..fbfbd3b5dcab22f3557ac70d94e21ca27a341b47 100644 (file)
@@ -3,20 +3,25 @@
 /**
  * Message.class.php
  *
- * Copyright (c) 2003 The SquirrelMail Project Team
+ * Copyright (c) 2003-2004 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
-  This contains functions needed to handle mime messages.
* This contains functions needed to handle mime messages.
  *
- * $Id$
+ * @version $Id$
+ * @package squirrelmail
  */
 
+/**
+ * The object that contains a message
+ *
+ * message is the object that contains messages.  It is a recursive
+ * object in that through the $entities variable, it can contain
+ * more objects of type message.  See documentation in mime.txt for
+ * a better description of how this works.
+ * @package squirrelmail
+ */
 class Message {
-    /** message is the object that contains messages.  It is a recursive
-        object in that through the $entities variable, it can contain
-        more objects of type message.  See documentation in mime.txt for
-        a better description of how this works.
-    **/
     var $rfc822_header = '',
         $mime_header = '',
         $flags = '',
@@ -43,7 +48,6 @@ class Message {
     }
 
     function getFilename() {
-        $filename = '';
         $filename = $this->header->getParameter('filename');
         if (!$filename) {
             $filename = $this->header->getParameter('name');
@@ -70,7 +74,7 @@ class Message {
             $cur_ent_a = explode('.', $this->entity_id);
         }
         $ent_a = explode('.', $ent);
-        
+
         for ($i = 0,$entCount = count($ent_a) - 1; $i < $entCount; ++$i) {
             if (isset($cur_ent_a[$i]) && ($cur_ent_a[$i] != $ent_a[$i])) {
                 $msg = $msg->parent;
@@ -141,12 +145,12 @@ class Message {
         if($msg) $msg->setEntIds($msg,false,0);
         return $msg;
     }
-    
+
     function setEntIds(&$msg,$init=false,$i=0) {
         $iCnt = count($msg->entities);
         if ($init !==false) {
             $iEntSub = $i+1;
-            if ($msg->parent->type0 == 'message' && 
+            if ($msg->parent->type0 == 'message' &&
                 $msg->parent->type1 == 'rfc822' &&
                 $msg->type0 == 'multipart') {
                 $iEntSub = '0';
@@ -162,8 +166,8 @@ class Message {
             $msg->entity_id='1';
         }
         for ($i=0;$i<$iCnt;++$i) {
-            $msg->entities[$i]->parent =& $msg;    
-            if (strrchr($msg->entity_id, '.') != '.0') {    
+            $msg->entities[$i]->parent =& $msg;
+            if (strrchr($msg->entity_id, '.') != '.0') {
                 $msg->entities[$i]->setEntIds($msg->entities[$i],$msg->entity_id,$i);
             } else {
                 $msg->entities[$i]->setEntIds($msg->entities[$i],$msg->parent->entity_id,$i);
@@ -179,7 +183,7 @@ class Message {
         } else {
             $message = new Message();
         }
-        $this = $message;    
+
         for ($cnt = strlen($read); $i < $cnt; ++$i) {
             $char = strtoupper($read{$i});
             switch ($char) {
@@ -196,29 +200,29 @@ class Message {
                                 $msg->header->type0 = 'multipart';
                                 $msg->type0 = 'multipart';
                                 while ($read{$i} == '(') {
-                                    $msg->addEntity($this->parseBodyStructure($read, $i, $msg));
+                                    $msg->addEntity($msg->parseBodyStructure($read, $i, $msg));
                                 }
                             }
                             break;
                         case 1:
                             /* multipart properties */
                             ++$i;
-                            $arg_a[] = $this->parseProperties($read, $i);
+                            $arg_a[] = $msg->parseProperties($read, $i);
                             ++$arg_no;
                             break;
                         case 2:
                             if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
                                 ++$i;
-                                $arg_a[] = $this->parseDisposition($read, $i);
+                                $arg_a[] = $msg->parseDisposition($read, $i);
                             } else { /* properties */
-                                $arg_a[] = $this->parseProperties($read, $i);
+                                $arg_a[] = $msg->parseProperties($read, $i);
                             }
                             ++$arg_no;
                             break;
                         case 3:
                             if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
                                 ++$i;
-                                $arg_a[]= $this->parseLanguage($read, $i);
+                                $arg_a[]= $msg->parseLanguage($read, $i);
                             }
                         case 7:
                             if (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822')) {
@@ -227,40 +231,40 @@ class Message {
                                 $msg->type0 = $arg_a[0];
                                 $msg->type1 = $arg_a[1];
                                 $rfc822_hdr = new Rfc822Header();
-                                $msg->rfc822_header = $this->parseEnvelope($read, $i, $rfc822_hdr);
+                                $msg->rfc822_header = $msg->parseEnvelope($read, $i, $rfc822_hdr);
                                 while (($i < $cnt) && ($read{$i} != '(')) {
                                     ++$i;
                                 }
-                                $msg->addEntity($this->parseBodyStructure($read, $i,$msg));
+                                $msg->addEntity($msg->parseBodyStructure($read, $i,$msg));
                             }
                             break;
                         case 8:
                             ++$i;
-                            $arg_a[] = $this->parseDisposition($read, $i);
+                            $arg_a[] = $msg->parseDisposition($read, $i);
                             ++$arg_no;
                             break;
                         case 9:
                             ++$i;
                             if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
-                                $arg_a[] = $this->parseDisposition($read, $i);
+                                $arg_a[] = $msg->parseDisposition($read, $i);
                             } else {
-                                $arg_a[] = $this->parseLanguage($read, $i);
+                                $arg_a[] = $msg->parseLanguage($read, $i);
                             }
                             ++$arg_no;
                             break;
                        case 10:
                            if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
                                ++$i;
-                               $arg_a[] = $this->parseLanguage($read, $i);
+                               $arg_a[] = $msg->parseLanguage($read, $i);
                            } else {
-                               $i = $this->parseParenthesis($read, $i);
+                               $i = $msg->parseParenthesis($read, $i);
                                $arg_a[] = ''; /* not yet described in rfc2060 */
                            }
                            ++$arg_no;
                            break;
                        default:
                            /* unknown argument, skip this part */
-                           $i = $this->parseParenthesis($read, $i);
+                           $i = $msg->parseParenthesis($read, $i);
                            $arg_a[] = '';
                            ++$arg_no;
                            break;
@@ -268,7 +272,7 @@ class Message {
                    break;
                 case '"':
                     /* inside an entity -> start processing */
-                    $arg_s = $this->parseQuote($read, $i);
+                    $arg_s = $msg->parseQuote($read, $i);
                     ++$arg_no;
                     if ($arg_no < 3) {
                         $arg_s = strtolower($arg_s); /* type0 and type1 */
@@ -287,10 +291,10 @@ class Message {
                     break;
                 case '{':
                     /* process the literal value */
-                    $arg_a[] = $this->parseLiteral($read, $i);
+                    $arg_a[] = $msg->parseLiteral($read, $i);
                     ++$arg_no;
                     break;
-        case '0':    
+        case '0':
                 case is_numeric($read{$i}):
                     /* process integers */
                     if ($read{$i} == ' ') { break; }
@@ -438,7 +442,7 @@ class Message {
         if (count($arg_a) > 9) {
             $d = strtr($arg_a[0], array('  ' => ' '));
             $d = explode(' ', $d);
-        if (!$arg_a[1]) $arg_1[1] = _("(no subject)");        
+        if (!$arg_a[1]) $arg_a[1] = _("(no subject)");
 
             $hdr->date = getTimeStamp($d); /* argument 1: date */
             $hdr->subject = $arg_a[1];     /* argument 2: subject */
@@ -687,7 +691,7 @@ class Message {
 //        $alt_order[] = "message/rfc822";
             foreach ($alt_order as $alt) {
                 if( ($alt == $type) && isset($this->entity_id) ) {
-                    if ((count($this->entities) == 0) && 
+                    if ((count($this->entities) == 0) &&
                 (!isset($ent->header->parameters['filename'])) &&
                 (!isset($ent->header->parameters['name'])) &&
                         (strtolower($this->header->disposition->name) != 'attachment')) {
@@ -761,7 +765,7 @@ class Message {
 
     function getAttachments($exclude_id=array(), $result = array()) {
 /*
-        if (($this->type0 == 'message') && 
+        if (($this->type0 == 'message') &&
         ($this->type1 == 'rfc822') &&
         ($this->entity_id) ) {
             $this = $this->entities[0];
@@ -797,7 +801,7 @@ class Message {
         }
         return $result;
     }
-    
+
     function initAttachment($type, $name, $location) {
         $attachment = new Message();
         $mime_header = new MessageHeader();
@@ -818,4 +822,4 @@ class Message {
     }
 }
 
-?>
+?>
\ No newline at end of file