X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=6c73bea8c12fc9787cb67c0feb95354e6c915f9b;hb=ff0969a01edab0a4f1e256132c1c4da2dcfe5e3b;hp=7e12373efcb5c20c50b35f2441a3ecbf61c26708;hpb=c075fcfeee6685e97ac75f7400f267ddaa7c3e28;p=squirrelmail.git diff --git a/src/read_body.php b/src/read_body.php index 7e12373e..6c73bea8 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -38,10 +38,11 @@ require_once(SM_PATH . 'functions/mailbox_display.php'); * @return the index of the next valid message from the array */ 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; - sqgetGlobalVar('server_sort_array',$server_sort_array,SQ_SESSION); - $uidset = $server_sort_array; } $result = -1; $count = count($uidset) - 1; @@ -66,9 +67,8 @@ function findNextMessage($uidset,$passed_id='backwards') { */ function findPreviousMessage($uidset, $passed_id) { - if (!is_array($uidset)) { //obsolete check - sqgetGlobalVar('server_sort_array',$server_sort_array,SQ_SESSION); - $uidset = $server_sort_array; + if (!is_array($uidset)) { + return -1; } $result = -1; foreach($uidset as $key=>$value) { @@ -192,8 +192,8 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { $special_encoding = ''; if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && - function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { - $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body); + 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'; @@ -265,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'); @@ -298,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; } @@ -347,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; } } @@ -425,26 +425,26 @@ function formatEnvheader($aMailbox, $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 '
'."\n"; echo $s; do_hook('read_body_header'); formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color); - echo '
'; - echo '
'; + echo ''; + echo ''."\n"; + echo ''; } /** @@ -456,7 +456,7 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, * @param object $message Current message object * @param object $mbx_response */ -function formatMenubar($aMailbox, $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, $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, @@ -523,14 +523,21 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res $nav_row .= $double_delimiter . '['._("View Message").']'; // Prev/Next links for regular messages - } else if ( !(isset($where) && isset($what)) ) { - $prev = findPreviousMessage($aMailbox['UIDSET'], $passed_id); - $next = findNextMessage($aMailbox['UIDSET'],$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.''; } @@ -539,6 +546,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res 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.''; } @@ -546,12 +554,13 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res // Only bother with Delete & Prev and Delete & Next IF // top display is enabled. if ( $delete_prev_next_display == 1 && - in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { + 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.''; } @@ -561,6 +570,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res $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.''; } @@ -572,13 +582,11 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res } // 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 . @@ -628,30 +636,23 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res $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 .= ' '; - if ( in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { - // Form for deletion - $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox; - $menu_row .= '
'; + if ( in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) { + // Form for deletion. Form is handled by the originating display in $where. This is right_main.php or search.php + $delete_url = $base_uri . "src/$where"; + $menu_row .= ''; if (!(isset($passed_ent_id) && $passed_ent_id)) { - $menu_row .= addHidden('message', $passed_id); - - if ($where && $what) { - $menu_row .= addHidden('where', $where); - $menu_row .= addHidden('what', $what); - } else { - $menu_row .= addHidden('sort', $sort); - $menu_row .= addHidden('startMessage', $startMessage); - } + $menu_row .= addHidden('mailbox', $aMailbox['NAME']); + $menu_row .= addHidden('msg[0]', $passed_id); $menu_row .= getButton('SUBMIT', 'delete', _("Delete")); - $menu_row .= '' . _("Bypass Trash"); + $menu_row .= '' . _("Bypass Trash"); + } else { + $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled } - else - $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled $menu_row .= '
'; } @@ -659,25 +660,13 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res // Add top move link $menu_row .= ''; if ( !(isset($passed_ent_id) && $passed_ent_id) && - in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { - - $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?'; - } + in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) { - $menu_row .= '
'. + $menu_row .= ''. ''. - addHidden('show_more', '0' ). - addHidden('dmn', '1'). - addHidden('location', $location.$current_box). - addHidden('msg[0]', $passed_id) . _("Move to:") . + + addHidden('mailbox',$aMailbox['NAME']) . + addHidden('msg[0]', $passed_id) . _("Move to:") . '