Incorrect columns were passed through calcfetchColumns with as result the
[squirrelmail.git] / src / read_body.php
index eeb8d8c043c1eab1a3557069cb83b6efd14247bf..dd379b2bf6bf5445540118a038a088367bea5150 100644 (file)
@@ -6,7 +6,7 @@
  * This file is used for reading the msgs array and displaying
  * the resulting emails in the right frame.
  *
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
+include_once(SM_PATH . 'include/validate.php');
+//require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'functions/mime.php');
 require_once(SM_PATH . 'functions/date.php');
 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/global.php');
 require_once(SM_PATH . 'functions/identity.php');
 include_once(SM_PATH . 'functions/arrays.php');
 include_once(SM_PATH . 'functions/mailbox_display.php');
@@ -80,7 +80,7 @@ function findPreviousMessage($uidset, $passed_id) {
  * @param int $passed_id
  */
 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
-    global $javascript_on;
+    global $javascript_on, $show_html_default;
 
     /* hackydiehack */
     if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
@@ -90,15 +90,16 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
     }
     $params = '?passed_ent_id=' . urlencode($passed_ent_id) .
               '&mailbox=' . urlencode($mailbox) .
-              '&passed_id=' . urlencode($passed_id).
-              '&view_unsafe_images='. (bool) $view_unsafe_images;
+              '&passed_id=' . urlencode($passed_id) .
+              '&view_unsafe_images='. (bool) $view_unsafe_images .
+              '&show_html_default=' . $show_html_default;
 
     $print_text = _("View Printable Version");
 
     $result = '';
     /* Output the link. */
     if ($javascript_on) {
-        $result = '<script language="javascript" type="text/javascript">' . "\n" .
+        $result = '<script type="text/javascript">' . "\n" .
                   '<!--' . "\n" .
                   "  function printFormat() {\n" .
                   '    window.open("../src/printer_friendly_main.php' .
@@ -262,9 +263,12 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
         $success = $deliver->finalizeStream($stream);
     }
     if (!$success) {
-        $msg  = htmlspecialchars($deliver->dlv_msg) . '<br />' .
-                _("Server replied:") . ' ' . htmlspecialchars($deliver->dlv_ret_nr . ' ' .
-                $deliver->dlv_server_msg);
+        $msg = $deliver->dlv_msg;
+        if (! empty($deliver->dlv_server_msg)) {
+            $msg.= '<br />' .
+                _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
+                nl2br(htmlspecialchars($deliver->dlv_server_msg));
+        }
         require_once(SM_PATH . 'functions/display_messages.php');
         plain_error_message($msg, $color);
     } else {
@@ -382,7 +386,7 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
                           $passed_ent_id)) {
                         $mdn_url = $PHP_SELF . '&sendreceipt=1';
                         if ($FirstTimeSee && $javascript_on) {
-                            $script  = '<script language="JavaScript" type="text/javascript">' . "\n";
+                            $script  = '<script type="text/javascript">' . "\n";
                             $script .= '<!--'. "\n";
                             $script .= 'if(window.confirm("' .
                                        _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
@@ -677,7 +681,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
 }
 
 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
-    global $base_uri, $where, $what;
+    global $base_uri, $where, $what, $download_and_unsafe_link;
 
     $urlMailbox = urlencode($mailbox);
     $urlPassed_id = urlencode($passed_id);
@@ -704,6 +708,12 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
     $s .= '&nbsp;|&nbsp;' .
           printer_friendly_link($mailbox, $passed_id, $passed_ent_id);
     echo $s;
+
+    /* Output the download and/or unsafe images link/-s, if any. */
+    if ($download_and_unsafe_link) {
+       echo $download_and_unsafe_link;
+    }
+
     do_hook("read_body_header_right");
     $s = "</small></td>\n" .
          "</tr>\n";
@@ -817,6 +827,7 @@ $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('s
 /**
  * Replace From => To  in case it concerns a draft or sent folder
  */
+$aColumns = array();
 if (($mailbox == $sent_folder || $mailbox == $draft_folder) &&
     !in_array(SQM_COL_TO,$index_order)) {
     $aNewOrder = array(); // nice var name ;)
@@ -824,11 +835,12 @@ if (($mailbox == $sent_folder || $mailbox == $draft_folder) &&
         if ($iCol == SQM_COL_FROM) {
             $iCol = SQM_COL_TO;
         }
-        $aNewOrder[] = $iCol;
+        $aColumns[$iCol] = array();
    }
-   $aColumns = $aNewOrder;
 } else {
-   $aColumns = $index_order;
+   foreach ($index_order as $iCol) {
+       $aColumns[$iCol] = array();
+   }
 }
 
 $aProps = array(
@@ -913,8 +925,6 @@ if (isset($passed_ent_id) && $passed_ent_id) {
 }
 $header = $message->header;
 
-$header = $message->header;
-
 
 /****************************************/
 /* Block for handling incoming url vars */
@@ -1028,6 +1038,5 @@ sqimap_logout($imapConnection);
  */
 $mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
 sqsession_register($mailbox_cache,'mailbox_cache');
-
-?>
-</body></html>
+$oTemplate->display('footer.tpl');
+?>
\ No newline at end of file