/** * Function to map an uid list with a msg header array by uid * The mapped headers are printed with printMessage * aMailbox parameters contains info about the page we are on, the * used search criteria, the number of messages to show * * @param resource $imapConnection socket handle to imap * @param array $aMailbox array with required elements MSG_HEADERS, UIDSET, OFFSET, LIMIT * @return void **/ function displayMessageArray($imapConnection, $aMailbox) { $iSetIndx = $aMailbox['SETINDEX']; $aId = $aMailbox['UIDSET'][$iSetIndx]; $aHeaders = $aMailbox['MSG_HEADERS']; $iOffset = $aMailbox['OFFSET']; $sort = $aMailbox['SORT']; $iPageOffset = $aMailbox['PAGEOFFSET']; $sMailbox = $aMailbox['NAME']; $sSearch = isset($aMailbox['SEARCH'][$aMailbox['SETINDEX']]) ? $aMailbox['SEARCH'][$aMailbox['SETINDEX']] : false; $aSearch = $sSearch ? array('search.php', $aMailbox['SETINDEX']) : null; if ($aMailbox['SORT'] & SQSORT_THREAD) { $aIndentArray =& $aMailbox['THREAD_INDENT'][$aMailbox['SETINDEX']]; $bThread = true; } else { $bThread = false; } /* * Loop through and display the info for each message. * ($t is used for the checkbox number) */ $iEnd = $aMailbox['SHOWALL'][$iSetIndx] ? $aMailbox['EXISTS'] : $iOffset + $aMailbox['LIMIT']; for ($i = $iOffset, $t = 0; $i < $iEnd; ++$i) { if (isset($aId[$i])) { $bLast = isset($aId[$i + 1]) && isset($aHeaders[$aId[$i + 1]]) || $i == $iEnd ? false : true; if ($bThread) { $indent = isset($aIndentArray[$aId[$i]]) ? $aIndentArray[$aId[$i]] : 0; } else { $indent = 0; } $aMsg = array('HEADER' => $aHeaders[$aId[$i]], 'INDX' => $t, 'OFFSET' => $iOffset, 'PAGEOFFSET' => $iPageOffset, 'SORT' => $sort, 'SEARCH' => $aSearch, 'MAILBOX' => $sMailbox, 'INDENT' => $indent, 'LAST' => $bLast); printMessageInfo($aMsg); ++$t; } else { break; } } }
function displayMessageArray($imapConnection, $num_msgs, $start_msg, $msort, $mailbox, $sort, $color, $show_num, $where = 0, $what = 0) { global $imapServerAddress, $use_mailbox_cache, $index_order, $indent_array, $thread_sort_messages, $allow_server_sort, $server_sort_order, $PHP_SELF; $res = getEndMessage($start_msg, $show_num, $num_msgs); $start_msg = $res[0]; $end_msg = $res[1]; $urlMailbox = urlencode($mailbox); /* get indent level for subject display */ if ($thread_sort_messages == 1 && $num_msgs) { $indent_array = get_parent_level($imapConnection); } $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 is used for the checkbox number) */ $t = 0; /* messages display */ if (!$num_msgs) { /* if there's no messages in this folder */ echo html_tag('tr', html_tag('td', "<br><b>" . _("THIS FOLDER IS EMPTY") . "</b><br> ", 'center', $color[4], 'colspan="' . count($index_order) . '"')); } elseif ($start_msg == $end_msg) { /* if there's only one message in the box, handle it differently. */ if ($sort != 6) { $i = $start_msg; } else { $i = 1; } reset($msort); $k = 0; do { $key = key($msort); next($msort); $k++; } while (isset($key) && $k < $i); printMessageInfo($imapConnection, $t, true, $key, $mailbox, $real_startMessage, $where, $what); } else { $i = $start_msg; reset($msort); $k = 0; do { $key = key($msort); next($msort); $k++; } while (isset($key) && $k < $i); $not_last = true; do { if (!$i || $i == $endVar - 1) { $not_last = false; } printMessageInfo($imapConnection, $t, $not_last, $key, $mailbox, $real_startMessage, $where, $what); $key = key($msort); $t++; $i++; next($msort); } while ($i && $i < $endVar); } }