X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=6c73bea8c12fc9787cb67c0feb95354e6c915f9b;hb=ff0969a01edab0a4f1e256132c1c4da2dcfe5e3b;hp=77f34d873e47f805811365095a3c1ff5ce48251e;hpb=789094695a51304ad7db3d10e192ce31937cc602;p=squirrelmail.git
diff --git a/src/read_body.php b/src/read_body.php
index 77f34d87..6c73bea8 100644
--- a/src/read_body.php
+++ b/src/read_body.php
@@ -37,38 +37,22 @@ require_once(SM_PATH . 'functions/mailbox_display.php');
* @param int $passed_id The current message UID
* @return the index of the next valid message from the array
*/
-function findNextMessage($passed_id) {
- global $msort, $msgs, $sort,
- $thread_sort_messages, $allow_server_sort,
- $server_sort_array;
- if (!is_array($server_sort_array)) {
- $thread_sort_messages = 0;
- $allow_server_sort = FALSE;
+function findNextMessage($uidset,$passed_id='backwards') {
+ if (!is_array($uidset)) {
+ return -1;
+ }
+ if ($passed_id=='backwards' || !is_array($uidset)) { // check for backwards compattibilty gpg plugin
+ $passed_id = $uidset;
}
$result = -1;
- if ($thread_sort_messages || $allow_server_sort) {
- $count = count($server_sort_array) - 1;
- foreach($server_sort_array as $key=>$value) {
- if ($passed_id == $value) {
- if ($key == $count) {
- break;
- }
- $result = $server_sort_array[$key + 1];
- break;
- }
- }
- } else {
- if (is_array($msort)) {
- for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
- if ($passed_id == $msgs[$key]['ID']) {
- next($msort);
- $key = key($msort);
- if (isset($key)){
- $result = $msgs[$key]['ID'];
- break;
- }
- }
+ $count = count($uidset) - 1;
+ foreach($uidset as $key=>$value) {
+ if ($passed_id == $value) {
+ if ($key == $count) {
+ break;
}
+ $result = $uidset[$key + 1];
+ break;
}
}
return $result;
@@ -81,38 +65,21 @@ function findNextMessage($passed_id) {
* @param int $passed_id The current message UID
* @return the index of the next valid message from the array
*/
-function findPreviousMessage($numMessages, $passed_id) {
- global $msort, $sort, $msgs,
- $thread_sort_messages,
- $allow_server_sort, $server_sort_array;
+
+function findPreviousMessage($uidset, $passed_id) {
+ if (!is_array($uidset)) {
+ return -1;
+ }
$result = -1;
- if (!is_array($server_sort_array)) {
- $thread_sort_messages = 0;
- $allow_server_sort = FALSE;
- }
- if ($thread_sort_messages || $allow_server_sort ) {
- foreach($server_sort_array as $key=>$value) {
- if ($passed_id == $value) {
- if ($key != 0) {
- $result = $server_sort_array[$key - 1];
- }
- break;
- }
- }
- } else {
- if (is_array($msort)) {
- for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
- if ($passed_id == $msgs[$key]['ID']) {
- prev($msort);
- $key = key($msort);
- if (isset($key)) {
- $result = $msgs[$key]['ID'];
- break;
- }
- }
+ foreach($uidset as $key=>$value) {
+ if ($passed_id == $value) {
+ if ($key != 0) {
+ $result = $uidset[$key - 1];
}
+ break;
}
}
+
return $result;
}
@@ -120,7 +87,7 @@ function findPreviousMessage($numMessages, $passed_id) {
* Displays a link to a page where the message is displayed more
* "printer friendly".
* @param string $mailbox Name of current mailbox
- * @param int $passed_id
+ * @param int $passed_id
*/
function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
global $javascript_on, $color;
@@ -150,14 +117,14 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
return $result;
}
-function ServerMDNSupport($read) {
- /* escaping $ doesn't work -> \x36 */
- $ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read);
- return $ret;
+function ServerMDNSupport($aFlags) {
+ /* escaping $ doesn't work -> \x36 */
+ return ( in_array('$mdnsent',$aFlags,true) ||
+ in_array('\\*',$aFlags,true) ) ;
}
function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
- global $username, $attachment_dir,
+ global $username, $attachment_dir,
$version, $attachments, $squirrelmail_language, $default_charset,
$languages, $useSendmail, $domain, $sent_folder,
$popuser, $data_dir, $username;
@@ -224,9 +191,9 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
sprintf( _("Was displayed on %s"), $now );
$special_encoding = '';
- if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
- function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
- $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
+ if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
+ function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
+ $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $body);
if (strtolower($default_charset) == 'iso-2022-jp') {
if (mb_detect_encoding($body) == 'ASCII') {
$special_encoding = '8bit';
@@ -298,7 +265,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
$success = $deliver->finalizeStream($stream);
}
if (!$success) {
- $msg = $deliver->dlv_msg . '
' .
+ $msg = $deliver->dlv_msg . '
' .
_("Server replied: ") . $deliver->dlv_ret_nr . ' '.
$deliver->dlv_server_msg;
require_once(SM_PATH . 'functions/display_messages.php');
@@ -320,7 +287,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) {
$sg = $set?'+':'-';
$cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
- $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
+ $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
$readmessage, TRUE);
}
@@ -331,16 +298,16 @@ function ClearAttachments() {
$rem_attachments = array();
if (isset($attachments)) {
- foreach ($attachments as $info) {
- if ($info['session'] == -1) {
- $attached_file = "$hashed_attachment_dir/$info[localfilename]";
- if (file_exists($attached_file)) {
- unlink($attached_file);
- }
- } else {
- $rem_attachments[] = $info;
- }
- }
+ foreach ($attachments as $info) {
+ if ($info['session'] == -1) {
+ $attached_file = "$hashed_attachment_dir/$info[localfilename]";
+ if (file_exists($attached_file)) {
+ unlink($attached_file);
+ }
+ } else {
+ $rem_attachments[] = $info;
+ }
+ }
}
$attachments = $rem_attachments;
}
@@ -380,15 +347,15 @@ function formatRecipientString($recipients, $item ) {
foreach($recipients as $r) {
$add = decodeHeader($r->getAddress(true));
if ($string) {
- $string .= '
' . $add;
+ $string .= '
' . $add;
} else {
$string = $add;
if ($cnt > 1) {
- $string .= ' ()';
+ $string .= '">'._("less").')';
} else {
- $string .= '">'._("more").')';
+ $string .= '">'._("more").')';
break;
}
}
@@ -398,12 +365,14 @@ function formatRecipientString($recipients, $item ) {
return $string;
}
-function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
+function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
$color, $FirstTimeSee) {
global $msn_user_support, $default_use_mdn, $default_use_priority,
$show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on,
$squirrelmail_language;
+ $mailbox = $aMailbox['NAME'] ;
+
$header = $message->rfc822_header;
$env = array();
$env[_("Subject")] = str_replace(" "," ",decodeHeader($header->subject));
@@ -431,8 +400,8 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
if ($message->is_mdnsent) {
$env[_("Read receipt")] = _("sent");
} else {
- $env[_("Read receipt")] = _("requested");
- if (!(handleAsSent($mailbox) ||
+ $env[_("Read receipt")] = _("requested");
+ if (!(handleAsSent($mailbox) ||
$message->is_deleted ||
$passed_ent_id)) {
$mdn_url = $PHP_SELF . '&sendreceipt=1';
@@ -456,44 +425,47 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
}
}
- $s = '
';
+ $s = '';
foreach ($env as $key => $val) {
if ($val) {
- $s .= '';
- $s .= html_tag('TD', '' . $key . ': ', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
- $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
- $s .= '
';
+ $s .= '';
+ $s .= html_tag('td', '' . $key . ': ', 'right', '', 'valign="top" width="20%"') . "\n";
+ $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n";
+ $s .= '
';
}
}
- echo ''."\n";
- echo ' |
'."\n";
+ echo ''."\n";
+ echo ' | '."\n";
echo $s;
do_hook('read_body_header');
formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
- echo ' | ';
- echo ' |
|
'."\n";
- echo '
';
+ echo '
';
+ echo ' |
'."\n";
+ echo '
';
}
/**
- * Format message toolbar
- *
+ * 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
*/
-function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response, $nav_on_top = TRUE) {
+function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar, $nav_on_top = TRUE) {
global $base_uri, $draft_folder, $where, $what, $color, $sort,
- $startMessage, $PHP_SELF, $save_as_draft,
+ $startMessage, $PHP_SELF, $save_as_draft,
$enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
$data_dir, $username, $delete_prev_next_display,
$compose_new_win, $javascript_on;
+ //FIXME cleanup argument list, use $aMailbox where possible
+ $mailbox = $aMailbox['NAME'];
+
$topbar_delimiter = ' | ';
$double_delimiter = ' ';
$urlMailbox = urlencode($mailbox);
@@ -551,14 +523,21 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
$nav_row .= $double_delimiter . '['._("View Message").']';
// Prev/Next links for regular messages
- } else if ( !(isset($where) && isset($what)) ) {
- $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
- $next = findNextMessage($passed_id);
+ } else if ( true ) { //!(isset($where) && isset($what)) ) {
+ /**
+ * Check if cache is still valid
+ */
+ if (!is_array($aMailbox['UIDSET'][$what])) {
+ fetchMessageHeaders($imapConnection, $aMailbox);
+ }
+ $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id);
+ $next = findNextMessage($aMailbox['UIDSET'][$what],$passed_id);
$prev_link = _("Previous");
if ($prev >= 0) {
$uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
'&mailbox='.$urlMailbox.'&sort='.$sort.
+ "&where=$where&what=$what" .
'&startMessage='.$startMessage.'&show_more=0';
$prev_link = ''.$prev_link.'';
}
@@ -567,20 +546,23 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
if ($next >= 0) {
$uri = $base_uri . 'src/read_body.php?passed_id='.$next.
'&mailbox='.$urlMailbox.'&sort='.$sort.
+ "&where=$where&what=$what" .
'&startMessage='.$startMessage.'&show_more=0';
$next_link = ''.$next_link.'';
}
// Only bother with Delete & Prev and Delete & Next IF
// top display is enabled.
- if ( $delete_prev_next_display == 1 ) {
+ if ( $delete_prev_next_display == 1 &&
+ in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
$del_prev_link = _("Delete & Prev");
if ($prev >= 0) {
$uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
'&mailbox='.$urlMailbox.'&sort='.$sort.
'&startMessage='.$startMessage.'&show_more=0'.
+ "&where=$where&what=$what" .
'&delete_id='.$passed_id;
- $del_prev_link = ''.$del_prev_link.'';
+ $del_prev_link = ''.$del_prev_link.'';
}
$del_next_link = _("Delete & Next");
@@ -588,6 +570,7 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
$uri = $base_uri . 'src/read_body.php?passed_id='.$next.
'&mailbox='.$urlMailbox.'&sort='.$sort.
'&startMessage='.$startMessage.'&show_more=0'.
+ "&where=$where&what=$what" .
'&delete_id='.$passed_id;
$del_next_link = ''.$del_next_link.'';
}
@@ -599,13 +582,11 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
}
// Start with Search Results or Message List link.
- if (isset($where) && isset($what)) {
- $msgs_url .= 'search.php?where=' . urlencode($where) .
- '&what=' . urlencode($what) . '&mailbox=' . $urlMailbox;
+ $msgs_url .= "$where?where=read_body.php&what=$what&mailbox=" . $urlMailbox.
+ "&startMessage=$startMessage";
+ if ($where == 'search.php') {
$msgs_str = _("Search Results");
} else {
- $msgs_url .= 'right_main.php?sort=' . $sort . '&startMessage=' .
- $startMessage . '&mailbox=' . $urlMailbox;
$msgs_str = _("Message List");
}
$nav_row .= $double_delimiter .
@@ -621,8 +602,8 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
'&mailbox=' . $urlMailbox .
'&startMessage=' . $startMessage .
(isset($passed_ent_id) ? '&passed_ent_id='.$passed_ent_id : '');
-
- // Start form for reply/reply all/forward..
+
+ // Start form for reply/reply all/forward..
$target = '';
$on_click='';
$method='method="post" ';
@@ -655,54 +636,37 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
$menu_row .= getButton('SUBMIT', 'smaction_reply_all', _("Reply All"), $on_click) ."\n";
$menu_row .= getButton('SUBMIT', 'smaction_forward', _("Forward"), $on_click);
if ($enable_forward_as_attachment)
- $menu_row .= '' . _("As Attachment") .' '."\n";
+ $menu_row .= '' . _("As Attachment") .' '."\n";
$menu_row .= ' ';
- // Form for deletion
- $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox;
- $menu_row .= '';
+ $menu_row .= '';
+ }
// Add top move link
$menu_row .= '';
- if ( !(isset($passed_ent_id) && $passed_ent_id) ) {
-
- $current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage;
-
- // Set subsequent location based on whether or not there is a 'next' message.
- if ( isset($next) && $next >= 0 ) {
- $location = $base_uri . 'src/read_body.php?passed_id='.$next.'&';
- } elseif (isset($prev) && $prev >= 0) {
- $location = $base_uri . 'src/read_body.php?passed_id='.$prev.'&';
- } else {
- $location = $base_uri . 'src/right_main.php?';
- }
+ if ( !(isset($passed_ent_id) && $passed_ent_id) &&
+ in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
- $menu_row .= ' |