\n" .
html_tag( 'td', '', 'right', '', 'valign="middle" width="20%"' ) . '' . _("Options") . ": \n" .
html_tag( 'td', '', 'left', '', 'valign="middle" width="80%"' ) . '' .
''._("View Full Header").'';
/* Output the printer friendly link if we are in subtle mode. */
$s .= ' | ' .
printer_friendly_link($mailbox, $passed_id, $passed_ent_id);
echo $s;
echo view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message);
/* Output the download and/or unsafe images link/-s, if any. */
if ($download_and_unsafe_link) {
echo $download_and_unsafe_link;
}
do_hook("read_body_header_right");
$s = "\n" .
"
\n";
echo $s;
}
/**
* Creates button
*
* @deprecated see form functions available in 1.5.1 and 1.4.3.
* @param string $type
* @param string $name
* @param string $value
* @param string $js
* @param bool $enabled
*/
function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
$disabled = ( $enabled ? '' : 'disabled ' );
$js = ( $js ? $js.' ' : '' );
return '';
}
/***************************/
/* Main of read_body.php */
/***************************/
/* get the globals we may need */
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION);
if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) {
$messages = array();
}
sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION);
if (is_array($delayed_errors)) {
$oErrorHandler->AssignDelayedErrors($delayed_errors);
sqsession_unregister("delayed_errors");
}
/** GET VARS */
sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET);
if (!sqgetGlobalVar('where', $where, SQ_GET) ) {
$where = 'right_main.php';
}
/*
* Used as entry key to the list of uid's cached in the mailbox cache
* we use the cached uid's to get the next and prev message.
*/
if (!sqgetGlobalVar('what', $what, SQ_GET) ){
$what = 0;
}
if ( sqgetGlobalVar('show_more', $temp, SQ_GET) ) {
$show_more = (int) $temp;
}
if ( sqgetGlobalVar('show_more_cc', $temp, SQ_GET) ) {
$show_more_cc = (int) $temp;
}
if ( sqgetGlobalVar('show_more_bcc', $temp, SQ_GET) ) {
$show_more_bcc = (int) $temp;
}
if ( sqgetGlobalVar('view_hdr', $temp, SQ_GET) ) {
$view_hdr = (int) $temp;
}
if ( sqgetGlobalVar('account', $temp, SQ_GET) ) {
$iAccount = (int) $temp;
} else {
$iAccount = 0;
}
/** GET/POST VARS */
sqgetGlobalVar('passed_ent_id', $passed_ent_id);
sqgetGlobalVar('mailbox', $mailbox);
if ( sqgetGlobalVar('passed_id', $temp) ) {
$passed_id = (int) $temp;
}
if ( sqgetGlobalVar('sort', $temp) ) {
$sort = (int) $temp;
}
if ( sqgetGlobalVar('startMessage', $temp) ) {
$startMessage = (int) $temp;
} else {
$startMessage = 1;
}
if(sqgetGlobalVar('show_html_default', $temp)) {
$show_html_default = (int) $temp;
}
if(sqgetGlobalVar('view_unsafe_images', $temp)) {
$view_unsafe_images = (int) $temp;
if($view_unsafe_images == 1) {
$show_html_default = 1;
}
} else {
$view_unsafe_images = 0;
}
/**
* Retrieve mailbox cache
*/
sqgetGlobalVar('mailbox_cache',$mailbox_cache,SQ_SESSION);
/* end of get globals */
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
*/
/**
* Replace From => To in case it concerns a draft or sent folder
*/
$aColumns = array();
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;
}
$aColumns[$iCol] = array();
}
} else {
foreach ($index_order as $iCol) {
$aColumns[$iCol] = array();
}
}
$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);
}
$iSetIndex = $aMailbox['SETINDEX'];
$aMailbox['CURRENT_MSG'][$iSetIndex] = $passed_id;
/**
* Update the seen state
* and ignore in_array('\\seen',$aMailbox['PERMANENTFLAGS'],true)
*/
if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'])) {
$aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\seen'] = true;
}
/**
* Process Delete from delete-move-next
* but only if delete_id was set
*/
if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
handleMessageListForm($imapConnection,$aMailbox,$sButton='setDeleted', array($delete_id));
}
/**
* $message contains all information about the message
* including header and body
*/
if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) {
$message = $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'];
$FirstTimeSee = !$message->is_seen;
} else {
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$FirstTimeSee = !$message->is_seen;
$message->is_seen = true;
$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
}
if (isset($passed_ent_id) && $passed_ent_id) {
$message = $message->getEntity($passed_ent_id);
if ($message->type0 != 'message' && $message->type1 != 'rfc822') {
$message = $message->parent;
}
$read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, TRUE);
$rfc822_header = new Rfc822Header();
$rfc822_header->parseHeader($read);
$message->rfc822_header = $rfc822_header;
} else if ($message->type0 == 'message' && $message->type1 == 'rfc822' && isset($message->entities[0])) {
$read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[1.HEADER]", true, $response, $msg, TRUE);
$rfc822_header = new Rfc822Header();
$rfc822_header->parseHeader($read);
$message->rfc822_header = $rfc822_header;
} else {
$passed_ent_id = 0;
}
$header = $message->header;
/****************************************/
/* Block for handling incoming url vars */
/****************************************/
if (isset($sendreceipt)) {
if ( !$message->is_mdnsent ) {
$final_recipient = '';
if ((isset($identity)) && ($identity != 0)) //Main identity
$final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
if ($final_recipient == '' )
$final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
$supportMDN = ServerMDNSupport($aMailbox["PERMANENTFLAGS"]);
if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id);
$message->is_mdnsent = true;
$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
}
}
}
/***********************************************/
/* End of block for handling incoming url vars */
/***********************************************/
$messagebody = '';
do_hook('read_body_top');
if ($show_html_default == 1) {
$ent_ar = $message->findDisplayEntity(array());
} else {
$ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
}
$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 .= '';
}
}
/**
* Write mailbox with updated seen flag information back to cache.
*/
$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
sqsession_register($mailbox_cache,'mailbox_cache');
$_SESSION['mailbox_cache'] = $mailbox_cache;
displayPageHeader($color, $mailbox,'','');
formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
echo '