Changeset 2dd7ee3 in github
- Timestamp:
- Jun 10, 2009 8:07:55 AM (4 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- d9c83e7
- Parents:
- 737f0da3
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (21 diffs)
-
program/lib/imap.inc (modified) (6 diffs)
-
program/steps/mail/show.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
ra54242c r2dd7ee3 2 2 =========================== 3 3 4 - Fixed many 'skip_deleted' issues (#1485634) 5 - Fixed messages list sorting on servers without SORT capability 4 6 - Colorized signatures in plain text messages 5 7 - Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI -
program/include/rcube_imap.php
r384d83a r2dd7ee3 507 507 // get message count using SEARCH 508 508 // not very performant but more precise (using UNDELETED) 509 $count = 0;510 509 $index = $this->_search_index($mailbox, $search_str); 511 if (is_array($index)) 512 { 513 $str = implode(",", $index); 514 if (!empty($str)) 515 $count = count($index); 516 } 510 $count = is_array($index) ? count($index) : 0; 517 511 } 518 512 else … … 571 565 $this->_set_sort_order($sort_field, $sort_order); 572 566 573 $max = $this->_messagecount($mailbox); 574 $start_msg = ($this->list_page-1) * $this->page_size; 575 576 list($begin, $end) = $this->_get_message_range($max, $page); 577 578 // mailbox is empty 579 if ($begin >= $end) 580 return array(); 581 582 $headers_sorted = FALSE; 567 $page = $page ? $page : $this->list_page; 583 568 $cache_key = $mailbox.'.msg'; 584 569 $cache_status = $this->check_cache_status($mailbox, $cache_key); … … 587 572 if ($cache_status>0) 588 573 { 574 $start_msg = ($page-1) * $this->page_size; 589 575 $a_msg_headers = $this->get_message_cache($cache_key, $start_msg, $start_msg+$this->page_size, $this->sort_field, $this->sort_order); 590 $headers_sorted = TRUE;576 return array_values($a_msg_headers); 591 577 } 592 578 // cache is dirty, sync it … … 596 582 return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE); 597 583 } 584 585 // retrieve headers from IMAP 586 $a_msg_headers = array(); 587 588 if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 589 { 590 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 591 $max = max($msg_index); 592 $msg_index = array_slice($msg_index, $begin, $end-$begin); 593 594 // fetch reqested headers from server 595 $this->_fetch_headers($mailbox, join(',', $msg_index), $a_msg_headers, $cache_key); 596 } 598 597 else 599 598 { 600 // retrieve headers from IMAP 601 if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 602 { 603 $mymsgidx = array_slice ($msg_index, $begin, $end-$begin); 604 $msgs = join(",", $mymsgidx); 605 } 606 else 607 { 608 $msgs = sprintf("%d:%d", $begin+1, $end); 609 $msg_index = range($begin, $end); 610 } 611 612 613 // fetch reuested headers from server 614 $a_msg_headers = array(); 615 $deleted_count = $this->_fetch_headers($mailbox, $msgs, $a_msg_headers, $cache_key); 616 617 // delete cached messages with a higher index than $max+1 618 // Changed $max to $max+1 to fix this bug : #1484295 619 $this->clear_message_cache($cache_key, $max + 1); 620 621 // kick child process to sync cache 622 // ... 623 } 599 $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", $this->sort_field, $this->skip_deleted); 600 601 if (empty($a_index)) 602 return array(); 603 604 asort($a_index); // ASC 605 $msg_index = array_keys($a_index); 606 $max = max($msg_index); 607 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 608 $msg_index = array_slice($msg_index, $begin, $end-$begin); 609 610 // fetch reqested headers from server 611 $this->_fetch_headers($mailbox, join(",", $msg_index), $a_msg_headers, $cache_key); 612 } 613 614 // delete cached messages with a higher index than $max+1 615 // Changed $max to $max+1 to fix this bug : #1484295 616 $this->clear_message_cache($cache_key, $max + 1); 617 618 // kick child process to sync cache 619 // ... 624 620 625 621 // return empty array if no messages found 626 if (!is_array($a_msg_headers) || empty($a_msg_headers)) {622 if (!is_array($a_msg_headers) || empty($a_msg_headers)) 627 623 return array(); 628 } 629 630 // if not already sorted 631 if (!$headers_sorted) 632 { 633 // use this class for message sorting 634 $sorter = new rcube_header_sorter(); 635 $sorter->set_sequence_numbers($msg_index); 636 $sorter->sort_headers($a_msg_headers); 637 638 if ($this->sort_order == 'DESC') 639 $a_msg_headers = array_reverse($a_msg_headers); 640 } 624 625 // use this class for message sorting 626 $sorter = new rcube_header_sorter(); 627 $sorter->set_sequence_numbers($msg_index); 628 $sorter->sort_headers($a_msg_headers); 629 630 if ($this->sort_order == 'DESC') 631 $a_msg_headers = array_reverse($a_msg_headers); 641 632 642 633 return array_values($a_msg_headers); … … 662 653 $msgs = $this->search_set; 663 654 $a_msg_headers = array(); 664 $start_msg = ($this->list_page-1) * $this->page_size; 655 $page = $page ? $page : $this->list_page; 656 $start_msg = ($page-1) * $this->page_size; 665 657 666 658 $this->_set_sort_order($sort_field, $sort_order); … … 742 734 function _get_message_range($max, $page) 743 735 { 744 $start_msg = ($ this->list_page-1) * $this->page_size;736 $start_msg = ($page-1) * $this->page_size; 745 737 746 738 if ($page=='all') … … 766 758 return array($begin, $end); 767 759 } 768 769 760 770 761 … … 777 768 * @param array Reference to message headers array 778 769 * @param array Array with cache index 779 * @return int Number of deleted messages770 * @return int Messages count 780 771 * @access private 781 772 */ … … 785 776 $cache_index = $this->get_message_cache_index($cache_key); 786 777 787 // fetch re uested headers from server778 // fetch reqested headers from server 788 779 $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs, false, $this->fetch_add_headers); 789 $deleted_count = 0;790 780 791 781 if (!empty($a_header_index)) 792 782 { 793 783 foreach ($a_header_index as $i => $headers) 794 { 784 { 785 /* 795 786 if ($headers->deleted && $this->skip_deleted) 796 787 { … … 799 790 $this->remove_message_cache($cache_key, $headers->uid); 800 791 801 $deleted_count++;802 792 continue; 803 793 } 804 794 */ 805 795 // add message to cache 806 796 if ($this->caching_enabled && $cache_index[$headers->id] != $headers->uid) … … 811 801 } 812 802 813 return $deleted_count;803 return count($a_msg_headers); 814 804 } 815 805 … … 847 837 else 848 838 { 849 $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field, false);839 $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field, $this->skip_deleted); 850 840 851 841 if ($this->sort_order=="ASC") … … 875 865 // fetch complete message index 876 866 $msg_count = $this->_messagecount($mailbox); 877 if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, '')))867 if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 878 868 { 879 869 if ($this->sort_order == 'DESC') … … 884 874 else 885 875 { 886 $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", $this->sort_field );876 $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", $this->sort_field, $this->skip_deleted); 887 877 888 878 if ($this->sort_order=="ASC") … … 905 895 $cache_key = $mailbox.'.msg'; 906 896 $cache_index = $this->get_message_cache_index($cache_key); 907 $msg_count = $this->_messagecount($mailbox);908 897 909 898 // fetch complete message index 910 $a_message_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:$msg_count", 'UID'); 899 $a_message_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", 'UID', $this->skip_deleted); 900 901 if ($a_message_index === false) 902 return false; 911 903 912 904 foreach ($a_message_index as $id => $uid) … … 932 924 } 933 925 934 935 // fetch complete headers and add to cache 936 $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, false, $this->fetch_add_headers); 937 $this->add_message_cache($cache_key, $headers->id, $headers); 938 } 939 926 $toupdate[] = $id; 927 } 928 929 // fetch complete headers and add to cache 930 if (!empty($toupdate)) { 931 if ($headers = iil_C_FetchHeader($this->conn, $mailbox, join(',', $toupdate), false, $this->fetch_add_headers)) 932 foreach ($headers as $header) 933 $this->add_message_cache($cache_key, $header->id, $header); 934 } 935 940 936 // those ids that are still in cache_index have been deleted 941 937 if (!empty($cache_index)) … … 1007 1003 function _search_index($mailbox, $criteria='ALL', $charset=NULL, $sort_field=NULL) 1008 1004 { 1005 $orig_criteria = $criteria; 1006 1009 1007 if ($this->skip_deleted && !preg_match('/UNDELETED/', $criteria)) 1010 1008 $criteria = 'UNDELETED '.$criteria; … … 1025 1023 unset($a_messages[$i]); 1026 1024 } 1025 1026 // update messagecount cache ? 1027 // $a_mailbox_cache = get_cache('messagecount'); 1028 // $a_mailbox_cache[$mailbox][$criteria] = sizeof($a_messages); 1029 // $this->update_cache('messagecount', $a_mailbox_cache); 1027 1030 1028 1031 return $a_messages; … … 2220 2223 */ 2221 2224 function check_cache_status($mailbox, $cache_key) 2222 {2225 { 2223 2226 if (!$this->caching_enabled) 2224 2227 return -3; … … 2230 2233 // console("Cache check: $msg_count !== ".count($cache_index)); 2231 2234 2232 if ($cache_count==$msg_count) 2233 { 2234 // get highest index 2235 $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count", false, $this->fetch_add_headers); 2236 $cache_uid = array_pop($cache_index); 2235 if ($cache_count==$msg_count) { 2236 if ($this->skip_deleted) { 2237 $h_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", 'UID', $this->skip_deleted); 2238 2239 if (sizeof($h_index) == $cache_count) { 2240 $cache_index = array_flip($cache_index); 2241 foreach ($h_index as $idx => $uid) 2242 unset($cache_index[$uid]); 2243 2244 if (empty($cache_index)) 2245 return 1; 2246 } 2247 return -2; 2248 } else { 2249 // get highest index 2250 $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count"); 2251 $cache_uid = array_pop($cache_index); 2237 2252 2238 // uids of highest message matches -> cache seems OK2239 if ($cache_uid == $header->uid)2240 return 1;2241 2253 // uids of highest message matches -> cache seems OK 2254 if ($cache_uid == $header->uid) 2255 return 1; 2256 } 2242 2257 // cache is dirty 2243 2258 return -1; 2244 }2259 } 2245 2260 // if cache count differs less than 10% report as dirty 2246 2261 else if (abs($msg_count - $cache_count) < $msg_count/10) … … 2248 2263 else 2249 2264 return -2; 2250 }2265 } 2251 2266 2252 2267 /** -
program/lib/imap.inc
r07f0b94 r2dd7ee3 85 85 - added UID EXPUNGE support 86 86 - fixed problem with double quotes and spaces in folder names in LIST and LSUB 87 - rewritten iil_C_FetchHeaderIndex() 87 88 88 89 ********************************************************/ … … 936 937 } 937 938 938 function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field, 939 $normalize=true) { 940 global $IMAP_USE_INTERNAL_DATE; 941 942 $c=0; 943 $result=array(); 944 $fp = $conn->fp; 945 946 if (empty($index_field)) { 947 $index_field = 'DATE'; 948 } 949 $index_field = strtoupper($index_field); 950 939 function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field='', $skip_deleted=true) { 940 951 941 list($from_idx, $to_idx) = explode(':', $message_set); 952 if (empty($message_set) || (isset($to_idx)953 && (int)$from_idx > (int)$to_idx)) {942 if (empty($message_set) || 943 (isset($to_idx) && $to_idx != '*' && (int)$from_idx > (int)$to_idx)) { 954 944 return false; 955 945 } 956 957 //$fields_a['DATE'] = ($IMAP_USE_INTERNAL_DATE?6:1); 946 947 $index_field = empty($index_field) ? 'DATE' : strtoupper($index_field); 948 958 949 $fields_a['DATE'] = 1; 959 $fields_a['INTERNALDATE'] = 6;950 $fields_a['INTERNALDATE'] = 4; 960 951 $fields_a['FROM'] = 1; 961 952 $fields_a['REPLY-TO'] = 1; … … 966 957 $fields_a['SIZE'] = 2; 967 958 $fields_a['SEEN'] = 3; 968 $fields_a['RECENT'] = 4; 969 $fields_a['DELETED'] = 5; 970 971 $mode=$fields_a[$index_field]; 972 if (!($mode > 0)) { 973 return false; 974 } 975 959 $fields_a['RECENT'] = 3; 960 $fields_a['DELETED'] = 3; 961 962 if (!($mode = $fields_a[$index_field])) { 963 return false; 964 } 965 976 966 /* Do "SELECT" command */ 977 967 if (!iil_C_Select($conn, $mailbox)) { 978 return false; 979 } 980 981 /* FETCH date,from,subject headers */ 982 if ($mode == 1) { 983 $key = 'fhi' . ($c++); 984 $request = $key . " FETCH $message_set (BODY.PEEK[HEADER.FIELDS ($index_field)])"; 985 if (!iil_PutLine($fp, $request)) { 986 return false; 987 } 988 do { 989 990 $line=chop(iil_ReadLine($fp, 200)); 991 $a=explode(' ', $line); 992 if (($line[0] == '*') && ($a[2] == 'FETCH') 993 && ($line[strlen($line)-1] != ')')) { 994 $id=$a[1]; 995 996 $str=$line=chop(iil_ReadLine($fp, 300)); 997 998 while ($line[0] != ')') { //caution, this line works only in this particular case 999 $line=chop(iil_ReadLine($fp, 300)); 1000 if ($line[0] != ')') { 1001 if (ord($line[0]) <= 32) { //continuation from previous header line 1002 $str.= ' ' . trim($line); 1003 } 1004 if ((ord($line[0]) > 32) || (strlen($line[0]) == 0)) { 1005 list($field, $string) = iil_SplitHeaderLine($str); 1006 if (strcasecmp($field, 'date') == 0) { 1007 $result[$id] = iil_StrToTime($string); 1008 } else { 1009 $result[$id] = str_replace('"', '', $string); 1010 if ($normalize) { 1011 $result[$id] = strtoupper($result[$id]); 1012 } 1013 } 1014 $str=$line; 1015 } 1016 } 968 return false; 969 } 970 971 // build FETCH command string 972 $key = 'fhi0'; 973 $deleted = $skip_deleted ? ' FLAGS' : ''; 974 975 if ($mode == 1) 976 $request = " FETCH $message_set (BODY.PEEK[HEADER.FIELDS ($index_field)]$deleted)"; 977 else if ($mode == 2) { 978 if ($index_field == 'SIZE') 979 $request = " FETCH $message_set (RFC822.SIZE$deleted)"; 980 else 981 $request = " FETCH $message_set ($index_field$deleted)"; 982 } else if ($mode == 3) 983 $request = " FETCH $message_set (FLAGS)"; 984 else // 4 985 $request = " FETCH $message_set (INTERNALDATE$deleted)"; 986 987 $request = $key . $request; 988 989 if (!iil_PutLine($conn->fp, $request)) 990 return false; 991 992 $result = array(); 993 994 do { 995 $line = chop(iil_ReadLine($conn->fp, 200)); 996 $line = iil_MultLine($conn->fp, $line); 997 998 if (preg_match('/^\* ([0-9]+) FETCH/', $line, $m)) { 999 1000 $id = $m[1]; 1001 $flags = NULL; 1002 1003 if ($skip_deleted && preg_match('/FLAGS \(([^)]+)\)/', $line, $matches)) { 1004 $flags = explode(' ', strtoupper($matches[1])); 1005 if (in_array('\\DELETED', $flags)) { 1006 $deleted[$id] = $id; 1007 continue; 1017 1008 } 1018 1009 } 1019 /* 1020 $end_pos = strlen($line)-1; 1021 if (($line[0]=="*") && ($a[2]=="FETCH") && ($line[$end_pos]=="}")) { 1022 $id = $a[1]; 1023 $pos = strrpos($line, "{")+1; 1024 $bytes = (int)substr($line, $pos, $end_pos-$pos); 1025 $received = 0; 1026 do { 1027 $line = iil_ReadLine($fp, 0); 1028 $received += strlen($line); 1029 $line = chop($line); 1030 1031 if ($received>$bytes) { 1032 break; 1033 } else if (!$line) { 1034 continue; 1010 1011 if ($mode == 1) { 1012 if (preg_match('/BODY\[HEADER\.FIELDS \((DATE|FROM|REPLY-TO|SENDER|TO|SUBJECT)\)\] (.*)/', $line, $matches)) { 1013 $value = preg_replace(array('/^"*[a-z]+:/i', '/\s+$/sm'), array('', ''), $matches[2]); 1014 $value = trim($value); 1015 if ($index_field == 'DATE') { 1016 $result[$id] = iil_StrToTime($value); 1017 } else { 1018 $result[$id] = $value; 1035 1019 } 1036 1037 list($field, $string) = explode(': ', $line); 1038 1039 if (strcasecmp($field, 'date') == 0) { 1040 $result[$id] = iil_StrToTime($string); 1041 } else if ($index_field != 'DATE') { 1042 $result[$id]=strtoupper(str_replace('"', '', $string)); 1043 } 1044 } while ($line[0] != ')'); 1045 }Â else { 1046 //one line response, not expected so ignore 1047 } 1048 */ 1049 } while (!iil_StartsWith($line, $key, true)); 1050 1051 }else if ($mode == 6) { 1052 1053 $key = 'fhi' . ($c++); 1054 $request = $key . " FETCH $message_set (INTERNALDATE)"; 1055 if (!iil_PutLine($fp, $request)) { 1056 return false; 1057 } 1058 do { 1059 $line=chop(iil_ReadLine($fp, 200)); 1060 if ($line[0] == '*') { 1061 /* 1062 * original: 1063 * "* 10 FETCH (INTERNALDATE "31-Jul-2002 09:18:02 -0500")" 1064 */ 1065 $paren_pos = strpos($line, '('); 1066 $foo = substr($line, 0, $paren_pos); 1067 $a = explode(' ', $foo); 1068 $id = $a[1]; 1069 1070 $open_pos = strpos($line, '"') + 1; 1071 $close_pos = strrpos($line, '"'); 1072 if ($open_pos && $close_pos) { 1073 $len = $close_pos - $open_pos; 1074 $time_str = substr($line, $open_pos, $len); 1075 $result[$id] = strtotime($time_str); 1020 } else { 1021 $result[$id] = ''; 1076 1022 } 1077 } else { 1078 $a = explode(' ', $line); 1079 } 1080 } while (!iil_StartsWith($a[0], $key, true)); 1081 } else { 1082 if ($mode >= 3) { 1083 $field_name = 'FLAGS'; 1084 } else if ($index_field == 'SIZE') { 1085 $field_name = 'RFC822.SIZE'; 1086 } else { 1087 $field_name = $index_field; 1088 } 1089 1090 /* FETCH uid, size, flags */ 1091 $key = 'fhi' .($c++); 1092 $request = $key . " FETCH $message_set ($field_name)"; 1093 1094 if (!iil_PutLine($fp, $request)) { 1095 return false; 1096 } 1097 do { 1098 $line=chop(iil_ReadLine($fp, 200)); 1099 $a = explode(' ', $line); 1100 if (($line[0] == '*') && ($a[2] == 'FETCH')) { 1101 $line = str_replace('(', '', $line); 1102 $line = str_replace(')', '', $line); 1103 $a = explode(' ', $line); 1104 1105 $id = $a[1]; 1106 1107 if (isset($result[$id])) { 1108 continue; //if we already got the data, skip forward 1023 } else if ($mode == 2) { 1024 if (preg_match('/\((UID|RFC822\.SIZE) ([0-9]+)/', $line, $matches)) { 1025 $result[$id] = trim($matches[2]); 1026 } else { 1027 $result[$id] = 0; 1109 1028 } 1110 if ($a[3]!=$field_name) { 1111 continue; //make sure it's returning what we requested 1029 } else if ($mode == 3) { 1030 if (!$flags && preg_match('/FLAGS \(([^)]+)\)/', $line, $matches)) { 1031 $flags = explode(' ', $matches[1]); 1112 1032 } 1113 1114 /* Caution, bad assumptions, next several lines */1115 if ( $mode == 2) {1116 $result[$id] = $a[4];1033 $result[$id] = in_array('\\'.$index_field, $flags) ? 1 : 0; 1034 } else if ($mode == 4) { 1035 if (preg_match('/INTERNALDATE "([^"]+)"/', $line, $matches)) { 1036 $result[$id] = strtotime($matches[1]); 1117 1037 } else { 1118 $haystack = strtoupper($line); 1119 $result[$id] = (strpos($haystack, $index_field) > 0 ? "F" : "N"); 1038 $result[$id] = 0; 1120 1039 } 1121 1040 } 1122 } while (!iil_StartsWith($line, $key, true)); 1123 } 1124 1041 } 1042 } while (!iil_StartsWith($line, $key, true)); 1043 1044 /* 1125 1045 //check number of elements... 1126 list($start_mid, $end_mid) = explode(':', $message_set); 1127 if (is_numeric($start_mid) && is_numeric($end_mid)) { 1046 if (is_numeric($from_idx) && is_numeric($to_idx)) { 1128 1047 //count how many we should have 1129 $should_have = $ end_mid - $start_mid +1;1048 $should_have = $to_idx - $from_idx + 1; 1130 1049 1131 1050 //if we have less, try and fill in the "gaps" 1132 1051 if (count($result) < $should_have) { 1133 for ($i=$ start_mid; $i<=$end_mid; $i++) {1052 for ($i=$from_idx; $i<=$to_idx; $i++) { 1134 1053 if (!isset($result[$i])) { 1135 1054 $result[$i] = ''; … … 1138 1057 } 1139 1058 } 1059 */ 1140 1060 return $result; 1141 1061 } … … 1521 1441 $fp = $conn->fp; 1522 1442 1523 list($from_idx, $to_idx) = explode(':', $message_set);1524 if (empty($message_set) || (isset($to_idx)1525 && (int)$from_idx > (int)$to_idx)) {1526 return false;1527 }1528 1529 1443 /* Do "SELECT" command */ 1530 1444 if (!iil_C_Select($conn, $mailbox)) { … … 1532 1446 return false; 1533 1447 } 1448 1449 $message_set = iil_CompressMessageSet($message_set); 1534 1450 1535 1451 if ($add) -
program/steps/mail/show.inc
ra25d396 r2dd7ee3 99 99 $next = $prev = $first = $last = -1; 100 100 101 if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 102 $IMAP->get_capability('sort')) || !empty($_REQUEST['_search'])) 103 { 104 // Only if we use custom sorting 105 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 106 107 $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index); 108 109 $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ; 110 $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1; 111 $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ; 112 $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1; 113 } 114 else 101 if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] != 'DESC' 102 && empty($_REQUEST['_search']) && !$IMAP->skip_deleted) 115 103 { 116 104 // this assumes that we are sorted by date_DESC … … 123 111 $next = $IMAP->get_uid($seq - 1); 124 112 $last = $IMAP->get_uid(1); 113 } 114 else 115 { 116 // Only if we use custom sorting 117 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 118 119 $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index); 120 121 $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1 ; 122 $first = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[0]) : -1; 123 $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1 ; 124 $last = count($a_msg_index)>0 ? $IMAP->get_uid($a_msg_index[count($a_msg_index)-1]) : -1; 125 125 } 126 126
Note: See TracChangeset
for help on using the changeset viewer.
