- }
- session_register('msort');
- }
- displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
- session_register('msgs');
- }
-
- /******************************************************************/
- /* Generic function to convert the msgs array into an HTML table. */
- /******************************************************************/
- function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
- global $folder_prefix, $sent_folder;
- global $imapServerAddress, $data_dir, $username, $use_mailbox_cache;
- global $index_order, $real_endMessage, $real_startMessage, $checkall;
-
- /* If cache isn't already set, do it now. */
- if (!session_is_registered('msgs')) { session_register('msgs'); }
- if (!session_is_registered('msort')) { session_register('msort'); }
-
- if ($startMessage + ($show_num - 1) < $numMessages) {
- $endMessage = $startMessage + ($show_num-1);
- } else {
- $endMessage = $numMessages;
- }
-
- if ($endMessage < $startMessage) {
- $startMessage = $startMessage - $show_num;
- if ($startMessage < 1) { $startMessage = 1; }
- }
-
- $nextGroup = $startMessage + $show_num;
- $prevGroup = $startMessage - $show_num;
- $urlMailbox = urlencode($mailbox);
-
- do_hook('mailbox_index_before');
-
- $Message = '';
- if ($startMessage < $endMessage) {
- $Message = sprintf( _("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"), $startMessage, $endMessage, $numMessages );
- } elseif ($startMessage == $endMessage) {
- $Message = _("Viewing Message: <b>1</b> (1 total)");
- } else {
- $Message = '<br>';
- }
-
- if ($sort == 6) {
- $use = 0;
- } else {
- $use = 1;
- }
- $lMore = '';
- $rMore = '';
- if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
- $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
- $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
- } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
- $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
- $rMore = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
- } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
- $lMore = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
- $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
- }
- if ($lMore <> '') {
- $lMore .= ' | ';
- }
-
- /* Page selector block. Following code computes page links. */
- $mMore = '';
- if (!getPref($data_dir, $username, 'page_selector')
- && ($numMessages > $show_num)) {
- $j = intval( $numMessages / $show_num ); // Max pages
- $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) );
- if ($numMessages % $show_num <> 0 ) {
- $j++;
- }
- $startMessage = min( $startMessage, $numMessages );
- $p = intval( $startMessage / $show_num ) + 1;
- $i = 1;
- while( $i < $p ) {
- $pg = intval( $i );
- $start = ( ($pg-1) * $show_num ) + 1;
- $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
- "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
- $i += $k;
- }
- $mMore .= "<b>$p</b> ";
- $i += $k;
- while( $i <= $j ) {
- $pg = intval( $i );
- $start = ( ($pg-1) * $show_num ) + 1;
- $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
- "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
- $i+=$k;
- }
- $mMore .= ' | ';
- }
-
- if (! isset($msg))
- $msg = '';
- mail_message_listing_beginning($imapConnection,
- "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
- $mailbox, $sort, $Message, $lMore . $mMore . $rMore, $startMessage);
-
- $groupNum = $startMessage % ($show_num - 1);
- $real_startMessage = $startMessage;
- if ($sort == 6) {
- if ($endMessage - $startMessage < $show_num - 1) {
- $endMessage = $endMessage - $startMessage + 1;
- $startMessage = 1;
- } else if ($startMessage > $show_num) {
- $endMessage = $show_num;
- $startMessage = 1;
- }
- }
- $endVar = $endMessage + 1;
-
- // loop through and display the info for each message.
- $t = 0; // $t is used for the checkbox number
- if ($numMessages == 0) { // if there's no messages in this folder
- echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
- echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>";
- } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
- if ($sort != 6)
- $i = $startMessage;
- else
+ }
+ session_register('msort');
+ }
+ displayMessageArray($imapConnection, $num_msgs, $start_msg, $msgs, $msort, $mailbox, $sort, $color,$show_num);
+ session_register('msgs');
+}
+
+/**
+ * Generic function to convert the msgs array into an HTML table.
+ */
+function displayMessageArray($imapConnection, $num_msgs, $start_msg, &$msgs, $msort, $mailbox, $sort, $color, $show_num) {
+ global $folder_prefix, $sent_folder;
+ global $imapServerAddress, $data_dir, $username, $use_mailbox_cache;
+ global $index_order, $real_endMessage, $real_startMessage, $checkall;
+
+ /* If cache isn't already set, do it now. */
+ if (!session_is_registered('msgs')) { session_register('msgs'); }
+ if (!session_is_registered('msort')) { session_register('msort'); }
+
+ if ($start_msg + ($show_num - 1) < $num_msgs) {
+ $end_msg = $start_msg + ($show_num-1);
+ } else {
+ $end_msg = $num_msgs;
+ }
+
+ if ($end_msg < $start_msg) {
+ $start_msg = $start_msg - $show_num;
+ if ($start_msg < 1) { $start_msg = 1; }
+ }
+
+ $urlMailbox = urlencode($mailbox);
+
+ do_hook('mailbox_index_before');
+
+ $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
+ $paginator_str = get_paginator_str($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort);
+
+ if (! isset($msg)) {
+ $msg = '';
+ }
+
+ mail_message_listing_beginning
+ ($imapConnection,
+ "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$start_msg",
+ $mailbox, $sort, $msg_cnt_str, $paginator_str, $start_msg);
+
+ $groupNum = $start_msg % ($show_num - 1);
+ $real_startMessage = $start_msg;
+ if ($sort == 6) {
+ if ($end_msg - $start_msg < $show_num - 1) {
+ $end_msg = $end_msg - $start_msg + 1;
+ $start_msg = 1;
+ } else if ($start_msg > $show_num) {
+ $end_msg = $show_num;
+ $start_msg = 1;
+ }
+ }
+ $endVar = $end_msg + 1;
+
+ /* Loop through and display the info for each message. */
+ $t = 0; // $t is used for the checkbox number
+ if ($num_msgs == 0) { // if there's no messages in this folder
+ echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order) . ">\n".
+ " <CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER>\n".
+ "</TD></TR>";
+ } elseif ($start_msg == $end_msg) {
+ /* If there's only one message in the box, handle it differently. */
+ if ($sort != 6) {
+ $i = $start_msg;
+ } else {