Add compatibility with Dovecot's bigint UIDs
[squirrelmail.git] / plugins / message_details / message_details_bottom.php
index 25fc00906643dbc71ad41e2199418641dbf5fbf5..c4dcc8df1dbb226a472a6eeccd054db324d6320c 100644 (file)
@@ -7,12 +7,13 @@
  *
  * @author Marc Groot Koerkamp
  * @copyright © 2002 Marc Groot Koerkamp, The Netherlands
- * @copyright © 2002-2006 The SquirrelMail Project Team
+ * @copyright © 2002-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage message_details
  */
+//FIXME: this file uses HTML extensively and eventually needs to be "templatized" (don't echo HTML directly)
 
 /**
  * Include the SquirrelMail initialization file.
@@ -32,13 +33,16 @@ global $msgd_8bit_in_hex;
 $msgd_8bit_in_hex=false;
 
 if (!empty($md_action)) {
-    sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
+    sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
+    if (!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET))
+        $passed_ent_id = 0;
     sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
     /* 
-     * add third function argument, if you want to see 
+     * change $unformatted to TRUE if you want to see 
      * message source without formating
      */
-    echo get_message_details($mailbox, $passed_id);
+    $unformatted = FALSE;
+    echo get_message_details($mailbox, $passed_id, $passed_ent_id, $unformatted);
 }
 
 
@@ -100,20 +104,24 @@ function CalcEntity($entString, $direction) {
  * Returns actual message details
  * @param string $mailbox
  * @param string $passed_id
+ * @param string $passed_ent_id
  * @param boolean $stripHTML If TRUE, only plain text is returned,
  *                           default is FALSE, wherein output contains
  *                           pretty-HTMLification of message body
  * @return string The formatted message details
  * @access public
  */
-function get_message_details($mailbox, $passed_id, $stripHTML=FALSE) {
+function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=FALSE) {
     global $imapServerAddress, $imapPort, $color,$msgd_8bit_in_hex, $username;
 
     $returnValue = '';
 
     $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
     $read = sqimap_mailbox_select($imapConnection, $mailbox);
-    $body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, TRUE);
+    if (!empty($passed_ent_id))
+        $body = sqimap_run_command($imapConnection, "FETCH $passed_id BODY[$passed_ent_id]",true, $response, $readmessage, TRUE);
+    else
+        $body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, TRUE);
     $message_body = '';
     $header = false;
     $mimepart = false;
@@ -287,7 +295,6 @@ function get_message_details($mailbox, $passed_id, $stripHTML=FALSE) {
 $xtra = <<<ECHO
 
 <style type="text/css">
-
 <!--
 .ent_body {
   display:inline;
@@ -301,8 +308,7 @@ $xtra = <<<ECHO
   display:inline;
   width:99%;
 }
-//-->
-
+-->
 </style>
 
 ECHO;