phpdocumentor preparation and a few corrections to earlier phpdocumentor work
[squirrelmail.git] / src / read_body.php
index 3838988c724cedd2141b497c5486bbe6849fb6fe..254ab767844d51a57cb048b3d9aaff9c80026928 100644 (file)
  * the resulting emails in the right frame.
  *
  * $Id$
+ * @package squirrelmail
  */
 
-/* Path for SquirrelMail required files. */
+/** Path for SquirrelMail required files. */
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
@@ -25,6 +26,7 @@ require_once(SM_PATH . 'functions/url_parser.php');
 require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/identity.php');
+require_once(SM_PATH . 'functions/mailbox_display.php');
 
 /**
  * Given an IMAP message id number, this will look it up in the cached
@@ -168,6 +170,16 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
     $rfc822_header->to[] = $header->dnt;
     $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject);
 
+    // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
+    // This merely comes from compose.php and only happens when there is no
+    // email_addr specified in user's identity (which is the startup config)
+    if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
+       $popuser = $usernamedata[1];
+       $domain  = $usernamedata[2];
+       unset($usernamedata);
+    } else {
+       $popuser = $username;
+    }
 
     $reply_to = '';
     $ident = get_identities();
@@ -177,9 +189,9 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
     $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
     $reply_to  = $ident[$identity]['reply_to'];
 
-    if (!$from_addr) {
-       $from_addr = "$popuser@$domain";
-       $from_mail = $from_addr;
+    if (!$from_mail) {
+       $from_mail = "$popuser@$domain";
+       $from_addr = $from_mail;
     }
     $rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
     if ($reply_to) {
@@ -392,15 +404,15 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
 
     $header = $message->rfc822_header;
     $env = array();
-    $env[_("Subject")] = decodeHeader($header->subject);
+    $env[_("Subject")] = str_replace("&nbsp;"," ",decodeHeader($header->subject));
+
     $from_name = $header->getAddr_s('from');
-    if (!$from_name) {
+    if (!$from_name)
         $from_name = $header->getAddr_s('sender');
-        if (!$from_name) {
-            $from_name = _("Unknown sender");
-        }
-    }
-    $env[_("From")] = decodeHeader($from_name);
+    if (!$from_name)
+        $env[_("From")] = _("Unknown sender");
+    else
+        $env[_("From")] = decodeHeader($from_name);
     $env[_("Date")] = getLongDateString($header->date);
     $env[_("To")] = formatRecipientString($header->to, "to");
     $env[_("Cc")] = formatRecipientString($header->cc, "cc");
@@ -415,7 +427,7 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
         if ($mdn_user_support) {
             if ($header->dnt) {
                 if ($message->is_mdnsent) {
-                    $env[_("Read receipt")] = _("send");
+                    $env[_("Read receipt")] = _("sent");
                 } else {
                     $env[_("Read receipt")] = _("requested"); 
                     if (!(handleAsSent($mailbox) || 
@@ -453,7 +465,7 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
         }
     }
     echo '<TABLE BGCOLOR="'.$color[9].'" WIDTH="100%" CELLPADDING="1"'.
-         ' CELLSPACING="0" BORDER="0" ALIIGN="center">'."\n";
+         ' CELLSPACING="0" BORDER="0" ALIGN="center">'."\n";
     echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.
           $color[4].'"></TD></TR><TR><TD align=center>'."\n";
     echo $s;
@@ -730,16 +742,11 @@ do_hook('html_top');
 
 if (isset($sendreceipt)) {
    if ( !$message->is_mdnsent ) {
-      if (isset($identity) ) {
-         $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
-      } else {
-         $final_recipient = getPref($data_dir, $username, 'email_address', '' );
-      }
-
-      $final_recipient = trim($final_recipient);
-      if ($final_recipient == '' ) {
-         $final_recipient = getPref($data_dir, $username, 'email_address', '' );
-      }
+      $final_recipient = '';
+      if ((isset($identity)) && ($identity != 0))      //Main identity
+         $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
+      if ($final_recipient == '' )
+         $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
       $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
       if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
          ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);