Changeset 422 in subversion
- Timestamp:
- Dec 20, 2006 9:27:47 AM (7 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 5 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.inc (modified) (14 diffs)
-
program/steps/mail/list.inc (modified) (1 diff)
-
program/steps/mail/move_del.inc (modified) (2 diffs)
-
program/steps/mail/search.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r412 r422 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2006/12/20 (thomasb) 5 ---------- 6 - Fixed wrong message listing when showing search results (closes #1484131) 7 - Introduced functions Q() and JQ() as aliases for rep_specialchars_output() 8 - Show remote images when opening HTML message part as attachment 9 3 10 4 11 2006/12/17 (thomasb) -
trunk/roundcubemail/program/include/rcube_imap.inc
r384 r422 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2006, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 36 36 * @package RoundCube Webmail 37 37 * @author Thomas Bruederli <roundcube@gmail.com> 38 * @version 1.3 438 * @version 1.36 39 39 * @link http://ilohamail.org 40 40 */ … … 61 61 var $capabilities = array(); 62 62 var $skip_deleted = FALSE; 63 var $search_set = NULL; 64 var $search_subject = ''; 65 var $search_string = ''; 66 var $search_charset = ''; 63 67 var $debug_level = 1; 64 68 … … 266 270 $this->page_size = (int)$size; 267 271 } 272 273 274 /** 275 * Save a set of message ids for future message listing methods 276 * 277 * @param array List of IMAP fields to search in 278 * @param string Search string 279 * @param array List of message ids or NULL if empty 280 */ 281 function set_search_set($subject, $str=null, $msgs=null, $charset=null) 282 { 283 if (is_array($subject) && $str == null && $msgs == null) 284 list($subject, $str, $msgs, $charset) = $subject; 285 if ($msgs != null && !is_array($msgs)) 286 $msgs = split(',', $msgs); 287 288 $this->search_subject = $subject; 289 $this->search_string = $str; 290 $this->search_set = is_array($msgs) ? $msgs : NULL; 291 $this->search_charset = $charset; 292 } 293 294 295 /** 296 * Return the saved search set as hash array 297 */ 298 function get_search_set() 299 { 300 return array($this->search_subject, $this->search_string, $this->search_set, $this->search_charset); 301 } 268 302 269 303 … … 403 437 if (empty($mailbox)) 404 438 $mailbox = $this->mailbox; 439 440 // count search set 441 if ($this->search_set && $mailbox == $this->mailbox && $mode == 'ALL') 442 return count($this->search_set); 405 443 406 444 $a_mailbox_cache = $this->get_cache('messagecount'); … … 482 520 if (!strlen($mailbox)) 483 521 return array(); 484 522 523 // use saved message set 524 if ($this->search_set && $mailbox == $this->mailbox) 525 return $this->_list_header_set($mailbox, $this->search_set, $page, $sort_field, $sort_order); 526 485 527 if ($sort_field!=NULL) 486 528 $this->sort_field = $sort_field; … … 493 535 list($begin, $end) = $this->_get_message_range($max, $page); 494 536 495 // mailbox is empty537 // mailbox is empty 496 538 if ($begin >= $end) 497 539 return array(); 498 540 499 541 $headers_sorted = FALSE; 500 542 $cache_key = $mailbox.'.msg'; … … 615 657 616 658 // return empty array if no messages found 617 if (!is_array($a_msg_headers) || empty($a_msg_headers))618 return array();659 if (!is_array($a_msg_headers) || empty($a_msg_headers)) 660 return array(); 619 661 620 662 // if not already sorted 621 663 $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); 622 664 623 // only return the requested part of the set624 return array_slice(array_values($a_msg_headers), $start_msg, min($max-$start_msg, $this->page_size));665 // only return the requested part of the set 666 return array_slice(array_values($a_msg_headers), $start_msg, min($max-$start_msg, $this->page_size)); 625 667 } 626 668 … … 831 873 { 832 874 $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; 833 if ($str && $criteria) 875 876 // have an array of criterias => execute multiple searches 877 if (is_array($criteria) && $str) 878 { 879 $results = array(); 880 foreach ($criteria as $crit) 881 $results = array_merge($results, $this->search($mbox_name, $crit, $str, $charset)); 882 883 $results = array_unique($results); 884 $this->set_search_set($criteria, $str, $results, $charset); 885 return $results; 886 } 887 else if ($str && $criteria) 834 888 { 835 889 $search = (!empty($charset) ? "CHARSET $charset " : '') . sprintf("%s {%d}\r\n%s", $criteria, strlen($str), $str); … … 840 894 $results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, 'ISO-8859-1'), 'ISO-8859-1'); 841 895 896 $this->set_search_set($criteria, $str, $results, $charset); 842 897 return $results; 843 898 } … … 866 921 867 922 return $a_messages; 923 } 924 925 926 /** 927 * Refresh saved search set 928 */ 929 function refresh_search() 930 { 931 if (!empty($this->search_subject) && !empty($this->search_string)) 932 $this->search_set = $this->search('', $this->search_subject, $this->search_string, $this->search_charset); 933 934 return $this->get_search_set(); 868 935 } 869 936 … … 1304 1371 $this->_clear_messagecount($to_mbox); 1305 1372 } 1373 1374 // remove message ids from search set 1375 if ($moved && $this->search_set && $from_mbox == $this->mailbox) 1376 $this->search_set = array_diff($this->search_set, $a_mids); 1306 1377 1307 1378 // update cached message headers … … 1312 1383 foreach ($a_uids as $uid) 1313 1384 { 1314 if (($index = array_search($uid, $a_cache_index)) !== FALSE)1315 $start_index = min($index, $start_index);1385 if (($index = array_search($uid, $a_cache_index)) !== FALSE) 1386 $start_index = min($index, $start_index); 1316 1387 } 1317 1388 … … 1352 1423 $this->_clear_messagecount($mailbox); 1353 1424 } 1425 1426 // remove message ids from search set 1427 if ($moved && $this->search_set && $mailbox == $this->mailbox) 1428 $this->search_set = array_diff($this->search_set, $a_mids); 1354 1429 1355 1430 // remove deleted messages from cache -
trunk/roundcubemail/program/steps/mail/list.inc
r232 r422 41 41 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 42 42 } 43 44 43 45 // we have a saved search request 46 if (!empty($_GET['_search']) && isset($_SESSION['search'][$_GET['_search']])) 47 { 48 $a_msgs = split(',', $_SESSION['search'][$_GET['_search']]); 49 $a_headers = $IMAP->list_header_set($mbox_name, $a_msgs, NULL, $sort_col, $sort_order); 50 $count = count($a_msgs); 51 } 52 else 53 { 54 if ($count = $IMAP->messagecount()) 55 $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); 56 } 44 45 // fetch message headers 46 if ($count = $IMAP->messagecount()) 47 $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); 57 48 58 49 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE); -
trunk/roundcubemail/program/steps/mail/move_del.inc
r388 r422 60 60 } 61 61 62 // refresh saved seach set after moving some messages 63 if (($search_request = $_GET['_search']) && $IMAP->search_set) 64 $_SESSION['search'][$search_request] = $IMAP->refresh_search(); 65 62 66 63 67 // update message count display 64 $pages = ceil($IMAP->messagecount()/$IMAP->page_size); 65 $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); 68 $msg_count = $IMAP->messagecount(); 69 $pages = ceil($msg_count / $IMAP->page_size); 70 $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($msg_count)); 66 71 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages); 67 72 … … 79 84 if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages) 80 85 { 81 $a_headers = $IMAP->list_headers($mbox, null, $_SESSION['sort_col'], $_SESSION['sort_order']); 86 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; 87 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 88 89 $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); 82 90 $a_headers = array_slice($a_headers, -$count, $count); 91 83 92 $commands .= rcmail_js_message_list($a_headers); 84 93 } 85 94 86 95 87 96 // send response 88 97 rcube_remote_response($commands); -
trunk/roundcubemail/program/steps/mail/search.inc
r305 r422 16 16 $REMOTE_REQUEST = TRUE; 17 17 18 // reset list_page 18 // reset list_page and old search results 19 19 $IMAP->set_page(1); 20 $IMAP->set_search_set(NULL); 20 21 $_SESSION['page'] = 1; 21 22 … … 27 28 $str = get_input_value('_search', RCUBE_INPUT_GET); 28 29 $mbox = get_input_value('_mbox', RCUBE_INPUT_GET); 29 $search_request = md5($ str);30 $search_request = md5($mbox.$str); 30 31 31 32 32 33 // Check the search string for type of search 33 if (preg_match("/^from:/i", $str)) { 34 if (preg_match("/^from:/i", $str)) 35 { 34 36 list(,$srch) = explode(":", $str); 35 $s earch = $IMAP->search($mbox, "HEADER FROM" ,trim($srch), $imap_charset);36 finish_search($mbox, $search);37 $subject = "HEADER FROM"; 38 $search = trim($srch); 37 39 } 38 else if (preg_match("/^to:/i", $str)) { 40 else if (preg_match("/^to:/i", $str)) 41 { 39 42 list(,$srch) = explode(":", $str); 40 $s earch = $IMAP->search($mbox, "HEADER TO", trim($srch), $imap_charset);41 finish_search($mbox, $search);43 $subject = "HEADER TO"; 44 $search = trim($srch); 42 45 } 43 else if (preg_match("/^cc:/i", $str)) { 46 else if (preg_match("/^cc:/i", $str)) 47 { 44 48 list(,$srch) = explode(":", $str); 45 $s earch = $IMAP->search($mbox, "HEADER CC", trim($srch), $imap_charset);46 finish_search($mbox, $search);49 $subject = "HEADER CC"; 50 $search = trim($srch); 47 51 } 48 else if (preg_match("/^subject:/i", $str)) { 52 else if (preg_match("/^subject:/i", $str)) 53 { 49 54 list(,$srch) = explode(":", $str); 50 $s earch = $IMAP->search($mbox, "HEADER SUBJECT", trim($srch), $imap_charset);51 finish_search($mbox, $search);55 $subject = "HEADER SUBJECT"; 56 $search = trim($srch); 52 57 } 53 else if (preg_match("/^body:/i", $str)) { 58 else if (preg_match("/^body:/i", $str)) 59 { 54 60 list(,$srch) = explode(":", $str); 55 $s earch = $IMAP->search($mbox, "TEXT", trim($srch), $imap_charset);56 finish_search($mbox, $search);61 $subject = "TEXT"; 62 $search = trim($srch); 57 63 } 58 64 // search in subject and sender by default 59 else {60 $search = $IMAP->search($mbox, "HEADER SUBJECT", trim($str), $imap_charset); 61 $s earch2 = $IMAP->search($mbox, "HEADER FROM", trim($str), $imap_charset);62 finish_search($mbox, array_unique(array_merge($search, $search2)));65 else 66 { 67 $subject = array("HEADER SUBJECT", "HEADER FROM"); 68 $search = trim($str); 63 69 } 64 70 65 71 66 // Complete the search display results or report error 67 function finish_search($mbox, $search) 72 // execute IMAP search 73 $result = $IMAP->search($mbox, $subject, $search, $imap_charset); 74 75 $commands = ''; 76 $count = 0; 77 78 // Make sure our $result is legit.. 79 if (is_array($result) && $result[0] != '') 68 80 { 69 global $IMAP, $JS_OBJECT_NAME, $OUTPUT, $search_request; 70 $commands = ''; 71 $count = 0; 72 73 // Make sure our $search is legit.. 74 if (is_array($search) && $search[0] != '') 81 // Get the headers 82 $result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 83 $count = count($result); 84 85 // save search results in session 86 if (!is_array($_SESSION['search'])) 87 $_SESSION['search'] = array(); 88 89 // Make sure we got the headers 90 if ($result_h != NULL) 75 91 { 76 // Get the headers 77 $result_h = $IMAP->list_header_set($mbox, $search, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 78 $count = count($search); 79 80 // save search results in session 81 if (!is_array($_SESSION['search'])) 82 $_SESSION['search'] = array(); 83 84 // Make sure we got the headers 85 if ($result_h != NULL) 86 { 87 $_SESSION['search'][$search_request] = join(',', $search); 88 $commands = rcmail_js_message_list($result_h); 89 $commands .= show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 90 } 92 $_SESSION['search'][$search_request] = $IMAP->get_search_set(); 93 $commands = rcmail_js_message_list($result_h); 94 $commands .= show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 91 95 } 92 else 93 { 94 $commands = show_message('searchnomatch', 'warning'); 95 $search_request = -1; 96 } 97 98 // update message count display 99 $pages = ceil($count/$IMAP->page_size); 100 $commands .= sprintf("\nthis.set_env('search_request', '%s')\n", $search_request); 101 $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); 102 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages); 103 $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count, 1)); 104 rcube_remote_response($commands); 96 } 97 else 98 { 99 $commands = show_message('searchnomatch', 'warning'); 100 $search_request = -1; 105 101 } 106 102 103 // update message count display 104 $pages = ceil($count/$IMAP->page_size); 105 $commands .= sprintf("\nthis.set_env('search_request', '%s')\n", $search_request); 106 $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); 107 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages); 108 $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count, 1)); 109 rcube_remote_response($commands); 110 107 111 ?>
Note: See TracChangeset
for help on using the changeset viewer.
