Changeset 4014 in subversion
- Timestamp:
- Sep 29, 2010 9:46:30 AM (3 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 2 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r4013 r4014 8 8 - Add option to "Return receipt" will be always checked (#1486352) 9 9 - Fix HTML to plain text conversion doesn't handle citation blocks (#1486921) 10 - Use custom sorting when SORT is disabled by IMAP admin (#1486959) 10 11 11 12 RELEASE 0.4.1 -
trunk/roundcubemail/program/include/rcube_imap.php
r4009 r4014 63 63 private $search_sort_field = ''; 64 64 private $search_threads = false; 65 private $search_sorted = false; 65 66 private $db_header_fields = array('idx', 'uid', 'subject', 'from', 'to', 'cc', 'date', 'size'); 66 67 private $options = array('auth_method' => 'check'); … … 293 294 * @param string Charset of search string 294 295 * @param string Sorting field 295 */ 296 function set_search_set($str=null, $msgs=null, $charset=null, $sort_field=null, $threads=false) 296 * @param string True if set is sorted (SORT was used for searching) 297 */ 298 function set_search_set($str=null, $msgs=null, $charset=null, $sort_field=null, $threads=false, $sorted=false) 297 299 { 298 300 if (is_array($str) && $msgs == null) … … 308 310 $this->search_sort_field = $sort_field; 309 311 $this->search_threads = $threads; 312 $this->search_sorted = $sorted; 310 313 } 311 314 … … 322 325 $this->search_sort_field, 323 326 $this->search_threads, 327 $this->search_sorted, 324 328 ); 325 329 } … … 616 620 } 617 621 // use SORT command 618 else if ($this->get_capability('SORT')) { 619 if ($msg_index = $this->conn->sort($mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) { 622 else if ($this->get_capability('SORT') && 623 // Courier-IMAP provides SORT capability but allows to disable it by admin (#1486959) 624 ($msg_index = $this->conn->sort($mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) !== false 625 ) { 626 if (!empty($msg_index)) { 620 627 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 621 628 $max = max($msg_index); … … 859 866 860 867 // sorted messages, so we can first slice array and then fetch only wanted headers 861 if ($this-> get_capability('SORT')) { // SORT searching result868 if ($this->search_sorted) { // SORT searching result 862 869 // reset search set if sorting field has been changed 863 870 if ($this->sort_field && $this->search_sort_field != $this->sort_field) … … 1169 1176 } 1170 1177 // sort with SORT command 1171 else if ($this-> get_capability('SORT')) {1178 else if ($this->search_sorted) { 1172 1179 if ($this->sort_field && $this->search_sort_field != $this->sort_field) 1173 1180 $this->search('', $this->search_string, $this->search_charset, $this->sort_field); … … 1225 1232 } 1226 1233 // fetch complete message index 1227 else if ($this->get_capability('SORT') ) {1228 $a_index = $this->conn->sort($mailbox,1229 $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '') ;1230 1231 if ($ a_index !== false && $this->sort_order == 'DESC')1234 else if ($this->get_capability('SORT') && 1235 ($a_index = $this->conn->sort($mailbox, 1236 $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) !== false 1237 ) { 1238 if ($this->sort_order == 'DESC') 1232 1239 $a_index = array_reverse($a_index); 1233 1240 … … 1440 1447 $results = $this->_search_index($mailbox, $str, $charset, $sort_field); 1441 1448 1442 $this->set_search_set($str, $results, $charset, $sort_field, (bool)$this->threading); 1449 $this->set_search_set($str, $results, $charset, $sort_field, (bool)$this->threading, 1450 $this->threading || $this->search_sorted ? true : false); 1443 1451 1444 1452 return $results; … … 1477 1485 ); 1478 1486 } 1479 } 1480 else if ($sort_field && $this->get_capability('SORT')) { 1487 1488 return $a_messages; 1489 } 1490 1491 if ($sort_field && $this->get_capability('SORT')) { 1481 1492 $charset = $charset ? $charset : $this->default_charset; 1482 1493 $a_messages = $this->conn->sort($mailbox, $sort_field, $criteria, false, $charset); … … 1487 1498 $a_messages = $this->conn->sort($mailbox, $sort_field, 1488 1499 $this->convert_criteria($criteria, $charset), false, 'US-ASCII'); 1500 1501 if ($a_messages !== false) { 1502 $this->search_sorted = true; 1503 return $a_messages; 1504 } 1505 } 1506 1507 if ($orig_criteria == 'ALL') { 1508 $max = $this->_messagecount($mailbox); 1509 $a_messages = $max ? range(1, $max) : array(); 1489 1510 } 1490 1511 else { 1491 if ($orig_criteria == 'ALL') {1492 $max = $this->_messagecount($mailbox);1493 $a_messages = $max ? range(1, $max) : array(); 1494 }1495 else {1512 $a_messages = $this->conn->search($mailbox, 1513 ($charset ? "CHARSET $charset " : '') . $criteria); 1514 1515 // Error, try with US-ASCII (some servers may support only US-ASCII) 1516 if ($a_messages === false && $charset && $charset != 'US-ASCII') 1496 1517 $a_messages = $this->conn->search($mailbox, 1497 ($charset ? "CHARSET $charset " : '') . $criteria); 1498 1499 // Error, try with US-ASCII (some servers may support only US-ASCII) 1500 if ($a_messages === false && $charset && $charset != 'US-ASCII') 1501 $a_messages = $this->conn->search($mailbox, 1502 'CHARSET US-ASCII ' . $this->convert_criteria($criteria, $charset)); 1503 1504 // I didn't found that SEARCH should return sorted IDs 1505 if (is_array($a_messages) && !$this->sort_field) 1506 sort($a_messages); 1507 } 1508 } 1509 1510 // update messagecount cache ? 1511 // $a_mailbox_cache = get_cache('messagecount'); 1512 // $a_mailbox_cache[$mailbox][$criteria] = sizeof($a_messages); 1513 // $this->update_cache('messagecount', $a_mailbox_cache); 1518 'CHARSET US-ASCII ' . $this->convert_criteria($criteria, $charset)); 1519 1520 // I didn't found that SEARCH should return sorted IDs 1521 if (is_array($a_messages) && !$this->sort_field) 1522 sort($a_messages); 1523 } 1524 1525 $this->search_sorted = false; 1514 1526 1515 1527 return $a_messages; … … 1592 1604 else { // ($sort_field == 'date' && $this->threading != 'REFS') 1593 1605 // use SORT command 1594 if ($this->get_capability('SORT') ) {1595 $a_index = $this->conn->sort($mailbox, $this->sort_field,1596 !empty($ids) ? $ids : ($this->skip_deleted ? 'UNDELETED' : '')) ;1597 1606 if ($this->get_capability('SORT') && 1607 ($a_index = $this->conn->sort($mailbox, $this->sort_field, 1608 !empty($ids) ? $ids : ($this->skip_deleted ? 'UNDELETED' : ''))) !== false 1609 ) { 1598 1610 // return unsorted tree if we've got no index data 1599 1611 if (!$a_index) … … 1673 1685 if (!empty($this->search_string)) 1674 1686 $this->search_set = $this->search('', $this->search_string, $this->search_charset, 1675 $this->search_sort_field, $this->search_threads );1687 $this->search_sort_field, $this->search_threads, $this->search_sorted); 1676 1688 1677 1689 return $this->get_search_set();
Note: See TracChangeset
for help on using the changeset viewer.
