X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=13f185a37b5b08af6bdf10579da967d8d823c806;hb=de9435583d67215d71d0a89f00adb2eeb4640a7f;hp=07d94a752fc4835dd376b9c0caa4c97cbf2eeb5e;hpb=6c930adedca170d2f040316c2c0b4dc54afe410e;p=squirrelmail.git
diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php
index 07d94a75..13f185a3 100644
--- a/functions/mailbox_display.php
+++ b/functions/mailbox_display.php
@@ -13,6 +13,8 @@
*/
require_once('../functions/strings.php');
+require_once('../functions/imap_utf7_decode_local.php');
+require_once('../functions/html.php');
/* Default value for page_selector_max. */
define('PG_SEL_MAX', 10);
@@ -28,7 +30,9 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort,
$indent_array, /* indent subject by */
$pos, /* Search postion (if any) */
$thread_sort_messages, /* thread sorting on/off */
- $row_count;
+ $server_sort_order, /* sort value when using server-sorting */
+ $row_count,
+ $allow_server_sort; /* enable/disable server-side sorting */
$color_string = $color[4];
if ($GLOBALS['alt_index_colors']) {
@@ -159,8 +163,10 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort,
case 4: /* subject */
echo "
$bold";
if ($thread_sort_messages == 1) {
- echo str_repeat(" ",$indent_array[$msg["ID"]]);
- }
+ if (isset($indent_array[$msg["ID"]])) {
+ echo str_repeat(" ",$indent_array[$msg["ID"]]);
+ }
+ }
echo "!\n";
$stuff = true;
}
- if ($msg['PRIORITY'][0] == 5) {
+ if ($msg['PRIORITY'] == 5) {
echo "?\n";
$stuff = true;
}
@@ -223,21 +229,71 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
$use_cache) {
global $msgs, $msort,
$sent_folder, $draft_folder,
- $message_highlight_list,
- $auto_expunge, $thread_sort_messages,
- $data_dir, $username;
- /* If autoexpunge is turned on, then do it now. */
-
+ $message_highlight_list,
+ $auto_expunge, $thread_sort_messages, $allow_server_sort,
+ $data_dir, $username, $server_sort_order;
+
+ /* if $start_msg is lower than $num_msgs, we probably deleted all messages
+ * in the last page. We need to re-adjust the start_msg
+ */
+
+ if($start_msg > $num_msgs) {
+ $start_msg -= $show_num;
+ if($start_msg < 1) {
+ $start_msg = 1;
+ }
+ }
+
+ /* This code and the next if() block check for
+ * server-side sorting methods. The $id array is
+ * formatted and $sort is set to 6 to disable
+ * SM internal sorting
+ */
if ($thread_sort_messages == 1) {
$id = get_thread_sort($imapConnection);
- $sort = 6;
- if ($start_msg + ($show_num - 1) < $num_msgs) {
- $end_msg = $start_msg + ($show_num-1);
- } else {
- $end_msg = $num_msgs;
- }
- $id = array_slice($id, ($start_msg-1), ($end_msg));
+ if ($id == 'no') {
+ echo 'Thread sorting is not'.
+ ' supported by your IMAP server. Please report this'.
+ ' to the system administrator.';
+ $thread_sort_messages = 0;
+ $id = array();
}
+ else {
+ $sort = 6;
+ if ($start_msg + ($show_num - 1) < $num_msgs) {
+ $end_msg = $start_msg + ($show_num-1);
+ }
+ else {
+ $end_msg = $num_msgs;
+ }
+ $id = array_slice($id, ($start_msg-1), ($end_msg));
+ }
+ }
+
+ if ($allow_server_sort == TRUE && $thread_sort_messages != 1) {
+ $server_sort_order = $sort;
+ $id = sqimap_get_sort_order($imapConnection, $server_sort_order);
+ if ($id == 'no') {
+ echo 'Server-side sorting'.
+ ' is not supported by your IMAP server. Please report this'.
+ ' to the system administrator.';
+ $sort = $server_sort_order;
+ $allow_server_sort = FALSE;
+ $id = array();
+ }
+ else {
+ $sort = 6;
+ if ($start_msg + ($show_num - 1) < $num_msgs) {
+ $end_msg = $start_msg + ($show_num-1);
+ }
+ else {
+ $end_msg = $num_msgs;
+ }
+ $id = array_slice($id, ($start_msg-1), ($end_msg));
+ }
+ }
+
+ /* If autoexpunge is turned on, then do it now. */
if ($auto_expunge == true) {
sqimap_mailbox_expunge($imapConnection, $mailbox, false);
}
@@ -249,7 +305,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
if ($sort < 6 ) {
$id = range(1, $num_msgs);
}
- elseif ($thread_sort_messages != 1) {
+ elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE && $sort == 6) {
/* if it's not sorted */
if ($start_msg + ($show_num - 1) < $num_msgs){
$end_msg = $start_msg + ($show_num - 1);
@@ -271,7 +327,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
$id = array_reverse(range($real_endMessage, $real_startMessage));
}
$msgs_list = sqimap_get_small_header_list($imapConnection, $id, $issent);
- $flags = sqimap_get_flags_list($imapConnection, $id, $issent);
+// $flags = sqimap_get_flags_list($imapConnection, $id, $issent);
if (sizeof($msgs_list)){
foreach ($msgs_list as $hdr) {
$from[] = $hdr->from;
@@ -282,6 +338,10 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
$cc[] = $hdr->cc;
$size[] = $hdr->size;
$type[] = $hdr->type0;
+ $flag_deleted[] = $hdr->flag_deleted;
+ $flag_answered[] = $hdr->flag_answered;
+ $flag_seen[] = $hdr->flag_seen;
+ $flag_flagged[] = $hdr->flag_flagged;
}
}
}
@@ -321,6 +381,11 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
$messages[$j]['CC'] = $cc[$j];
$messages[$j]['SIZE'] = $size[$j];
$messages[$j]['TYPE0'] = $type[$j];
+ $messages[$j]['FLAG_DELETED'] = $flag_deleted[$j];
+ $messages[$j]['FLAG_ANSWERED'] = $flag_answered[$j];
+ $messages[$j]['FLAG_SEEN'] = $flag_seen[$j];
+ $messages[$j]['FLAG_FLAGGED'] = $flag_flagged[$j];
+
/*
* fix SUBJECT-SORT to remove Re:
@@ -335,7 +400,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
$messages[$j]['SUBJECT-SORT'], $matches)){
$messages[$j]['SUBJECT-SORT'] = $matches[2];
}
-
+/*
$num = 0;
while ($num < count($flags[$j])) {
if ($flags[$j][$num] == 'Deleted') {
@@ -349,7 +414,9 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
}
$num++;
}
+*/
$j++;
+
}
/*
@@ -413,7 +480,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
}
}
session_register('msort');
- } elseif ($thread_sort_messages == 1 ) {
+ } elseif ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
$msort = $msgs;
session_unregister('msgs');
session_register('msort');
@@ -433,7 +500,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
global $folder_prefix, $sent_folder,
$imapServerAddress, $data_dir, $username, $use_mailbox_cache,
$index_order, $real_endMessage, $real_startMessage, $checkall,
- $indent_array, $thread_sort_messages;
+ $indent_array, $thread_sort_messages, $allow_server_sort, $server_sort_order;
/* If cache isn't already set, do it now. */
if (!session_is_registered('msgs')) {
@@ -539,11 +606,12 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
}
echo ''
- . ""
+ . html_tag( 'table', '',
+ "bgcolor=\"$color[9]\" width=\"100%\" border=0 cellpadding=1 cellspacing=1" )
+ . " | "
. "$paginator_str | "
- . "$msg_cnt_str | "
+ . html_tag( 'td', 'right' ) . "$msg_cnt_str | "
. " | ";
/* End of message-list table */
@@ -561,6 +629,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
* $Message is a message that is centered on top of the list
* $More is a second line that is left aligned
*/
+
function mail_message_listing_beginning ($imapConnection, $moveURL,
$mailbox = '', $sort = -1,
$msg_cnt_str = '',
@@ -568,39 +637,27 @@ function mail_message_listing_beginning ($imapConnection, $moveURL,
$start_msg = 1) {
global $color, $index_order, $auto_expunge, $move_to_trash, $base_uri,
$checkall, $sent_folder, $draft_folder, $thread_sort_messages,
- $allow_thread_sort;
+ $allow_thread_sort, $allow_server_sort, $server_sort_order,
+ $lastTargetMailbox;
+
$urlMailbox = urlencode($mailbox);
/*
* This is the beginning of the message list table.
* It wraps around all messages
*/
- echo "