formatting and added forward as attachment link
[squirrelmail.git] / src / read_body.php
index 38efa9fad49776535b9008fc2b2f0e519c4d01f8..10b5d65da5a54146f338ccf4fb95c594a12f1ee8 100644 (file)
@@ -163,7 +163,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message) {
     global $username, $attachment_dir, $SERVER_NAME,
            $version, $attachments;
 
-    $header = $message->header;
+    $header = $message->rfc822_header;
     $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
     
     $recipient_o = $header->dnt;
@@ -311,15 +311,16 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
   global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
          $default_use_priority, $show_xmailer_default, 
         $mdn_user_support, $PHP_SELF, $javascript_on;
-  
-   $header = $message->header;
+
+   $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = htmlspecialchars($header->subject);   
-   $from_o = $header->from;
-   if (is_object($from_o)) {
-       $from_name = $from_o->getAddress();
-   } else {
-       $from_name = _("Unknown sender");
+   $from_name = $header->getAddr_s('from');
+   if (!$from_name) {
+     $from_name = $header->getAddr_s('sender');
+     if (!$from_name) {
+         $from_name = _("Unknown sender");
+     }
    }
    $env[_("From")] = htmlspecialchars($from_name);
    $env[_("Date")] = getLongDateString($header->date);
@@ -363,18 +364,21 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
       }                 
    }
 
-   $s = '<table width="100%" cellpadding="0" cellspacing="0" border="0" ' .
-        'align="center">';
+/* BOOKMARK */
+   $s  = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
+   $s .=       ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
    foreach ($env as $key => $val) {
      if ($val) {      
-        $s .= '<tr>';
-        $s .=  html_tag( 'td', '<b>'.$key.':&nbsp;&nbsp;</b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
-        $s .=  html_tag( 'td', $val, 'left', $color[0], 'valign="top" width="80%"');
-        $s .=  "\n</tr>";
+        $s .= '<TR>';
+        $s .=   html_tag('TD', '<B>' . $key . ':&nbsp;&nbsp;</B>', 'RIGHT', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
+        $s .=   html_tag('TD', $val, 'left', '', 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
+        $s .= '</TR>';
      }
    }
-   $s .= '</table>';
    echo $s;
+   do_hook("read_body_header");   
+   formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
+   echo '</table>';
 }           
 
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
@@ -467,8 +471,7 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
       }
    }      
 
-   $s .= '</small></td><td align="right" width="33%"><small>';
-
+   $s .= '</small></td><td align="right" width="33%" nowrap><small>';
    $comp_action_uri = $comp_uri . '&amp;action=forward';
    if ($compose_new_win == '1') {
       $s .= '<a href="javascript:void(0)" '. 
@@ -478,6 +481,17 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
    }
    $s .= $topbar_delimiter;
 
+   $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
+   if ($compose_new_win == '1') {
+      $s .= '<a href="javascript:void(0)" '. 
+            'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as attachment").'</a>';
+   } else {
+      $s .= '<a href="'.$comp_action_uri.'">'._("Forward as attachment").'</a>';
+   }
+   $s .= $topbar_delimiter;
+
+
+
    $comp_action_uri = decodeHeader($comp_uri . '&amp;action=reply');
    if ($compose_new_win == '1') {
       $s .= '<a href="javascript:void(0)" '. 
@@ -502,18 +516,24 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
    global $QUERY_STRING, $base_uri;
    
    $urlMailbox = urlencode($mailbox);
-   $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
-         ' border="0" bgcolor="'.$color[9].'">'. "\n".
-        '<tr align="right"><td valign="top" align="right"><small>';
    $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
+
+/* BOOKMARK */
+   $s  = "<TR>\n";
+   $s .= '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Other") . ":&nbsp;&nbsp;</B></TD>\n";
+   $s .= '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>';
    $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
-  /* Output the printer friendly link if we are in subtle mode. */
-   $s .= '&nbsp;|&nbsp;'. 
-         printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+
+   /* Output the printer friendly link if we are in subtle mode. */
+   $s .= '&nbsp;|&nbsp;';
+   $s .= printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
    echo $s;
    do_hook("read_body_header_right");
-   echo '</small></td></tr>';
-   echo '</table>'."\n";
+   $s = "</SMALL></TD>\n";   
+   $s .= "</TR>\n";
+   echo $s;
+
+
 }
 
 
@@ -557,8 +577,8 @@ if (!isset($messages[$uidvalidity][$passed_id]) || !$uid_support) {
    $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
    $messages[$uidvalidity][$passed_id] = $message;
 } else {
-//   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-   $message = $messages[$uidvalidity][$passed_id];
+   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+//   $message = $messages[$uidvalidity][$passed_id];
 }
 $FirstTimeSee = !$message->is_seen;
 $message->is_seen = true;
@@ -611,23 +631,46 @@ $msgs[$passed_id]['FLAG_SEEN'] = true;
  
 $messagebody = ''; 
 $ent_ar = $message->findDisplayEntity(array());
-for ($i = 0; $i < count($ent_ar); $i++) {
+$cnt = count($ent_ar);
+for ($i = 0; $i < $cnt; $i++) {
    $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
-   $messagebody .= '<hr noshade size=1>';
+   if ($i != $cnt-1) {
+       $messagebody .= '<hr noshade size=1>';
+   }
 }
 
 displayPageHeader($color, $mailbox);
 do_hook('read_body_top');
 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
-do_hook("read_body_header");   
-formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
-echo '<table width="100%" cellpadding="3" cellspacing="3" align="center"'.
-      ' border="0" bgcolor="'.$color[4].'">';
-echo '<tr><td>'.$messagebody.'</td></tr>';      
-echo '<tr><td>'.formatAttachments($message,$ent_ar,$mailbox, $passed_id).'</td></tr>';      
+echo '<table width="100%" cellpadding="0" cellspacing="5" align="center" border="0">';
+echo '   <tr><td>';
+echo '   <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
+echo '      <tr><td>';
+echo '      <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
+echo '          <tr bgcolor="'.$color[4].'"><td>'.$messagebody. '</td></tr>';      
+echo '      </table></td></tr>';
+echo '   </table>';
+echo '   </td></tr>';
+
+$attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
+if ($attachmentsdisplay) {
+   echo '   <tr><td>';
+   echo '   <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
+   echo '      <tr><td>';
+   echo '      <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
+   echo '         <tr><td ALIGN="left" bgcolor="'.$color[9].'">';// colspan="5"><b>';
+   echo           _("Attachments").':</b></td></tr><tr><td>';
+   echo '          <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[12].'">';
+   echo             $attachmentsdisplay;
+   echo '         </td></tr></table></table></td></tr>';
+   echo '      </table></td></tr>';
+   echo '   </table>';
+   echo '   </td></tr>';
+}
 echo '</table>';
 
+
 /* show attached images inline -- if pref'fed so */
 if (($attachment_common_show_images) &&
     is_array($attachment_common_show_images_list)) {