Changeset c435173 in github
- Timestamp:
- May 19, 2010 2:41:02 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- b62a0d2
- Parents:
- 98ef63c
- Files:
-
- 2 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (115 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r1d51658 rc435173 2 2 =========================== 3 3 4 - Fix handling errors of folder deletion (#1486705) 4 5 - Parse untagged CAPABILITY response for LOGIN command (#1486742) 5 6 - Renamed all php-cli scripts to use .sh extension -
program/include/rcube_imap.php
r677e1f2 rc435173 27 27 * @package Mail 28 28 * @author Thomas Bruederli <roundcube@gmail.com> 29 * @author Aleksander Machniak <alec@alec.pl> 29 * @author Aleksander Machniak <alec@alec.pl> 30 30 * @version 2.0 31 31 */ … … 54 54 private $icache = array(); 55 55 private $cache = array(); 56 private $cache_keys = array(); 56 private $cache_keys = array(); 57 57 private $cache_changes = array(); 58 58 private $uid_id_map = array(); … … 109 109 $data = rcmail::get_instance()->plugins->exec_hook('imap_connect', 110 110 array('host' => $host, 'user' => $user, 'attempt' => ++$attempt)); 111 111 112 112 if (!empty($data['pass'])) 113 113 $pass = $data['pass']; … … 155 155 */ 156 156 function close() 157 { 157 { 158 158 if ($this->conn && $this->conn->connected()) 159 159 $this->conn->close(); … … 172 172 $this->close(); 173 173 $this->connect($this->host, $this->user, $this->pass, $this->port, $this->ssl); 174 174 175 175 // issue SELECT command to restore connection status 176 176 if ($this->mailbox) … … 202 202 $this->root_dir = $root; 203 203 $this->options['rootdir'] = $root; 204 204 205 205 if (empty($this->delimiter)) 206 206 $this->get_hierarchy_delimiter(); … … 284 284 $this->page_size = (int)$size; 285 285 } 286 286 287 287 288 288 /** … … 359 359 { 360 360 $this->threading = false; 361 361 362 362 if ($enable) { 363 363 if ($this->get_capability('THREAD=REFS')) … … 445 445 return count((array)$this->search_set); 446 446 } 447 447 448 448 $a_mailbox_cache = $this->get_cache('messagecount'); 449 449 450 450 // return cached value 451 451 if (!$force && is_array($a_mailbox_cache[$mailbox]) && isset($a_mailbox_cache[$mailbox][$mode])) … … 481 481 $index = $this->_search_index($mailbox, $search_str); 482 482 $this->threading = $threads; 483 483 484 484 $count = is_array($index) ? count($index) : 0; 485 485 … … 520 520 if (!empty($this->icache['threads'])) 521 521 return count($this->icache['threads']['tree']); 522 522 523 523 list ($thread_tree, $msg_depth, $has_children) = $this->_fetch_threads($mailbox); 524 524 525 525 $msg_count = count($msg_depth); 526 526 527 527 // $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); 528 return count($thread_tree); 528 return count($thread_tree); 529 529 } 530 530 … … 540 540 * @param boolean Number of slice items to extract from result array 541 541 * @return array Indexed array with message header objects 542 * @access public 542 * @access public 543 543 */ 544 544 function list_headers($mbox_name='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) … … 655 655 if (!is_array($a_msg_headers) || empty($a_msg_headers)) 656 656 return array(); 657 657 658 658 // use this class for message sorting 659 659 $sorter = new rcube_header_sorter(); … … 662 662 663 663 if ($this->sort_order == 'DESC') 664 $a_msg_headers = array_reverse($a_msg_headers); 664 $a_msg_headers = array_reverse($a_msg_headers); 665 665 666 666 return array_values($a_msg_headers); … … 708 708 list ($thread_tree, $msg_depth, $has_children) = $this->conn->thread( 709 709 $mailbox, $this->threading, $this->skip_deleted ? 'UNDELETED' : ''); 710 710 711 711 // add to internal (fast) cache 712 712 $this->icache['threads'] = array(); … … 757 757 if (!is_array($a_msg_headers) || empty($a_msg_headers)) 758 758 return array(); 759 759 760 760 // use this class for message sorting 761 761 $sorter = new rcube_header_sorter(); … … 826 826 if ($this->search_threads) 827 827 $this->search('', $this->search_string, $this->search_charset, $sort_field); 828 828 829 829 $msgs = $this->search_set; 830 830 $a_msg_headers = array(); … … 910 910 // for small result set we can fetch all messages headers 911 911 $this->_fetch_headers($mailbox, join(',', $msgs), $a_msg_headers, NULL); 912 912 913 913 // return empty array if no messages found 914 914 if (!is_array($a_msg_headers) || empty($a_msg_headers)) … … 978 978 { 979 979 $start_msg = ($page-1) * $this->page_size; 980 980 981 981 if ($page=='all') { 982 982 $begin = 0; … … 995 995 if ($end < 0) $end = $max; 996 996 if ($end > $max) $end = $max; 997 997 998 998 return array($begin, $end); 999 999 } 1000 1000 1001 1001 1002 1002 /** … … 1040 1040 return count($a_msg_headers); 1041 1041 } 1042 1042 1043 1043 1044 1044 /** … … 1056 1056 $old = $this->get_folder_stats($mailbox); 1057 1057 1058 // refresh message count -> will update 1058 // refresh message count -> will update 1059 1059 $this->_messagecount($mailbox, 'ALL', true); 1060 1060 … … 1151 1151 $a_index = $this->conn->fetchHeaderIndex($mailbox, 1152 1152 join(',', $this->search_set), $this->sort_field, $this->skip_deleted); 1153 1153 1154 1154 if (is_array($a_index)) { 1155 1155 if ($this->sort_order=="ASC") … … 1200 1200 if ($this->sort_order == 'DESC') 1201 1201 $a_index = array_reverse($a_index); 1202 1202 1203 1203 $this->cache[$key] = $a_index; 1204 1204 } … … 1210 1210 else if ($this->sort_order=="DESC") 1211 1211 arsort($a_index); 1212 1212 1213 1213 $this->cache[$key] = array_keys($a_index); 1214 1214 } … … 1259 1259 1260 1260 $this->cache[$key] = $this->_flatten_threads($mailbox, $thread_tree); 1261 1261 1262 1262 return $this->cache[$key]; 1263 1263 } … … 1284 1284 if ($this->sort_order == 'DESC') 1285 1285 $msg_index = array_reverse($msg_index); 1286 1286 1287 1287 // flatten threads array 1288 1288 $all_ids = array(); … … 1307 1307 // fetch complete message index 1308 1308 $a_message_index = $this->conn->fetchHeaderIndex($mailbox, "1:*", 'UID', $this->skip_deleted); 1309 1309 1310 1310 if ($a_message_index === false) 1311 1311 return false; 1312 1312 1313 1313 foreach ($a_message_index as $id => $uid) { 1314 1314 // message in cache at correct position … … 1322 1322 unset($cache_index[$id]); 1323 1323 } 1324 1324 1325 1325 // other message at this position 1326 1326 if (isset($cache_index[$id])) { … … 1328 1328 unset($cache_index[$id]); 1329 1329 } 1330 1330 1331 1331 $for_update[] = $id; 1332 1332 } 1333 1333 1334 // clear messages at wrong positions and those deleted that are still in cache_index 1334 // clear messages at wrong positions and those deleted that are still in cache_index 1335 1335 if (!empty($for_remove)) 1336 1336 $cache_index = array_merge($cache_index, $for_remove); 1337 1337 1338 1338 if (!empty($cache_index)) 1339 1339 $this->remove_message_cache($cache_key, $cache_index); … … 1366 1366 if (!$str) 1367 1367 return false; 1368 1368 1369 1369 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1370 1370 … … 1456 1456 // $a_mailbox_cache[$mailbox][$criteria] = sizeof($a_messages); 1457 1457 // $this->update_cache('messagecount', $a_mailbox_cache); 1458 1458 1459 1459 return $a_messages; 1460 1460 } 1461 1461 1462 1462 1463 1463 /** … … 1475 1475 if (!$str) 1476 1476 return false; 1477 1477 1478 1478 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; 1479 1479 … … 1481 1481 } 1482 1482 1483 1483 1484 1484 /** 1485 1485 * Sort thread … … 1541 1541 if (empty($tree)) 1542 1542 return array(); 1543 1543 1544 1544 $index = array_combine(array_values($index), $index); 1545 1545 … … 1554 1554 } 1555 1555 1556 $index = array_values($index); 1556 $index = array_values($index); 1557 1557 1558 1558 // create sorted array of roots … … 1588 1588 return $this->get_search_set(); 1589 1589 } 1590 1591 1590 1591 1592 1592 /** 1593 1593 * Check if the given message ID is part of the current search set … … 1612 1612 * 1613 1613 * @param int Message ID 1614 * @param string Mailbox to read from 1614 * @param string Mailbox to read from 1615 1615 * @param boolean True if $id is the message UID 1616 1616 * @param boolean True if we need also BODYSTRUCTURE in headers … … 1676 1676 $this->struct_charset = $this->_structure_charset($structure); 1677 1677 1678 // Here we can recognize malformed BODYSTRUCTURE and 1678 // Here we can recognize malformed BODYSTRUCTURE and 1679 1679 // 1. [@TODO] parse the message in other way to create our own message structure 1680 1680 // 2. or just show the raw message body. … … 1704 1704 } 1705 1705 1706 1706 1707 1707 /** 1708 1708 * Build message part object … … 1718 1718 if (is_array($part[0])) { 1719 1719 $struct->ctype_primary = 'multipart'; 1720 1720 1721 1721 // find first non-array entry 1722 1722 for ($i=1; $i<count($part); $i++) { … … 1726 1726 } 1727 1727 } 1728 1728 1729 1729 $struct->mimetype = 'multipart/'.$struct->ctype_secondary; 1730 1730 … … 1746 1746 } 1747 1747 } 1748 1748 1749 1749 // pre-fetch headers of all parts (in one command for better performance) 1750 1750 // @TODO: we could do this before _structure_part() call, to fetch … … 1781 1781 for ($i=0; $i<count($part[2]); $i+=2) 1782 1782 $struct->ctype_parameters[strtolower($part[2][$i])] = $part[2][$i+1]; 1783 1783 1784 1784 if (isset($struct->ctype_parameters['charset'])) 1785 1785 $struct->charset = $struct->ctype_parameters['charset']; 1786 1786 } 1787 1787 1788 1788 // read content encoding 1789 1789 if (!empty($part[5]) && $part[5]!='NIL') { … … 1791 1791 $struct->headers['content-transfer-encoding'] = $struct->encoding; 1792 1792 } 1793 1793 1794 1794 // get part size 1795 1795 if (!empty($part[6]) && $part[6]!='NIL') … … 1806 1806 $struct->d_parameters[strtolower($part[$di][1][$n])] = $part[$di][1][$n+1]; 1807 1807 } 1808 1808 1809 1809 // get child parts 1810 1810 if (is_array($part[8]) && $di != 8) { … … 1819 1819 $struct->content_id = $part[3]; 1820 1820 $struct->headers['content-id'] = $part[3]; 1821 1821 1822 1822 if (empty($struct->disposition)) 1823 1823 $struct->disposition = 'inline'; 1824 1824 } 1825 1825 1826 1826 // fetch message headers if message/rfc822 or named part (could contain Content-Location header) 1827 1827 if ($struct->ctype_primary == 'message' || ($struct->ctype_parameters['name'] && !$struct->content_id)) { … … 1843 1843 if (preg_match('/^([a-z0-9_\/-]+)/i', $struct->real_headers['content-type'], $matches)) { 1844 1844 $struct->real_mimetype = strtolower($matches[1]); 1845 } 1845 } 1846 1846 } 1847 1847 } … … 1857 1857 return $struct; 1858 1858 } 1859 1860 1861 /** 1862 * Set attachment filename from message part structure 1859 1860 1861 /** 1862 * Set attachment filename from message part structure 1863 1863 * 1864 1864 * @access private … … 1965 1965 // decode filename 1966 1966 if (!empty($filename_mime)) { 1967 $part->filename = rcube_imap::decode_mime_string($filename_mime, 1967 $part->filename = rcube_imap::decode_mime_string($filename_mime, 1968 1968 $part->charset ? $part->charset : ($this->struct_charset ? $this->struct_charset : 1969 1969 rc_detect_encoding($filename_mime, $this->default_charset))); 1970 } 1970 } 1971 1971 else if (!empty($filename_encoded)) { 1972 1972 // decode filename according to RFC 2231, Section 4 … … 1994 1994 $structure = $structure[0]; 1995 1995 } 1996 } 1996 } 1997 1997 1998 1998 … … 2011 2011 // get part encoding if not provided 2012 2012 if (!is_object($o_part)) { 2013 $structure_str = $this->conn->fetchStructureString($this->mailbox, $uid, true); 2013 $structure_str = $this->conn->fetchStructureString($this->mailbox, $uid, true); 2014 2014 $structure = new rcube_mime_struct(); 2015 2015 // error or message not found … … 2023 2023 $o_part->charset = $structure->getPartCharset($part); 2024 2024 } 2025 2025 2026 2026 // TODO: Add caching for message parts 2027 2027 … … 2042 2042 $body = rcube_charset_convert($body, $o_part->charset); 2043 2043 } 2044 2044 2045 2045 return $body; 2046 2046 } … … 2084 2084 return $this->conn->fetchPartHeader($this->mailbox, $uid, true); 2085 2085 } 2086 2086 2087 2087 2088 2088 /** … … 2090 2090 * 2091 2091 * @param int Message UID 2092 */ 2092 */ 2093 2093 function print_raw_body($uid) 2094 2094 { … … 2339 2339 // unset threads internal cache 2340 2340 unset($this->icache['threads']); 2341 2341 2342 2342 // remove message ids from search set 2343 2343 if ($this->search_set && $mailbox == $this->mailbox) { … … 2375 2375 $mailbox = !empty($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; 2376 2376 $msg_count = $this->_messagecount($mailbox, 'ALL'); 2377 2377 2378 2378 if (!$msg_count) { 2379 2379 return 0; 2380 2380 } 2381 2381 2382 2382 $cleared = $this->conn->clearFolder($mailbox); 2383 2383 2384 2384 // make sure the message count cache is cleared as well 2385 2385 if ($cleared) { 2386 $this->clear_message_cache($mailbox.'.msg'); 2386 $this->clear_message_cache($mailbox.'.msg'); 2387 2387 $a_mailbox_cache = $this->get_cache('messagecount'); 2388 2388 unset($a_mailbox_cache[$mailbox]); 2389 2389 $this->update_cache('messagecount', $a_mailbox_cache); 2390 2390 } 2391 2391 2392 2392 return $cleared; 2393 2393 } … … 2420 2420 private function _expunge($mailbox, $clear_cache=true, $uids=NULL) 2421 2421 { 2422 if ($uids && $this->get_capability('UIDPLUS')) 2422 if ($uids && $this->get_capability('UIDPLUS')) 2423 2423 $a_uids = is_array($uids) ? join(',', $uids) : $uids; 2424 2424 else … … 2431 2431 $this->_clear_messagecount($mailbox); 2432 2432 } 2433 2433 2434 2434 return $result; 2435 2435 } … … 2441 2441 * @param mixed UIDs array or comma-separated list or '*' or '1:*' 2442 2442 * @param string Mailbox name 2443 * @return array Two elements array with UIDs converted to list and ALL flag 2443 * @return array Two elements array with UIDs converted to list and ALL flag 2444 2444 * @access private 2445 2445 */ … … 2458 2458 else 2459 2459 $uids = $this->conn->fetchUIDs($mailbox, $this->search_set); 2460 2460 2461 2461 // save ID-to-UID mapping in local cache 2462 2462 if (is_array($uids)) … … 2486 2486 * @return int Message ID 2487 2487 */ 2488 function get_id($uid, $mbox_name=NULL) 2488 function get_id($uid, $mbox_name=NULL) 2489 2489 { 2490 2490 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; … … 2554 2554 { 2555 2555 $a_defaults = $a_out = array(); 2556 2557 // get cached folder list 2556 2557 // get cached folder list 2558 2558 $a_mboxes = $this->get_cache('mailboxes'); 2559 2559 if (is_array($a_mboxes)) … … 2563 2563 $data = rcmail::get_instance()->plugins->exec_hook('list_mailboxes', 2564 2564 array('root'=>$root,'filter'=>$filter)); 2565 2565 2566 2566 if (isset($data['folders'])) { 2567 2567 $a_folders = $data['folders']; … … 2571 2571 $a_folders = $this->conn->listSubscribed($this->mod_mailbox($root), $filter); 2572 2572 } 2573 2573 2574 2574 if (!is_array($a_folders) || !sizeof($a_folders)) 2575 2575 $a_folders = array(); … … 2577 2577 // write mailboxlist to cache 2578 2578 $this->update_cache('mailboxes', $a_folders); 2579 2579 2580 2580 return $a_folders; 2581 2581 } … … 2584 2584 /** 2585 2585 * Get a list of all folders available on the IMAP server 2586 * 2586 * 2587 2587 * @param string IMAP root dir 2588 2588 * @return array Indexed array with folder names … … 2591 2591 { 2592 2592 static $a_folders; 2593 2593 2594 2594 if (is_array($a_folders)) 2595 2595 return $a_folders; 2596 2596 2597 2597 // retrieve list of folders from IMAP server 2598 2598 $a_mboxes = $this->conn->listMailboxes($this->mod_mailbox($root), '*'); … … 2618 2618 * Get mailbox quota information 2619 2619 * added by Nuny 2620 * 2620 * 2621 2621 * @return mixed Quota info or False if not supported 2622 2622 */ … … 2625 2625 if ($this->get_capability('QUOTA')) 2626 2626 return $this->conn->getQuota(); 2627 2627 2628 2628 return false; 2629 2629 } … … 2635 2635 * @param array Mailbox name(s) 2636 2636 * @return boolean True on success 2637 */ 2637 */ 2638 2638 function subscribe($a_mboxes) 2639 2639 { … … 2672 2672 { 2673 2673 $result = false; 2674 2674 2675 2675 // reduce mailbox name to 100 chars 2676 2676 $name = substr($name, 0, 100); … … 2703 2703 $mailbox = $this->mod_mailbox($mbox_name); 2704 2704 $abs_name = $this->mod_mailbox($name); 2705 2705 2706 2706 // check if mailbox is subscribed 2707 2707 $a_subscribed = $this->_list_mailboxes(); 2708 2708 $subscribed = in_array($mailbox, $a_subscribed); 2709 2709 2710 2710 // unsubscribe folder 2711 2711 if ($subscribed) … … 2765 2765 // send delete command to server 2766 2766 $result = $this->conn->deleteFolder($mailbox); 2767 if ($result >= 0) {2767 if ($result) { 2768 2768 $deleted = true; 2769 2769 $this->clear_message_cache($mailbox.'.msg'); … … 2774 2774 $this->conn->unsubscribe($c_mbox); 2775 2775 $result = $this->conn->deleteFolder($c_mbox); 2776 if ($result >= 0) {2776 if ($result) { 2777 2777 $deleted = true; 2778 2778 $this->clear_message_cache($c_mbox.'.msg'); … … 2829 2829 $a_folders = $this->conn->listMailboxes($this->mod_mailbox(''), $mbox_name); 2830 2830 } 2831 2831 2832 2832 if (is_array($a_folders) && in_array($this->mod_mailbox($mbox_name), $a_folders)) { 2833 2833 $this->icache[$key][] = $mbox_name; … … 2858 2858 $mbox_name = substr($mbox_name, strlen($this->root_dir)+1); 2859 2859 } 2860 2860 2861 2861 return $mbox_name; 2862 2862 } … … 2887 2887 return $this->_read_cache_record($key); 2888 2888 } 2889 2889 2890 2890 return $this->cache[$key]; 2891 2891 } … … 2921 2921 if (!$this->caching_enabled) 2922 2922 return; 2923 2923 2924 2924 if ($key===NULL) { 2925 2925 foreach ($this->cache as $key => $data) … … 3016 3016 $_SESSION['user_id'], 3017 3017 'IMAP.'.$key); 3018 3018 3019 3019 unset($this->cache_keys[$key]); 3020 3020 } … … 3025 3025 * message caching methods 3026 3026 * --------------------------------*/ 3027 3027 3028 3028 /** 3029 3029 * Checks if the cache is up-to-date … … 3072 3072 $uid = $this->conn->ID2UID($mailbox, $msg_count); 3073 3073 $cache_uid = array_pop($cache_index); 3074 3074 3075 3075 // uids of highest message matches -> cache seems OK 3076 3076 if ($cache_uid == $uid) … … 3093 3093 { 3094 3094 $cache_key = "$key:$from:$to:$sort_field:$sort_order"; 3095 3095 3096 3096 // use idx sort as default sorting 3097 3097 if (!$sort_field || !in_array($sort_field, $this->db_header_fields)) { 3098 3098 $sort_field = 'idx'; 3099 3099 } 3100 3100 3101 3101 if ($this->caching_enabled && !isset($this->cache[$cache_key])) { 3102 3102 $this->cache[$cache_key] = array(); … … 3132 3132 { 3133 3133 $internal_key = 'message'; 3134 3134 3135 3135 if ($this->caching_enabled && !isset($this->icache[$internal_key][$uid])) { 3136 3136 $sql_result = $this->db->query( … … 3157 3157 /** 3158 3158 * @access private 3159 */ 3159 */ 3160 3160 private function get_message_cache_index($key, $force=false, $sort_field='idx', $sort_order='ASC') 3161 3161 { 3162 3162 static $sa_message_index = array(); 3163 3163 3164 3164 // empty key -> empty array 3165 3165 if (!$this->caching_enabled || empty($key)) 3166 3166 return array(); 3167 3167 3168 3168 if (!empty($sa_message_index[$key]) && !$force) 3169 3169 return $sa_message_index[$key]; … … 3172 3172 if (!$sort_field || !in_array($sort_field, $this->db_header_fields)) 3173 3173 $sort_field = 'idx'; 3174 3174 3175 3175 $sa_message_index[$key] = array(); 3176 3176 $sql_result = $this->db->query( … … 3185 3185 while ($sql_arr = $this->db->fetch_assoc($sql_result)) 3186 3186 $sa_message_index[$key][$sql_arr['idx']] = $sql_arr['uid']; 3187 3187 3188 3188 return $sa_message_index[$key]; 3189 3189 } … … 3204 3204 if (!$this->caching_enabled) 3205 3205 return; 3206 3206 3207 3207 // check for an existing record (probably headers are cached but structure not) 3208 3208 if (!$force) { … … 3256 3256 } 3257 3257 } 3258 3258 3259 3259 /** 3260 3260 * @access private … … 3264 3264 if (!$this->caching_enabled) 3265 3265 return; 3266 3266 3267 3267 $this->db->query( 3268 3268 "DELETE FROM ".get_table_name('messages'). … … 3281 3281 if (!$this->caching_enabled) 3282 3282 return; 3283 3283 3284 3284 $this->db->query( 3285 3285 "DELETE FROM ".get_table_name('messages'). … … 3297 3297 if (!$this->caching_enabled) 3298 3298 return; 3299 3299 3300 3300 if (!empty($uids) && !is_array($uids)) { 3301 3301 if ($uids == '*' || $uids == '1:*') … … 3317 3317 return $sql_arr['minidx']; 3318 3318 else 3319 return 0; 3319 return 0; 3320 3320 } 3321 3321 … … 3339 3339 // Special chars as defined by RFC 822 need to in quoted string (or escaped). 3340 3340 $special_chars = '[\(\)\<\>\\\.\[\]@,;:"]'; 3341 3341 3342 3342 if (!is_array($a)) 3343 3343 return $out; … … 3360 3360 else if ($name) 3361 3361 $string = $name; 3362 3362 3363 3363 $out[$j] = array('name' => $name, 3364 3364 'mailto' => $address, … … 3369 3369 break; 3370 3370 } 3371 3371 3372 3372 return $out; 3373 3373 } 3374 3375 3374 3375 3376 3376 /** 3377 3377 * Decode a Microsoft Outlook TNEF part (winmail.dat) … … 3391 3391 $tnef_parts = array(); 3392 3392 $tnef_arr = tnef_decode($part->body); 3393 3393 3394 3394 foreach ($tnef_arr as $winatt) { 3395 3395 $tpart = new rcube_message_part; … … 3423 3423 if ($str{0}=='"' && $remove_quotes) 3424 3424 $str = str_replace('"', '', $str); 3425 3425 3426 3426 return $str; 3427 3427 } … … 3443 3443 3444 3444 // Iterate instead of recursing, this way if there are too many values we don't have stack overflows 3445 // rfc: all line breaks or other characters not found 3445 // rfc: all line breaks or other characters not found 3446 3446 // in the Base64 Alphabet must be ignored by decoding software 3447 // delete all blanks between MIME-lines, differently we can 3447 // delete all blanks between MIME-lines, differently we can 3448 3448 // receive unnecessary blanks and broken utf-8 symbols 3449 3449 $input = preg_replace("/\?=\s+=\?/", '?==?', $input); … … 3451 3451 // Check if there is stuff to decode 3452 3452 if (strpos($input, '=?') !== false) { 3453 // Loop through the string to decode all occurences of =? ?= into the variable $out 3453 // Loop through the string to decode all occurences of =? ?= into the variable $out 3454 3454 while(($pos = strpos($input, '=?')) !== false) { 3455 3455 // Append everything that is before the text to be decoded … … 3479 3479 3480 3480 // no encoding information, use fallback 3481 return rcube_charset_convert($input, 3481 return rcube_charset_convert($input, 3482 3482 !empty($fallback) ? $fallback : rcmail::get_instance()->config->get('default_charset', 'ISO-8859-1')); 3483 3483 } … … 3509 3509 } 3510 3510 3511 // we dont' know what to do with this 3511 // we dont' know what to do with this 3512 3512 return $str; 3513 3513 } … … 3599 3599 $folders = array_merge($a_defaults, array_keys($folders)); 3600 3600 3601 // finally we must rebuild the list to move 3601 // finally we must rebuild the list to move 3602 3602 // subfolders of default folders to their place... 3603 3603 // ...also do this for the rest of folders because 3604 3604 // asort() is not properly sorting case sensitive names 3605 3605 while (list($key, $folder) = each($folders)) { 3606 // set the type of folder name variable (#1485527) 3606 // set the type of folder name variable (#1485527) 3607 3607 $a_out[] = (string) $folder; 3608 3608 unset($folders[$key]); 3609 $this->_rsort($folder, $delimiter, $folders, $a_out); 3609 $this->_rsort($folder, $delimiter, $folders, $a_out); 3610 3610 } 3611 3611 … … 3621 3621 while (list($key, $name) = each($list)) { 3622 3622 if (strpos($name, $folder.$delimiter) === 0) { 3623 // set the type of folder name variable (#1485527) 3623 // set the type of folder name variable (#1485527) 3624 3624 $out[] = (string) $name; 3625 3625 unset($list[$key]); … … 3627 3627 } 3628 3628 } 3629 reset($list); 3629 reset($list); 3630 3630 } 3631 3631 … … 3638 3638 if (!$mbox_name) 3639 3639 $mbox_name = $this->mailbox; 3640 3640 3641 3641 if (!isset($this->uid_id_map[$mbox_name][$uid])) 3642 3642 $this->uid_id_map[$mbox_name][$uid] = $this->conn->UID2ID($mbox_name, $uid); … … 3658 3658 $uid = $this->conn->ID2UID($mbox_name, $id); 3659 3659 $this->uid_id_map[$mbox_name][$uid] = $id; 3660 3660 3661 3661 return $uid; 3662 3662 } … … 3713 3713 3714 3714 $a_mailbox_cache = $this->get_cache('messagecount'); 3715 3715 3716 3716 if (!is_array($a_mailbox_cache[$mailbox]) || !isset($a_mailbox_cache[$mailbox][$mode]) || !is_numeric($increment)) 3717 3717 return false; 3718 3718 3719 3719 // add incremental value to messagecount 3720 3720 $a_mailbox_cache[$mailbox][$mode] += $increment; 3721 3721 3722 3722 // there's something wrong, delete from cache 3723 3723 if ($a_mailbox_cache[$mailbox][$mode] < 0) … … 3726 3726 // write back to cache 3727 3727 $this->update_cache('messagecount', $a_mailbox_cache); 3728 3728 3729 3729 return true; 3730 3730 } … … 3768 3768 } 3769 3769 } 3770 3770 3771 3771 return $a_headers; 3772 3772 } … … 3794 3794 $result[$key]['name'] .= (empty($result[$key]['name'])?'':' ').str_replace("\"",'',stripslashes($v)); 3795 3795 } 3796 3796 3797 3797 if (empty($result[$key]['name'])) 3798 $result[$key]['name'] = $result[$key]['address']; 3798 $result[$key]['name'] = $result[$key]['address']; 3799 3799 elseif (empty($result[$key]['address'])) 3800 3800 $result[$key]['address'] = $result[$key]['name']; 3801 3801 } 3802 3802 3803 3803 return $result; 3804 3804 } … … 3846 3846 { 3847 3847 var $sequence_numbers = array(); 3848 3848 3849 3849 /** 3850 3850 * Set the predetermined sort order. … … 3868 3868 * the keys are the UIDs. We'll use uasort instead and dereference the value 3869 3869 * to get the sequence number (in the "id" field). 3870 * 3871 * uksort($headers, array($this, "compare_seqnums")); 3870 * 3871 * uksort($headers, array($this, "compare_seqnums")); 3872 3872 */ 3873 3873 uasort($headers, array($this, "compare_seqnums")); 3874 3874 } 3875 3875 3876 3876 /** 3877 3877 * Sort method called by uasort() … … 3882 3882 $seqa = $a->id; 3883 3883 $seqb = $b->id; 3884 3884 3885 3885 // then find each sequence number in my ordered list 3886 3886 $posa = isset($this->sequence_numbers[$seqa]) ? intval($this->sequence_numbers[$seqa]) : -1; 3887 3887 $posb = isset($this->sequence_numbers[$seqb]) ? intval($this->sequence_numbers[$seqb]) : -1; 3888 3888 3889 3889 // return the relative position as the comparison value 3890 3890 return $posa - $posb;
Note: See TracChangeset
for help on using the changeset viewer.
