oops, this error was already encoded, so back my r1.366 out, and part of
[squirrelmail.git] / src / read_body.php
index f3bb0fcd8460f0c5ec939387607637bd6b22d333..de7b9c43a480084b35c73b3166dc44351b0b4282 100644 (file)
@@ -3,12 +3,11 @@
 /**
  * read_body.php
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * 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
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  */
@@ -30,7 +29,7 @@ require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/identity.php');
 include_once(SM_PATH . 'functions/arrays.php');
-require_once(SM_PATH . 'functions/mailbox_display.php');
+include_once(SM_PATH . 'functions/mailbox_display.php');
 
 /**
  * Given an IMAP message id number, this will look it up in the cached
@@ -289,27 +288,6 @@ function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) {
                                 $readmessage, TRUE);
 }
 
-function ClearAttachments() {
-    global $username, $attachments, $attachment_dir;
-
-    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
-
-    $rem_attachments = array();
-    if (isset($attachments)) {
-        foreach ($attachments as $info) {
-            if ($info['session'] == -1) {
-                $attached_file = "$hashed_attachment_dir/$info[localfilename]";
-                if (file_exists($attached_file)) {
-                    unlink($attached_file);
-                }
-            } else {
-                $rem_attachments[] = $info;
-            }
-        }
-    }
-    $attachments = $rem_attachments;
-}
-
 function formatRecipientString($recipients, $item ) {
     global $show_more_cc, $show_more, $show_more_bcc,
            $PHP_SELF;
@@ -827,15 +805,57 @@ global $sqimap_capabilities, $lastTargetMailbox;
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
 
+
+/**
+ Start code to set the columns to fetch in case of hitting the next/prev link
+ The reason for this is the fact that the cache can be invalidated which means that the headers
+ to fetch aren't there anymore. Before they got calculated when the messagelist was shown.
+
+ Todo, better central handling of setting the mailbox options so we do not need to do the stuff below
+*/
+
 /**
-    * Check if cache is still valid, $what contains the key
-    * which gives us acces to the array with uid's. At this moment
-    * 0 is used for a normal message list and search uses 1 as key. This can be
-    * changed / extended in the future.
-    * If on a select of a mailbox we detect that the cache should be invalidated due to
-    * the delete of messages or due to new messages we empty the list with uid's and
-    * that's what we detect below.
-    */
+ * Replace From => To  in case it concerns a draft or sent folder
+ */
+if (($mailbox == $sent_folder || $mailbox == $draft_folder) &&
+    !in_array(SQM_COL_TO,$index_order)) {
+    $aNewOrder = array(); // nice var name ;)
+    foreach($index_order as $iCol) {
+        if ($iCol == SQM_COL_FROM) {
+            $iCol = SQM_COL_TO;
+        }
+        $aNewOrder[] = $iCol;
+   }
+   $aColumns = $aNewOrder;
+} else {
+   $aColumns = $index_order;
+}
+
+$aProps = array(
+    'columns' => $aColumns, // columns bound settings
+    'config'  => array(
+                        'highlight_list'        => $message_highlight_list, // row highlighting rules
+                        'trash_folder'          => $trash_folder,
+                        'sent_folder'           => $sent_folder,
+                        'draft_folder'          => $draft_folder));
+
+calcFetchColumns($aMailbox,$aProps);
+
+/**
+ End code to set the columns to fetch in case of hitting the next/prev link
+*/
+
+
+
+/**
+ * Check if cache is still valid, $what contains the key
+ * which gives us acces to the array with uid's. At this moment
+ * 0 is used for a normal message list and search uses 1 as key. This can be
+ * changed / extended in the future.
+ * If on a select of a mailbox we detect that the cache should be invalidated due to
+ * the delete of messages or due to new messages we empty the list with uid's and
+ * that's what we detect below.
+ */
 if (!is_array($aMailbox['UIDSET'][$what])) {
     fetchMessageHeaders($imapConnection, $aMailbox);
 }
@@ -913,7 +933,6 @@ if (isset($sendreceipt)) {
          $message->is_mdnsent = true;
          $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
       }
-      ClearAttachments();
    }
 }
 /***********************************************/
@@ -1011,4 +1030,4 @@ $mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
 sqsession_register($mailbox_cache,'mailbox_cache');
 
 ?>
-</body></html>
\ No newline at end of file
+</body></html>