Changeset 2983 in subversion
- Timestamp:
- Sep 23, 2009 8:32:09 AM (4 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 10 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
program/include/rcmail.php (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (14 diffs)
-
program/js/app.js (modified) (1 diff)
-
program/localization/en_US/labels.inc (modified) (1 diff)
-
program/localization/pl_PL/labels.inc (modified) (1 diff)
-
program/steps/mail/list.inc (modified) (1 diff)
-
program/steps/settings/edit_prefs.inc (modified) (1 diff)
-
program/steps/settings/save_prefs.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r2977 r2983 2 2 =========================== 3 3 4 - Fix Received header format 5 - Implemented sorting by message index - added 'index_sort' option (#1485936) 4 6 - Fix dl() use in installer (#1486150) 5 7 - Added 'ldap_debug' option -
trunk/roundcubemail/config/main.inc.php.dist
r2976 r2983 444 444 $rcmail_config['display_next'] = FALSE; 445 445 446 // If true, messages list will be sorted by message index instead of message date 447 $rcmail_config['index_sort'] = TRUE; 448 446 449 // end of config file 447 450 ?> -
trunk/roundcubemail/program/include/rcmail.php
r2976 r2983 367 367 $this->imap->debug_level = $this->config->get('debug_level'); 368 368 $this->imap->skip_deleted = $this->config->get('skip_deleted'); 369 $this->imap->index_sort = $this->config->get('index_sort', true); 369 370 370 371 // enable caching of imap data -
trunk/roundcubemail/program/include/rcube_imap.php
r2974 r2983 51 51 var $sort_field = 'date'; 52 52 var $sort_order = 'DESC'; 53 var $index_sort = true; 53 54 var $delimiter = NULL; 54 55 var $caching_enabled = FALSE; … … 599 600 $a_msg_headers = array(); 600 601 601 if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 602 // use message index sort for sorting by Date (for better performance) 603 if ($this->index_sort && $this->sort_field == 'date') 604 { 605 if ($this->skip_deleted) { 606 $msg_index = $this->_search_index($mailbox, 'ALL'); 607 $max = max($msg_index); 608 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 609 $msg_index = array_slice($msg_index, $begin, $end-$begin); 610 } else if ($max = iil_C_CountMessages($this->conn, $mailbox)) { 611 list($begin, $end) = $this->_get_message_range($max, $page); 612 $msg_index = range($begin+1, $end); 613 } else 614 return array(); 615 616 if ($slice) 617 $msg_index = array_slice($msg_index, ($this->sort_order == 'DESC' ? 0 : -$slice), $slice); 618 619 // fetch reqested headers from server 620 $this->_fetch_headers($mailbox, join(",", $msg_index), $a_msg_headers, $cache_key); 621 } 622 // use SORT command 623 else if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 602 624 { 603 625 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); … … 611 633 $this->_fetch_headers($mailbox, join(',', $msg_index), $a_msg_headers, $cache_key); 612 634 } 635 // fetch specified header for all messages and sort 613 636 else 614 637 { … … 678 701 $this->_set_sort_order($sort_field, $sort_order); 679 702 703 // quickest method 704 if ($this->index_sort && $this->search_sort_field == 'date' && $this->sort_field == 'date') 705 { 706 if ($sort_order == 'DESC') 707 $msgs = array_reverse($msgs); 708 709 // get messages uids for one page 710 $msgs = array_slice(array_values($msgs), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); 711 712 if ($slice) 713 $msgs = array_slice($msgs, -$slice, $slice); 714 715 // fetch headers 716 $this->_fetch_headers($mailbox, join(',',$msgs), $a_msg_headers, NULL); 717 718 // I didn't found in RFC that FETCH always returns messages sorted by index 719 $sorter = new rcube_header_sorter(); 720 $sorter->set_sequence_numbers($msgs); 721 $sorter->sort_headers($a_msg_headers); 722 723 return array_values($a_msg_headers); 724 } 680 725 // sorted messages, so we can first slice array and then fetch only wanted headers 681 if ($this->get_capability('sort') ) // SORT searching result726 if ($this->get_capability('sort') && (!$this->index_sort || $this->sort_field != 'date')) // SORT searching result 682 727 { 683 728 // reset search set if sorting field has been changed 684 729 if ($this->sort_field && $this->search_sort_field != $this->sort_field) 685 {686 730 $msgs = $this->search('', $this->search_string, $this->search_charset, $this->sort_field); 687 }688 731 689 732 // return empty array if no messages found … … 711 754 else { // SEARCH searching result, need sorting 712 755 $cnt = count($msgs); 713 if ($cnt > 300 && $cnt > $this->page_size) { // experimantal value for best result 756 // 300: experimantal value for best result 757 if (($cnt > 300 && $cnt > $this->page_size) || ($this->index_sort && $this->sort_field == 'date')) { 714 758 // use memory less expensive (and quick) method for big result set 715 759 $a_index = $this->message_index('', $this->sort_field, $this->sort_order); … … 845 889 $key = "{$mailbox}:{$this->sort_field}:{$this->sort_order}:{$this->search_string}.msgi"; 846 890 847 // we have a saved search result .get index from there891 // we have a saved search result, get index from there 848 892 if (!isset($this->cache[$key]) && $this->search_string && $mailbox == $this->mailbox) 849 893 { 850 894 $this->cache[$key] = array(); 851 895 852 if ($this->get_capability('sort')) 896 // use message index sort for sorting by Date 897 if ($this->index_sort && $this->sort_field == 'date') 898 { 899 $msgs = $this->search_set; 900 901 if ($this->search_sort_field != 'date') 902 sort($msgs); 903 904 if ($this->sort_order == 'DESC') 905 $this->cache[$key] = array_reverse($msgs); 906 else 907 $this->cache[$key] = $msgs; 908 } 909 // sort with SORT command 910 else if ($this->get_capability('sort')) 853 911 { 854 912 if ($this->sort_field && $this->search_sort_field != $this->sort_field) … … 888 946 } 889 947 948 // use message index sort for sorting by Date 949 if ($this->index_sort && $this->sort_field == 'date') 950 { 951 if ($this->skip_deleted) { 952 $a_index = $this->_search_index($mailbox, 'ALL'); 953 } else if ($max = $this->_messagecount($mailbox)) { 954 $a_index = range(1, $max); 955 } 956 957 if ($this->sort_order == 'DESC') 958 $a_index = array_reverse($a_index); 959 960 $this->cache[$key] = $a_index; 961 } 890 962 // fetch complete message index 891 if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')))963 else if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) 892 964 { 893 965 if ($this->sort_order == 'DESC') … … 1033 1105 $criteria = 'UNDELETED '.$criteria; 1034 1106 1035 if ($sort_field && $this->get_capability('sort')) 1036 { 1107 if ($sort_field && $this->get_capability('sort') && (!$this->index_sort || $sort_field != 'date')) { 1037 1108 $charset = $charset ? $charset : $this->default_charset; 1038 1109 $a_messages = iil_C_Sort($this->conn, $mailbox, $sort_field, $criteria, FALSE, $charset); 1039 1110 } 1040 else 1041 $a_messages = iil_C_Search($this->conn, $mailbox, ($charset ? "CHARSET $charset " : '') . $criteria); 1042 1111 else { 1112 if ($orig_criteria == 'ALL') { 1113 $max = $this->_messagecount($mailbox); 1114 $a_messages = $max ? range(1, $max) : array(); 1115 } 1116 else { 1117 $a_messages = iil_C_Search($this->conn, $mailbox, ($charset ? "CHARSET $charset " : '') . $criteria); 1118 1119 // I didn't found that SEARCH always returns sorted IDs 1120 if ($this->index_sort && $this->sort_field == 'date') 1121 sort($a_messages); 1122 } 1123 } 1043 1124 // update messagecount cache ? 1044 1125 // $a_mailbox_cache = get_cache('messagecount'); … … 2220 2301 * @param string Mailbox name 2221 2302 * @param string Internal cache key 2222 * @return int -3 = off, -2 = incomplete, -1 = dirty2303 * @return int Cache status: -3 = off, -2 = incomplete, -1 = dirty 2223 2304 */ 2224 2305 private function check_cache_status($mailbox, $cache_key) … … 2227 2308 return -3; 2228 2309 2229 $cache_index = $this->get_message_cache_index($cache_key , TRUE);2310 $cache_index = $this->get_message_cache_index($cache_key); 2230 2311 $msg_count = $this->_messagecount($mailbox); 2231 2312 $cache_count = count($cache_index); … … 2234 2315 if (!$msg_count) 2235 2316 return $cache_count ? -2 : 1; 2236 2317 2318 // @TODO: We've got one big performance problem in cache status checking method 2319 // E.g. mailbox contains 1000 messages, in cache table we've got first 100 2320 // of them. Now if we want to display only that 100 (which we've got) 2321 // check_cache_status returns 'incomplete' and messages are fetched 2322 // from IMAP instead of DB. 2323 2237 2324 if ($cache_count==$msg_count) { 2238 2325 if ($this->skip_deleted) { … … 2249 2336 return -2; 2250 2337 } else { 2251 // get highest index2252 $ header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count");2338 // get UID of message with highest index 2339 $uid = iil_C_ID2UID($this->conn, $mailbox, $msg_count); 2253 2340 $cache_uid = array_pop($cache_index); 2254 2341 2255 2342 // uids of highest message matches -> cache seems OK 2256 if ($cache_uid == $ header->uid)2343 if ($cache_uid == $uid) 2257 2344 return 1; 2258 2345 } … … 2275 2362 $db_header_fields = array('idx', 'uid', 'subject', 'from', 'to', 'cc', 'date', 'size'); 2276 2363 2277 if (!in_array($sort_field, $db_header_fields)) 2364 $config = rcmail::get_instance()->config; 2365 2366 // use idx sort for sorting by Date with index_sort=true or for unknown field 2367 if (($sort_field == 'date' && $this->index_sort) 2368 || !in_array($sort_field, $db_header_fields)) { 2278 2369 $sort_field = 'idx'; 2370 } 2279 2371 2280 2372 if ($this->caching_enabled && !isset($this->cache[$cache_key])) … … 2350 2442 if (!empty($sa_message_index[$key]) && !$force) 2351 2443 return $sa_message_index[$key]; 2444 2445 // use idx sort for sorting by Date with index_sort=true 2446 if ($sort_field == 'date' && $this->index_sort) 2447 $sort_field = 'idx'; 2352 2448 2353 2449 $sa_message_index[$key] = array(); -
trunk/roundcubemail/program/js/app.js
r2978 r2983 3019 3019 target = window.frames[this.env.contentframe]; 3020 3020 } 3021 3022 3021 target.location.href = this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url; 3023 3022 } -
trunk/roundcubemail/program/localization/en_US/labels.inc
r2831 r2983 307 307 $labels['checkallfolders'] = 'Check all folders for new messages'; 308 308 $labels['displaynext'] = 'After message delete/move display the next message'; 309 $labels['indexsort'] = 'Use message index for sorting by date'; 309 310 $labels['mainoptions'] = 'Main Options'; 310 311 $labels['section'] = 'Section'; -
trunk/roundcubemail/program/localization/pl_PL/labels.inc
r2836 r2983 267 267 $labels['skipdeleted'] = 'Ukryj wiadomoÅci oznaczone do usuniÄcia'; 268 268 $labels['autosavedraft'] = 'Automatyczny zapis tworzonej wiadomoÅci'; 269 $labels['indexsort'] = 'Stosuj indeks wiadomoÅci do sortowania wg daty'; 269 270 $labels['keepalive'] = 'Sprawdzaj czy nadeszÅy nowe wiadomoÅci'; 270 271 $labels['everynminutes'] = 'co $n minut(y)'; -
trunk/roundcubemail/program/steps/mail/list.inc
r2960 r2983 50 50 { 51 51 $search_request = md5($mbox_name.$_SESSION['search_filter']); 52 53 52 $IMAP->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col); 54 53 $_SESSION['search'][$search_request] = $IMAP->get_search_set(); 55 54 $OUTPUT->set_env('search_request', $search_request); 56 55 } 57 58 56 59 57 // fetch message headers -
trunk/roundcubemail/program/steps/settings/edit_prefs.inc
r2830 r2983 163 163 } 164 164 165 // Show checkbox for toggling 'index_sort' 166 if (!isset($no_override['index_sort'])) { 167 $field_id = 'rcmfd_indexsort'; 168 $input_indexsort = new html_checkbox(array('name' => '_index_sort', 'id' => $field_id, 'value' => 1)); 169 170 $blocks['list']['options']['index_sort'] = array( 171 'title' => html::label($field_id, Q(rcube_label('indexsort'))), 172 'content' => $input_indexsort->show($config['index_sort']?1:0), 173 ); 174 } 175 165 176 // show drop-down for available skins 166 177 if (!isset($no_override['skin'])) { -
trunk/roundcubemail/program/steps/settings/save_prefs.inc
r2873 r2983 33 33 'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE, 34 34 'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'], 35 'index_sort' => isset($_POST['_index_sort']) ? TRUE : FALSE, 35 36 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, 36 37 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'],
Note: See TracChangeset
for help on using the changeset viewer.
