Juergen Edner
[squirrelmail.git] / src / printer_friendly_bottom.php
index bbab3b79e31c6d5c0881bb0c9085a5aaf16afc48..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
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
-require_once(SM_PATH . 'src/validate.php');
+require_once(SM_PATH . 'include/validate.php');
 require_once(SM_PATH . 'functions/strings.php');
 require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'src/load_prefs.php');
+require_once(SM_PATH . 'include/load_prefs.php');
 require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'functions/page_header.php');
 require_once(SM_PATH . 'functions/html.php');
 
+/* get some of these globals */
+$key = $_COOKIE['key'];
+$username = $_SESSION['username'];
+$onetimepad = $_SESSION['onetimepad'];
+
+$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-- */
 
@@ -58,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];
@@ -96,7 +113,7 @@ displayHtmlHeader( _("Printer Friendly"), '', FALSE );
 
 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n" .
      /* headers (we use table because translations are not all the same width) */
-     html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0"' ) .
+     html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
      html_tag( 'tr',
          html_tag( 'td', _("From").'&nbsp;', 'left' ,'','valign="top"') .
          html_tag( 'td', htmlspecialchars($from), 'left' )
@@ -121,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" .