- * FIXME: Undocumented function
- *
- * @param array $messages
- * @param integer $sort sorting order
- * @return array
- */
-function calc_msort($msgs, $sort) {
- /*
- * 0 = Date (up)
- * 1 = Date (dn)
- * 2 = Name (up)
- * 3 = Name (dn)
- * 4 = Subject (up)
- * 5 = Subject (dn)
- */
-
- if (($sort == 0) || ($sort == 1)) {
- foreach ($msgs as $item) {
- $msort[$item['ID']] = $item['TIME_STAMP'];
- }
- } elseif (($sort == 2) || ($sort == 3)) {
- foreach ($msgs as $item) {
- $msort[$item['ID']] = $item['FROM-SORT'];
- }
- } elseif (($sort == 4) || ($sort == 5)) {
- foreach ($msgs as $item) {
- //echo $item['SUBJECT-SORT'] . "<br />";
- $msort[$item['ID']] = $item['SUBJECT-SORT'];
- }
- } else {
- return array_keys($msgs); //array_walk($msort, create_function('&$v,$k', '$v = $v["ID"];'));
- }
- if ($sort < 6) {
- if ($sort % 2) {
- asort($msort);
- } else {
- arsort($msort);
- }
- $msort = array_keys($msort);
- }
- return $msort;
-}
-
-/**
- * FIXME: Undocumented function
- *
- * @param mixed $imapConnection
- * @param mixed $id
- * @param mixed $count
- * @param bool $show_num
- */
-function fillMessageArray($imapConnection, $id, $count, $show_num=false) {
- return sqimap_get_small_header_list($imapConnection, $id, $show_num);
-}
-
-
-/**
- * Generic function to convert the msgs array into an HTML table.
- *
- * @param resource $imapConnection
- * @param int $num_msgs total number of messages in the mailbox
- * @param int $start_msg offset in messages to sisplay
- * @param array $msort sorted array which is used to map the index to the unsorted $msgs index
- * @param string $mailbox mail folder name
- * @param int $sort sort order. 6 means no sorting or server side / thread sort
- * @param array $color
- * @param int $show_num number of messages to show
- * @param mixed $where
- * @param mixed $what
- */
-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, $msgs;
-
-
- $urlMailbox = urlencode($mailbox);
-
- /* get indent level for subject display */
-
- // FIX ME this call is at the wrong place
- if ($thread_sort_messages == 1 && $num_msgs) {
- $indent_array = get_parent_level($imapConnection);
- }
-
- /* messages display */
-
- // if client side sorting and no sort we only fetch num_msgs so the start_msg in the $msgs
- // array must be corrected
- if ($sort == 6) {
- $i = 0;
+* 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) {
+
+ $aId = $aMailbox['UIDSET'];
+ $aHeaders = $aMailbox['MSG_HEADERS'];
+ $iOffset = $aMailbox['OFFSET'];
+ $sort = $aMailbox['SORT'];
+ $iPageOffset = $aMailbox['PAGEOFFSET'];
+ $sMailbox = $aMailbox['NAME'];
+ $aSearch = (isset($aMailbox['SEARCH'])) ? $aMailbox['SEARCH'] : false;
+ if ($aMailbox['SORT_METHOD'] == 'THREAD') {
+ $aIndentArray =& $aMailbox['THREAD_INDENT'];
+ $bThread = true;