';
+
+ $env[_("Options")] = formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
+
+
+ $oTemplate->assign('headers_to_display', $env);
+
+ $oTemplate->display('read_headers.tpl');
}
/**
* Format message toolbar
*
- * @param string $mailbox Name of current mailbox
- * @param int $passed_id UID of current message
- * @param int $passed_ent_id Id of entity within message
- * @param object $message Current message object
- * @param object $mbx_response
+ * @param array $aMailbox Current mailbox information array
+ * @param int $passed_id UID of current message
+ * @param int $passed_ent_id Id of entity within message
+ * @param object $message Current message object
+ * @param void $removedVar This parameter is no longer used, but remains
+ * so as not to break this function's prototype
+ * (OPTIONAL)
+ * @param boolean $nav_on_top When TRUE, the menubar is being constructed
+ * for use at the top of the page, otherwise it
+ * will be used for page bottom (OPTIONAL;
+ * default = TRUE)
*/
-function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar, $nav_on_top = TRUE) {
- global $base_uri, $draft_folder, $where, $what, $color, $sort,
+function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,
+ $removedVar=FALSE, $nav_on_top=TRUE) {
+
+ global $base_uri, $draft_folder, $where, $what, $sort,
$startMessage, $PHP_SELF, $save_as_draft,
$enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
- $username, $delete_prev_next_display,
- $compose_new_win, $javascript_on, $compose_width, $compose_height;
+ $delete_prev_next_display, $show_copy_buttons,
+ $compose_new_win, $compose_width, $compose_height,
+ $oTemplate;
//FIXME cleanup argument list, use $aMailbox where possible
$mailbox = $aMailbox['NAME'];
- $topbar_delimiter = ' | ';
- $double_delimiter = ' ';
$urlMailbox = urlencode($mailbox);
- $msgs_url = $base_uri . 'src/';
-
- // BEGIN NAV ROW - PREV/NEXT, DEL PREV/NEXT, LINKS TO INDEX, etc.
- $nav_row = '
\n";
- echo $s;
+ $links[] = array (
+ 'URL' => $download_href,
+ 'Text' => _("Download this as a file")
+ );
+ $toggle = html_toggle_href($mailbox, $passed_id, $passed_ent_id, $message);
+ if (!empty($toggle)) {
+ $links[] = array (
+ 'URL' => $toggle,
+ 'Text' => $show_html_default==1 ? _("View as plain text") : _("View as HTML")
+ );
+ }
+ if (!empty($unsafe_image_toggle_href)) {
+ $links[] = array (
+ 'URL' => $unsafe_image_toggle_href,
+ 'Text' => $unsafe_image_toggle_text
+ );
+ }
-}
+ do_hook('read_body_header_right', $links);
-/**
- * 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 '';
-}
+ $oTemplate->assign('links', $links);
+ return $oTemplate->fetch('read_toolbar.tpl');
+}
/***************************/
/* Main of read_body.php */
@@ -760,16 +776,16 @@ function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
/* 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) ) {
@@ -802,12 +818,10 @@ if ( sqgetGlobalVar('account', $temp, SQ_GET) ) {
}
/** GET/POST VARS */
+sqgetGlobalVar('passed_id', $passed_id, SQ_INORDER, NULL, SQ_TYPE_BIGINT);
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;
}
@@ -816,26 +830,82 @@ if ( sqgetGlobalVar('startMessage', $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);
+$imapConnection = sqimap_login($username, false, $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.
- */
+ * 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);
}
@@ -870,10 +940,14 @@ if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) {
} 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;
}
+/**
+ * update message seen status and put in cache
+ */
+$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') {
@@ -893,8 +967,14 @@ if (isset($passed_ent_id) && $passed_ent_id) {
}
$header = $message->header;
-$header = $message->header;
-
+// gmail does not mark messages as read when retrieving the message body
+// even though RFC 3501, section 6.4.5 (FETCH Command) says:
+// "The \Seen flag is implicitly set; if this causes the flags to change,
+// they SHOULD be included as part of the FETCH responses."
+//
+if ($imap_server_type == 'gmail') {
+ sqimap_toggle_flag($imapConnection, $passed_id, '\\Seen', true, true);
+}
/****************************************/
/* Block for handling incoming url vars */
@@ -902,28 +982,22 @@ $header = $message->header;
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 ) {
+ if ( SendMDN( $mailbox, $passed_id, $message, $imapConnection ) > 0 && $supportMDN ) {
ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id);
$message->is_mdnsent = true;
$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
}
- ClearAttachments();
}
}
/***********************************************/
/* End of block for handling incoming url vars */
/***********************************************/
-
-
+$oTemplate->assign('aAttribs', array('class' => 'entity_sep'));
+$hr = $oTemplate->fetch('horizontal_rule.tpl');
$messagebody = '';
-do_hook('read_body_top');
+do_hook('read_body_top', $null);
if ($show_html_default == 1) {
$ent_ar = $message->findDisplayEntity(array());
} else {
@@ -933,55 +1007,38 @@ $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 .= '';
+ $messagebody .= $hr;
}
}
+/**
+ * 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;
+
+// message list URI is used in page header when on read_body
+$oTemplate->assign('message_list_href', get_message_list_uri($aMailbox['NAME'], $startMessage, $what));
+
displayPageHeader($color, $mailbox,'','');
-formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
+
+/* this is the non-javascript version of printer friendly */
+if ( sqgetGlobalVar('print', $print, SQ_GET) ) {
+ $oTemplate->display('read_message_print.tpl');
+} else {
+ formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,false);
+}
formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
-echo '