X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fread_body.php;h=36dfe50b6244254b763fe537fc5af724869efc1b;hp=c3a2ec76fc25be8721e78b0f2aa5f08bff0b9a2b;hb=407e70327abb65df0d3da60110eb27d477776898;hpb=1e12d1ffb4f54350932a17397d38917db21d64df diff --git a/src/read_body.php b/src/read_body.php index c3a2ec76..36dfe50b 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -3,125 +3,103 @@ /** * read_body.php * - * Copyright (c) 1999-2003 The SquirrelMail Project Team - * Licensed under the GNU GPL. For full terms see the file COPYING. - * * This file is used for reading the msgs array and displaying * the resulting emails in the right frame. * - * $Id$ + * @copyright © 1999-2006 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package squirrelmail */ -/* Path for SquirrelMail required files. */ +/** + * Path for SquirrelMail required files. + * @ignore + */ define('SM_PATH','../'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); +include_once(SM_PATH . 'include/validate.php'); +//require_once(SM_PATH . 'functions/global.php'); require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/mime.php'); require_once(SM_PATH . 'functions/date.php'); require_once(SM_PATH . 'functions/url_parser.php'); require_once(SM_PATH . 'functions/html.php'); -require_once(SM_PATH . 'functions/global.php'); +//require_once(SM_PATH . 'functions/global.php'); +require_once(SM_PATH . 'functions/identity.php'); +include_once(SM_PATH . 'functions/arrays.php'); +include_once(SM_PATH . 'functions/mailbox_display.php'); /** * Given an IMAP message id number, this will look it up in the cached - * and sorted msgs array and return the index. Used for finding the next - * and previous messages. + * and sorted msgs array and return the index of the next message * + * @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; - } - $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; - } - } +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 = sqm_array_get_value_by_offset($uidset,$passed_id,1); + if ($result === false) { + return -1; } 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; - } - } - } - } + return $result; } - return $result; } -/** returns the index of the previous message from the array. */ -function findPreviousMessage($numMessages, $passed_id) { - global $msort, $sort, $msgs, - $thread_sort_messages, - $allow_server_sort, $server_sort_array; - $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) { - break; - } - $result = $server_sort_array[$key - 1]; - break; - } - } +/** + * Given an IMAP message id number, this will look it up in the cached + * and sorted msgs array and return the index of the previous message + * + * @param int $passed_id The current message UID + * @return the index of the next valid message from the array + */ + +function findPreviousMessage($uidset, $passed_id) { + if (!is_array($uidset)) { + return -1; + } + $result = sqm_array_get_value_by_offset($uidset,$passed_id,-1); + if ($result === false) { + return -1; } 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; - } - } - } - } + return $result; } - return $result; } /** * 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 */ -function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) { - global $javascript_on; +function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { + global $javascript_on, $show_html_default; - $params = '?passed_ent_id=' . $passed_ent_id . + /* hackydiehack */ + if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) { + $view_unsafe_images = false; + } else { + $view_unsafe_images = true; + } + $params = '?passed_ent_id=' . urlencode($passed_ent_id) . '&mailbox=' . urlencode($mailbox) . - '&passed_id=' . $passed_id; + '&passed_id=' . urlencode($passed_id) . + '&view_unsafe_images='. (bool) $view_unsafe_images . + '&show_html_default=' . $show_html_default; $print_text = _("View Printable Version"); $result = ''; /* Output the link. */ if ($javascript_on) { - $result = '