Juergen Edner
[squirrelmail.git] / src / printer_friendly_bottom.php
index 2f0839d8a0ecbe5172f54ca89341d65bc24291b8..b1b6274fa586443121830e1690f0413f3db26968 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * printer_friendly_bottom.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * with javascript on, it is the bottom frame of printer_friendly_main.php
@@ -31,21 +31,28 @@ $key = $_COOKIE['key'];
 $username = $_SESSION['username'];
 $onetimepad = $_SESSION['onetimepad'];
 
-$passed_ent_id = $_GET['passed_ent_id'];
-$passed_id = $_GET['passed_id'];
+$passed_id = (int) $_GET['passed_id'];
 $mailbox = $_GET['mailbox'];
+
+if (!isset($_GET['passed_ent_id'])) {
+    $passed_ent_id = '';
+} else {
+    $passed_ent_id = $_GET['passed_ent_id'];
+}
 /* end globals */
 
 $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay');
 $mailbox = urldecode($mailbox);
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-sqimap_mailbox_select($imapConnection, $mailbox);
-$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-$id = $passed_id;
-if (isset($passed_ent_id)) {
-   $message = $message->getEntity($passed_ent_id);
+$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
+if (isset($messages[$mbx_response['UIDVALIDITY']][$passed_id])) {
+    $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
+} else {
+    $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+}
+if ($passed_ent_id) {
+    $message = &$message->getEntity($passed_ent_id);
 }
-
 
 /* --start display setup-- */
 
@@ -68,7 +75,7 @@ $body = '';
 if ($ent_ar[0] != '') {
   for ($i = 0; $i < count($ent_ar); $i++) {
      $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
-     $body .= '<hr noshade size=1>';
+     $body .= '<hr noshade size="1" />';
   }
   $hookResults = do_hook('message_body', $body);
   $body = $hookResults[1];
@@ -131,7 +138,7 @@ echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"
      }
      /* body */
      echo html_tag( 'tr',
-         html_tag( 'td', '<hr noshade size=1><br>' . "\n" . $body, 'left', '', 'colspan="2"' )
+         html_tag( 'td', '<hr noshade size="1" /><br>' . "\n" . $body, 'left', '', 'colspan="2"' )
      ) . "\n" .
 
      '</table>' . "\n" .