Changeset 3379 in subversion
- Timestamp:
- Mar 18, 2010 9:02:18 AM (3 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (49 diffs)
-
program/lib/imap.inc (modified) (4 diffs)
-
program/steps/mail/func.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r3377 r3379 2 2 =========================== 3 3 4 - Improved performance of folders operations (#1486525) 4 5 - Fix blocked.gif attachment is not attached to the message (#1486516) 5 6 - Managesieve: import from Horde-INGO -
trunk/roundcubemail/program/include/rcube_imap.php
r3378 r3379 111 111 raise_error(array('code' => 403, 'type' => 'imap', 112 112 'file' => __FILE__, 'line' => __LINE__, 113 'message' => "Open SSL not available"), TRUE, FALSE);113 'message' => "Open SSL not available"), true, false); 114 114 $port = 143; 115 115 } … … 143 143 raise_error(array('code' => 403, 'type' => 'imap', 144 144 'file' => __FILE__, 'line' => __LINE__, 145 'message' => $GLOBALS['iil_error']), TRUE, FALSE);145 'message' => $GLOBALS['iil_error']), true, false); 146 146 } 147 147 … … 155 155 } 156 156 157 return $this->conn ? TRUE : FALSE;157 return $this->conn ? true : false; 158 158 } 159 159 … … 472 472 $a_folders = $data['folders']; 473 473 } 474 else {474 else { 475 475 // retrieve list of folders from IMAP server 476 476 $a_folders = iil_C_ListSubscribed($this->conn, $this->mod_mailbox($root), $filter); 477 477 } 478 479 478 480 479 if (!is_array($a_folders) || !sizeof($a_folders)) … … 497 496 * @access public 498 497 */ 499 function messagecount($mbox_name='', $mode='ALL', $force= FALSE)498 function messagecount($mbox_name='', $mode='ALL', $force=false) 500 499 { 501 500 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; … … 510 509 * @see rcube_imap::messagecount() 511 510 */ 512 private function _messagecount($mailbox='', $mode='ALL', $force= FALSE)511 private function _messagecount($mailbox='', $mode='ALL', $force=false) 513 512 { 514 513 $mode = strtoupper($mode); … … 619 618 * @see rcube_imap::list_headers 620 619 */ 621 private function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive= FALSE, $slice=0)620 private function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=false, $slice=0) 622 621 { 623 622 if (!strlen($mailbox)) … … 651 650 { 652 651 $this->sync_header_index($mailbox); 653 return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE, $slice);652 return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, true, $slice); 654 653 } 655 654 … … 683 682 } 684 683 // use SORT command 685 else if ($this->get_capability(' sort'))684 else if ($this->get_capability('SORT')) 686 685 { 687 686 if ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) { … … 742 741 * @see rcube_imap::list_headers 743 742 */ 744 private function _list_thread_headers($mailbox, $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive= FALSE, $slice=0)743 private function _list_thread_headers($mailbox, $page=NULL, $sort_field=NULL, $sort_order=NULL, $recursive=false, $slice=0) 745 744 { 746 745 $this->_set_sort_order($sort_field, $sort_order); … … 926 925 927 926 // sorted messages, so we can first slice array and then fetch only wanted headers 928 if ($this->get_capability(' sort')) // SORT searching result927 if ($this->get_capability('SORT')) // SORT searching result 929 928 { 930 929 // reset search set if sorting field has been changed … … 1172 1171 } 1173 1172 // sort with SORT command 1174 else if ($this->get_capability(' sort'))1173 else if ($this->get_capability('SORT')) 1175 1174 { 1176 1175 if ($this->sort_field && $this->search_sort_field != $this->sort_field) … … 1207 1206 if ($cache_status>0) 1208 1207 { 1209 $a_index = $this->get_message_cache_index($cache_key, TRUE, $this->sort_field, $this->sort_order);1208 $a_index = $this->get_message_cache_index($cache_key, true, $this->sort_field, $this->sort_order); 1210 1209 return array_keys($a_index); 1211 1210 } … … 1226 1225 } 1227 1226 // fetch complete message index 1228 else if ($this->get_capability(' sort'))1227 else if ($this->get_capability('SORT')) 1229 1228 { 1230 1229 if ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) { … … 1283 1282 if ($cache_status>0) 1284 1283 { 1285 $a_index = $this->get_message_cache_index($cache_key, TRUE, $this->sort_field, $this->sort_order);1284 $a_index = $this->get_message_cache_index($cache_key, true, $this->sort_field, $this->sort_order); 1286 1285 return array_keys($a_index); 1287 1286 } … … 1353 1352 1354 1353 // message in cache but in wrong position 1355 if (in_array((string)$uid, $cache_index, TRUE))1354 if (in_array((string)$uid, $cache_index, true)) 1356 1355 { 1357 1356 unset($cache_index[$id]); … … 1460 1459 ); 1461 1460 } 1462 else if ($sort_field && $this->get_capability(' sort')) {1461 else if ($sort_field && $this->get_capability('SORT')) { 1463 1462 $charset = $charset ? $charset : $this->default_charset; 1464 $a_messages = iil_C_Sort($this->conn, $mailbox, $sort_field, $criteria, FALSE, $charset);1463 $a_messages = iil_C_Sort($this->conn, $mailbox, $sort_field, $criteria, false, $charset); 1465 1464 1466 1465 if (!$a_messages) … … 1513 1512 else { // ($sort_field == 'date' && $this->threading != 'REFS') 1514 1513 // use SORT command 1515 if ($this->get_capability(' sort')) {1514 if ($this->get_capability('SORT')) { 1516 1515 $a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, 1517 1516 !empty($ids) ? $ids : ($this->skip_deleted ? 'UNDELETED' : '')); … … 1623 1622 * @return object Message headers representation 1624 1623 */ 1625 function get_headers($id, $mbox_name=NULL, $is_uid= TRUE, $bodystr=FALSE)1624 function get_headers($id, $mbox_name=NULL, $is_uid=true, $bodystr=false) 1626 1625 { 1627 1626 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; … … 2169 2168 2170 2169 // make sure mailbox exists 2171 if ( ($mailbox == 'INBOX') || in_array($mailbox, $this->_list_mailboxes())) {2170 if ($mailbox == 'INBOX' || $this->mailbox_exists($mbox_name)) { 2172 2171 if ($is_file) { 2173 2172 $separator = rcmail::get_instance()->config->header_delimiter(); … … 2184 2183 $this->_set_messagecount($mailbox, 'ALL', 1); 2185 2184 } 2186 2185 2187 2186 return $saved; 2188 2187 } … … 2205 2204 2206 2205 // make sure mailbox exists 2207 if ($to_mbox != 'INBOX' && ! in_array($to_mbox, $this->_list_mailboxes()))2206 if ($to_mbox != 'INBOX' && !$this->mailbox_exists($tbox)) 2208 2207 { 2209 2208 if (in_array($tbox, $this->default_folders)) 2210 $this->create_mailbox($tbox, TRUE);2209 $this->create_mailbox($tbox, true); 2211 2210 else 2212 return FALSE;2211 return false; 2213 2212 } 2214 2213 … … 2234 2233 // really deleted from the source mailbox 2235 2234 if ($moved) { 2236 $this->_expunge($from_mbox, FALSE, $a_uids);2235 $this->_expunge($from_mbox, false, $a_uids); 2237 2236 $this->_clear_messagecount($from_mbox); 2238 2237 $this->_clear_messagecount($to_mbox); … … 2294 2293 // send expunge command in order to have the deleted message 2295 2294 // really deleted from the mailbox 2296 $this->_expunge($mailbox, FALSE, $a_uids);2295 $this->_expunge($mailbox, false, $a_uids); 2297 2296 $this->_clear_messagecount($mailbox); 2298 2297 unset($this->uid_id_map[$mailbox]); … … 2363 2362 * @return boolean True on success 2364 2363 */ 2365 function expunge($mbox_name='', $clear_cache= TRUE)2364 function expunge($mbox_name='', $clear_cache=true) 2366 2365 { 2367 2366 $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; … … 2380 2379 * @access private 2381 2380 */ 2382 private function _expunge($mailbox, $clear_cache= TRUE, $uids=NULL)2381 private function _expunge($mailbox, $clear_cache=true, $uids=NULL) 2383 2382 { 2384 2383 if ($uids && $this->get_capability('UIDPLUS')) … … 2445 2444 return iil_C_GetQuota($this->conn); 2446 2445 2447 return FALSE;2446 return false; 2448 2447 } 2449 2448 … … 2488 2487 * @param string Name of the created mailbox, false on error 2489 2488 */ 2490 function create_mailbox($name, $subscribe= FALSE)2491 { 2492 $result = FALSE;2489 function create_mailbox($name, $subscribe=false) 2490 { 2491 $result = false; 2493 2492 2494 2493 // reduce mailbox name to 100 chars 2495 2494 $name = substr($name, 0, 100); 2496 2497 2495 $abs_name = $this->mod_mailbox($name); 2498 $a_mailbox_cache = $this->get_cache('mailboxes'); 2499 2500 if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) 2501 $result = iil_C_CreateFolder($this->conn, $abs_name); 2496 $result = iil_C_CreateFolder($this->conn, $abs_name); 2502 2497 2503 2498 // try to subscribe it … … 2505 2500 $this->subscribe($name); 2506 2501 2507 return $result ? $name : FALSE;2502 return $result ? $name : false; 2508 2503 } 2509 2504 … … 2518 2513 function rename_mailbox($mbox_name, $new_name) 2519 2514 { 2520 $result = FALSE;2515 $result = false; 2521 2516 2522 2517 // encode mailbox name and reduce it to 100 chars … … 2559 2554 iil_C_Subscribe($this->conn, $abs_name); 2560 2555 2561 return $result ? $name : FALSE;2556 return $result ? $name : false; 2562 2557 } 2563 2558 … … 2571 2566 function delete_mailbox($mbox_name) 2572 2567 { 2573 $deleted = FALSE;2568 $deleted = false; 2574 2569 2575 2570 if (is_array($mbox_name)) … … 2578 2573 $a_mboxes = explode(',', $mbox_name); 2579 2574 2580 $all_mboxes = iil_C_ListMailboxes($this->conn, $this->mod_mailbox($root), '*');2581 2582 2575 if (is_array($a_mboxes)) 2583 2576 foreach ($a_mboxes as $mbox_name) 2584 2577 { 2585 2578 $mailbox = $this->mod_mailbox($mbox_name); 2579 $sub_mboxes = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), 2580 $mailbox . $this->delimiter . '*'); 2586 2581 2587 2582 // unsubscribe mailbox before deleting … … 2591 2586 $result = iil_C_DeleteFolder($this->conn, $mailbox); 2592 2587 if ($result >= 0) { 2593 $deleted = TRUE;2588 $deleted = true; 2594 2589 $this->clear_message_cache($mailbox.'.msg'); 2595 2590 } 2596 2591 2597 foreach ($all_mboxes as $c_mbox) 2598 { 2599 $regex = preg_quote($mailbox . $this->delimiter, '/'); 2600 $regex = '/^' . $regex . '/'; 2601 if (preg_match($regex, $c_mbox)) 2602 { 2603 iil_C_UnSubscribe($this->conn, $c_mbox); 2604 $result = iil_C_DeleteFolder($this->conn, $c_mbox); 2605 if ($result >= 0) { 2606 $deleted = TRUE; 2607 $this->clear_message_cache($c_mbox.'.msg'); 2608 } 2609 } 2592 foreach ($sub_mboxes as $c_mbox) 2593 if ($c_mbox != 'INBOX') { 2594 iil_C_UnSubscribe($this->conn, $c_mbox); 2595 $result = iil_C_DeleteFolder($this->conn, $c_mbox); 2596 if ($result >= 0) { 2597 $deleted = true; 2598 $this->clear_message_cache($c_mbox.'.msg'); 2599 } 2610 2600 } 2611 2601 } … … 2624 2614 function create_default_folders() 2625 2615 { 2626 $a_folders = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), '*');2627 $a_subscribed = iil_C_ListSubscribed($this->conn, $this->mod_mailbox(''), '*');2628 2629 2616 // create default folders if they do not exist 2630 2617 foreach ($this->default_folders as $folder) 2631 2618 { 2632 $abs_name = $this->mod_mailbox($folder); 2633 if (!in_array($abs_name, $a_folders)) 2634 $this->create_mailbox($folder, TRUE); 2635 else if (!in_array($abs_name, $a_subscribed)) 2619 if (!$this->mailbox_exists($folder)) 2620 $this->create_mailbox($folder, true); 2621 else if (!$this->mailbox_exists($folder, true)) 2636 2622 $this->subscribe($folder); 2637 2623 } 2624 } 2625 2626 2627 /** 2628 * Checks if folder exists and is subscribed 2629 * 2630 * @param string Folder name 2631 * @param boolean Enable subscription checking 2632 * @return boolean TRUE or FALSE 2633 */ 2634 function mailbox_exists($mbox_name, $subscription=false) 2635 { 2636 if ($mbox_name) { 2637 if ($mbox_name == 'INBOX') 2638 return true; 2639 2640 $mbox = $this->mod_mailbox($mbox_name); 2641 2642 if ($subscription) { 2643 if ($a_folders = iil_C_ListSubscribed($this->conn, $this->mod_mailbox(''), $mbox)) 2644 return true; 2645 } 2646 else { 2647 $a_folders = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), $mbox); 2648 2649 if (is_array($a_folders) && in_array($mbox, $a_folders)) 2650 return true; 2651 } 2652 } 2653 2654 return false; 2638 2655 } 2639 2656 … … 2650 2667 { 2651 2668 if ($set && is_object($this->db)) 2652 $this->caching_enabled = TRUE;2669 $this->caching_enabled = true; 2653 2670 else 2654 $this->caching_enabled = FALSE;2671 $this->caching_enabled = false; 2655 2672 } 2656 2673 … … 2675 2692 { 2676 2693 $this->cache[$key] = $data; 2677 $this->cache_changed = TRUE;2678 $this->cache_changes[$key] = TRUE;2694 $this->cache_changed = true; 2695 $this->cache_changes[$key] = true; 2679 2696 } 2680 2697 … … 2708 2725 2709 2726 $this->cache = array(); 2710 $this->cache_changed = FALSE;2727 $this->cache_changed = false; 2711 2728 $this->cache_changes = array(); 2712 2729 } … … 2714 2731 { 2715 2732 $this->_clear_cache_record($key); 2716 $this->cache_changes[$key] = FALSE;2733 $this->cache_changes[$key] = false; 2717 2734 unset($this->cache[$key]); 2718 2735 } … … 2739 2756 $this->cache_keys[$sql_key] = $sql_arr['cache_id']; 2740 2757 if (!isset($this->cache[$sql_key])) 2741 $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE;2758 $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : false; 2742 2759 } 2743 2760 } … … 2752 2769 { 2753 2770 if (!$this->db) 2754 return FALSE;2771 return false; 2755 2772 2756 2773 // update existing cache record … … 2947 2964 * @access private 2948 2965 */ 2949 private function get_message_cache_index($key, $force= FALSE, $sort_field='idx', $sort_order='ASC')2966 private function get_message_cache_index($key, $force=false, $sort_field='idx', $sort_order='ASC') 2950 2967 { 2951 2968 static $sa_message_index = array(); … … 3032 3049 $index, 3033 3050 $headers->uid, 3034 (string)mb_substr($this->db->encode($this->decode_header($headers->subject, TRUE)), 0, 128),3035 (string)mb_substr($this->db->encode($this->decode_header($headers->from, TRUE)), 0, 128),3036 (string)mb_substr($this->db->encode($this->decode_header($headers->to, TRUE)), 0, 128),3037 (string)mb_substr($this->db->encode($this->decode_header($headers->cc, TRUE)), 0, 128),3051 (string)mb_substr($this->db->encode($this->decode_header($headers->subject, true)), 0, 128), 3052 (string)mb_substr($this->db->encode($this->decode_header($headers->from, true)), 0, 128), 3053 (string)mb_substr($this->db->encode($this->decode_header($headers->to, true)), 0, 128), 3054 (string)mb_substr($this->db->encode($this->decode_header($headers->cc, true)), 0, 128), 3038 3055 (int)$headers->size, 3039 3056 serialize($this->db->encode(clone $headers)), … … 3194 3211 * @return string Decoded string 3195 3212 */ 3196 function decode_header($input, $remove_quotes= FALSE)3213 function decode_header($input, $remove_quotes=false) 3197 3214 { 3198 3215 $str = rcube_imap::decode_mime_string((string)$input, $this->default_charset); … … 3505 3522 private function _change_subscription($a_mboxes, $mode) 3506 3523 { 3507 $updated = FALSE;3524 $updated = false; 3508 3525 3509 3526 if (is_array($a_mboxes)) … … 3546 3563 private function _set_messagecount($mbox_name, $mode, $increment) 3547 3564 { 3548 $a_mailbox_cache = FALSE;3565 $a_mailbox_cache = false; 3549 3566 $mailbox = $mbox_name ? $mbox_name : $this->mailbox; 3550 3567 $mode = strtoupper($mode); … … 3553 3570 3554 3571 if (!is_array($a_mailbox_cache[$mailbox]) || !isset($a_mailbox_cache[$mailbox][$mode]) || !is_numeric($increment)) 3555 return FALSE;3572 return false; 3556 3573 3557 3574 // add incremental value to messagecount … … 3565 3582 $this->update_cache('messagecount', $a_mailbox_cache); 3566 3583 3567 return TRUE;3584 return true; 3568 3585 } 3569 3586 … … 3575 3592 private function _clear_messagecount($mbox_name='') 3576 3593 { 3577 $a_mailbox_cache = FALSE;3594 $a_mailbox_cache = false; 3578 3595 $mailbox = $mbox_name ? $mbox_name : $this->mailbox; 3579 3596 -
trunk/roundcubemail/program/lib/imap.inc
r3378 r3379 1749 1749 1750 1750 function iil_C_ListMailboxes(&$conn, $ref, $mailbox) { 1751 global $IGNORE_FOLDERS;1752 1753 $ignore = $IGNORE_FOLDERS[strtolower($conn->host)];1754 1751 1755 1752 $fp = $conn->fp; … … 1780 1777 $a = iil_ExplodeQuotedString(' ', $line); 1781 1778 // last string is folder name 1782 $folder = preg_replace(array('/^"/', '/"$/'), '', iil_UnEscape($a[count($a)-1])); 1783 1784 if (empty($ignore) || (!empty($ignore) 1785 && !preg_match('/'.preg_quote(ignore, '/').'/i', $folder))) { 1786 $folders[$i] = $folder; 1787 } 1779 $folders[$i] = preg_replace(array('/^"/', '/"$/'), '', iil_UnEscape($a[count($a)-1])); 1788 1780 1789 1781 // second from last is delimiter … … 1813 1805 1814 1806 function iil_C_ListSubscribed(&$conn, $ref, $mailbox) { 1815 global $IGNORE_FOLDERS;1816 1817 $ignore = $IGNORE_FOLDERS[strtolower($conn->host)];1818 1807 1819 1808 $fp = $conn->fp; … … 1847 1836 // last string is folder name 1848 1837 $folder = preg_replace(array('/^"/', '/"$/'), '', iil_UnEscape($a[count($a)-1])); 1849 1850 if ((!in_array($folder, $folders)) && (empty($ignore)1851 || (!empty($ignore) && !preg_match('/'.preg_quote(ignore, '/').'/i', $folder)))) {1838 1839 // @TODO: do we need this check??? 1840 if (!in_array($folder, $folders)) { 1852 1841 $folders[$i] = $folder; 1853 1842 } -
trunk/roundcubemail/program/steps/mail/func.inc
r3367 r3379 43 43 $OUTPUT->send('login'); 44 44 } 45 46 45 47 46 // set imap properties and session vars
Note: See TracChangeset
for help on using the changeset viewer.
