require_once('../functions/url_parser.php');
require_once('../functions/smtp.php');
require_once('../functions/html.php');
-require_once('../src/view_header.php');
/**
* Given an IMAP message id number, this will look it up in the cached
global $username, $attachment_dir, $SERVER_NAME,
$version, $attachments;
- $header = $message->header;
+ $header = $message->rfc822_header;
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
$recipient_o = $header->dnt;
$to_array = $header->to;
$to = '';
foreach ($to_array as $line) {
- $to .= " $line ";
+ $to .= ' '.$line->getAddress();
}
$subject = $header->subject;
return $string;
}
-function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color) {
+function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
+ $color, $FirstTimeSee) {
global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
$default_use_priority, $show_xmailer_default,
$mdn_user_support, $PHP_SELF, $javascript_on;
-
- $header = $message->header;
+
+ $header = $message->rfc822_header;
$env = array();
- $env[_("Subject")] = getLongDateString($header->date);
- $from_o = $header->from;
- if (is_object($from_o)) {
- $from_name = $from_o->getAddress();
- } else {
- $from_name = _("Unknown sender");
+ $env[_("Subject")] = htmlspecialchars($header->subject);
+ $from_name = $header->getAddr_s('from');
+ if (!$from_name) {
+ $from_name = $header->getAddr_s('sender');
+ if (!$from_name) {
+ $from_name = _("Unknown sender");
+ }
}
$env[_("From")] = htmlspecialchars($from_name);
- $env[_("Date")] = htmlspecialchars($header->subject);
+ $env[_("Date")] = getLongDateString($header->date);
$env[_("To")] = formatRecipientString($header->to, "to");
$env[_("Cc")] = formatRecipientString($header->cc, "cc");
$env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
if ( !($mailbox == $draft_folder ||
$mailbox == $sent_folder || $message->is_deleted)) {
$mdn_url = $PHP_SELF . '&sendreceipt=1';
- $FirstTimeSee = false;
if ($FirstTimeSee && $javascript_on) {
$script = '<script language="JavaScript" type="text/javascript">' ."\n";
$script .= '<!--'. "\n";
}
}
- $s = '<table width="100%" cellpadding="0" cellspacing="0" border="0" ' .
- 'align="center">';
+/* BOOKMARK */
+ $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"';
+ $s .= ' ALIGN="center" BGCOLOR="' . $color[0] . '">';
foreach ($env as $key => $val) {
if ($val) {
- $s .= '<tr>';
- $s .= html_tag( 'td', '<b>'.$key.': </b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
- $s .= html_tag( 'td', $val, 'left', $color[0], 'valign="top" width="80%"');
- $s .= "\n</tr>";
+ $s .= '<TR>';
+ $s .= html_tag('TD', '<B>' . $key . ': </B>', 'RIGHT', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
+ $s .= html_tag('TD', $val, 'left', '', 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
+ $s .= '</TR>';
}
}
- $s .= '</table>';
- return $s;
+ echo $s;
+ do_hook("read_body_header");
+ formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
+ echo '</table>';
}
-function formatMenubar($mailbox, $passed_id, $passed_ent_id, $msg, $mbx_response) {
+function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
- $startMessage, $data_dir, $username, $compose_new_win;
+ $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft;
$topbar_delimiter = ' | ';
- $urlMailbox = encodeHeader($mailbox);
-
- $identity = '';
- $idents = getPref($data_dir, $username, 'identities');
- $from_name = $msg->header->from->getAddress();
- if (!empty($idents) && $idents > 1) {
- for ($i = 1; $i < $idents; $i++) {
- $enc_from_name = '"'.
- encodeHeader(getPref($data_dir,
- $username,
- 'full_name' . $i)) .
- '" <' . getPref($data_dir, $username,
- 'email_address' . $i) . '>';
- if (htmlspecialchars($enc_from_name) == $from_name) {
- $identity = $i;
- break;
- }
- }
- }
-
+ $urlMailbox = urlencode($mailbox);
$s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
$msgs_url = $base_uri . 'src/';
if (isset($where) && isset($what)) {
- if ($pos == '') {
- $pos=0;
- }
- $msgs_url .= 'search.php?where='.urlencode($where).'&pos='.$pos.
+ $msgs_url .= 'search.php?where='.urlencode($where).
'&what='.urlencode($what).'&mailbox='.$urlMailbox;
+ $msgs_str = _("Search results");
} else {
$msgs_url .= 'right_main.php?sort='.$sort.'&startMessage='.
$startMessage.'&mailbox='.$urlMailbox;
+ $msgs_str = _("Message List");
}
- $s .= '<a href="'. $msgs_url.'">'._("Message List").'</a>';
+ $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
$s .= $topbar_delimiter;
$delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
$comp_uri = $base_uri . 'src/compose.php'.
'?passed_id='.$passed_id.
'&mailbox='.$urlMailbox.
- (isset($passed_ent_id)?'&passed_ent_id='.$passed_ent_id:'').
- '&identity='.$identity;
-
+ (isset($passed_ent_id)?'&passed_ent_id='.$passed_ent_id:'');
if (($mailbox == $draft_folder) && ($save_as_draft)) {
$comp_alt_uri = $comp_uri . '&action=draft';
$s .= $topbar_delimiter;
if ($compose_new_win == '1') {
$s .= '<a href="javascript:void(0)" '.
- 'onclick="comp_in_new("'.$comp_alt_uri.'")">'.$comp_alt_string.'</a>';
+ 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
} else {
$s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
}
$s .= _("Next");
}
} else if (isset($passed_ent_id) && $passed_ent_id) {
+ /* code for navigating through attached message/rfc822 messages */
+ $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
+ $s .= '<a href="'.$url.'">'._("View Message").'</a>';
+ $par_ent_id = $message->parent->entity_id;
+ if ($par_ent_id) {
+ $par_ent_id = substr($par_ent_id,0,-2);
+ $s .= $topbar_delimiter;
+ $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
+ $s .= '<a href="'.$url.'">'._("Up").'</a>';
+ }
}
- $s .= '</small></td><td align="right" width="33%"><small>';
-
+ $s .= '</small></td><td align="right" width="33%" nowrap><small>';
$comp_action_uri = $comp_uri . '&action=forward';
if ($compose_new_win == '1') {
$s .= '<a href="javascript:void(0)" '.
}
$s .= $topbar_delimiter;
+ $comp_action_uri = $comp_uri . '&action=forward_as_attachment';
+ if ($compose_new_win == '1') {
+ $s .= '<a href="javascript:void(0)" '.
+ 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as attachment").'</a>';
+ } else {
+ $s .= '<a href="'.$comp_action_uri.'">'._("Forward as attachment").'</a>';
+ }
+ $s .= $topbar_delimiter;
+
+
+
$comp_action_uri = decodeHeader($comp_uri . '&action=reply');
if ($compose_new_win == '1') {
$s .= '<a href="javascript:void(0)" '.
$s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
}
$s .= '</small></td></tr></table>';
- return $s;
+ echo $s;
}
function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
- global $startMessage, $show_more, $base_uri, $where, $what;
-
- $urlMailbox = encodeHeader($mailbox);
- $s = '<table width="100%" cellpadding="3" cellspacing="0" align="right"'.
- ' border="0" bgcolor="'.$color[9].'">'.
- '<tr align="right"><td valign="top" align="right"><small>';
-
- $viewheader_url = $base_uri . 'src/read_body.php?mailbox=' . $urlMailbox .
- '&passed_id='. $passed_id. '&';
- if ($where && $what) {
- $viewheader_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what) .
- '&view_hdr=1';
- } else {
- $viewheader_url .= 'startMessage=' .$startMessage. '&show_more='.
- $show_more .'&view_hdr=1';
- }
- $s .= '<a href="'.$viewheader_url.'">'.("View Full Header").'</a>';
- /* Output the printer friendly link if we are in subtle mode. */
- $s .= ' | '.
- printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+ global $QUERY_STRING, $base_uri;
+ $urlMailbox = urlencode($mailbox);
+ $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
+
+/* BOOKMARK */
+ $s = "<TR>\n";
+ $s .= '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Other") . ": </B></TD>\n";
+ $s .= '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>';
+ $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
+
+ /* Output the printer friendly link if we are in subtle mode. */
+ $s .= ' | ';
+ $s .= printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+ echo $s;
do_hook("read_body_header_right");
-
- $s .= '</small></td></tr></table>'."\n";
- return $s;
+ $s = "</SMALL></TD>\n";
+ $s .= "</TR>\n";
+ echo $s;
+
+
}
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$messages[$uidvalidity][$passed_id] = $message;
} else {
-// $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
- $message = $messages[$uidvalidity][$passed_id];
+ $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+// $message = $messages[$uidvalidity][$passed_id];
}
+$FirstTimeSee = !$message->is_seen;
+$message->is_seen = true;
+$messages[$uidvalidity][$passed_id] = $message;
+
if (isset($passed_ent_id)) {
$message = $message->getEntity($passed_ent_id);
$message->id = $passed_id;
//do_hook('html_top');
-/*
- * The following code sets necesarry stuff for the MDN thing
- */
-if($default_use_mdn &&
- ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
- $default_use_mdn))) {
- $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
- $FirstTimeSee = !$message->is_seen;
-}
-
/* =============================================================================
* block for handling incoming url vars
*
* =============================================================================
*/
-
-/*
- * The following code shows the header of the message and then exit
- */
-if (isset($view_hdr)) {
- $template_vars = array();
- $template_vars['full_header'] = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
- $template_vars['return_address'] = set_url_var($PHP_SELF, 'view_hdr');
- view_header($template_vars, '', '</body></html>');
- exit;
-}
-
if (isset($sendreceipt)) {
if ( !$message->is_mdnsent ) {
if (isset($identity) ) {
if ($final_recipient == '' ) {
$final_recipient = getPref($data_dir, $username, 'email_address', '' );
}
-
+ $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message ) > 0 && $supportMDN ) {
ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
$message->is_mdnsent = true;
$messagebody = '';
$ent_ar = $message->findDisplayEntity(array());
-for ($i = 0; $i < count($ent_ar); $i++) {
+$cnt = count($ent_ar);
+for ($i = 0; $i < $cnt; $i++) {
$messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
+ if ($i != $cnt-1) {
+ $messagebody .= '<hr noshade size=1>';
+ }
}
displayPageHeader($color, $mailbox);
do_hook('read_body_top');
-echo formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
-echo formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color);
-echo formatToolbar($mailbox,$passed_id,$passed_ent_id,$message, $color);
-echo "BOE";
-echo '<table width="100%" cellpadding="3" cellspacing="3" align="center"'.
- ' border="0" bgcolor="'.$color[4].'">';
-echo '<tr><td>'.$messagebody.'</td></tr>';
-echo '<tr><td>'.formatAttachments($message,$ent_ar,$mailbox, $passed_id).'</td></tr>';
+formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
+formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
+echo '<table width="100%" cellpadding="0" cellspacing="5" align="center" border="0">';
+echo ' <tr><td>';
+echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
+echo ' <tr><td>';
+echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
+echo ' <tr bgcolor="'.$color[4].'"><td>'.$messagebody. '</td></tr>';
+echo ' </table></td></tr>';
+echo ' </table>';
+echo ' </td></tr>';
+
+$attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
+if ($attachmentsdisplay) {
+ echo ' <tr><td>';
+ echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
+ echo ' <tr><td>';
+ echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
+ echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'"><b>';
+ echo _("Attachments").':</b></td></tr><tr><td>';
+ echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[12].'">';
+ echo $attachmentsdisplay;
+ echo ' </td></tr></table></table></td></tr>';
+ echo ' </table></td></tr>';
+ echo ' </table>';
+ echo ' </td></tr>';
+}
echo '</table>';
+
/* show attached images inline -- if pref'fed so */
if (($attachment_common_show_images) &&
is_array($attachment_common_show_images_list)) {
do_hook('read_body_bottom');
do_hook('html_bottom');
+//$message->clean_up();
sqimap_logout($imapConnection);
?>
</body>