Changeset 5758 in subversion
- Timestamp:
- Jan 12, 2012 5:51:05 AM (16 months ago)
- Location:
- branches/devel-framework/roundcubemail
- Files:
-
- 1 added
- 32 edited
-
bin/msgexport.sh (modified) (3 diffs)
-
index.php (modified) (3 diffs)
-
installer/rcube_install.php (modified) (2 diffs)
-
program/include/main.inc (modified) (9 diffs)
-
program/include/rcmail.php (modified) (22 diffs)
-
program/include/rcube_config.php (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (188 diffs)
-
program/include/rcube_imap_cache.php (modified) (7 diffs)
-
program/include/rcube_message.php (modified) (8 diffs)
-
program/include/rcube_storage.php (added)
-
program/include/rcube_template.php (modified) (1 diff)
-
program/steps/mail/check_recent.inc (modified) (5 diffs)
-
program/steps/mail/compose.inc (modified) (7 diffs)
-
program/steps/mail/copy.inc (modified) (1 diff)
-
program/steps/mail/folders.inc (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (20 diffs)
-
program/steps/mail/get.inc (modified) (4 diffs)
-
program/steps/mail/getunread.inc (modified) (2 diffs)
-
program/steps/mail/headers.inc (modified) (1 diff)
-
program/steps/mail/list.inc (modified) (6 diffs)
-
program/steps/mail/mark.inc (modified) (8 diffs)
-
program/steps/mail/move_del.inc (modified) (8 diffs)
-
program/steps/mail/pagenav.inc (modified) (1 diff)
-
program/steps/mail/search.inc (modified) (6 diffs)
-
program/steps/mail/sendmail.inc (modified) (5 diffs)
-
program/steps/mail/show.inc (modified) (6 diffs)
-
program/steps/mail/viewsource.inc (modified) (2 diffs)
-
program/steps/settings/edit_folder.inc (modified) (5 diffs)
-
program/steps/settings/folders.inc (modified) (16 diffs)
-
program/steps/settings/func.inc (modified) (4 diffs)
-
program/steps/settings/save_folder.inc (modified) (6 diffs)
-
program/steps/settings/save_prefs.inc (modified) (1 diff)
-
tests/mailfunc.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-framework/roundcubemail/bin/msgexport.sh
r5716 r5758 32 32 global $IMAP; 33 33 34 $IMAP->set_mailbox($mbox); 34 $IMAP->set_folder($mbox); 35 36 $index = $IMAP->index($mbox, null, 'ASC'); 37 $count = $index->countMessages(); 38 $index = $index->get(); 35 39 36 40 vputs("Getting message list of {$mbox}..."); 37 vputs( $IMAP->messagecount()."messages\n");41 vputs("$count messages\n"); 38 42 39 43 if ($filename) … … 49 53 $out = STDOUT; 50 54 51 for ($ count = $IMAP->messagecount(), $i=1; $i <=$count; $i++)55 for ($i = 0; $i < $count; $i++) 52 56 { 53 $headers = $IMAP->get_ headers($i, null, false);57 $headers = $IMAP->get_message_headers($index[$i]); 54 58 $from = current(rcube_mime::decode_address_list($headers->from, 1, false)); 55 59 56 60 fwrite($out, sprintf("From %s %s UID %d\n", $from['mailto'], $headers->date, $headers->uid)); 57 fwrite($out, $IMAP->conn->fetchPartHeader($mbox, $i)); 58 fwrite($out, $IMAP->conn->handlePartBody($mbox, $i)); 61 fwrite($out, $IMAP->print_raw_body($headers->uid)); 59 62 fwrite($out, "\n\n\n"); 60 63 61 progress_update($i , $count);64 progress_update($i+1, $count); 62 65 } 63 66 vputs("\ncomplete.\n"); … … 117 120 118 121 $filename = null; 119 $mailboxes = $args['mbox'] == '*' ? $IMAP->list_ mailboxes(null) : array($args['mbox']);122 $mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : array($args['mbox']); 120 123 121 124 foreach ($mailboxes as $mbox) -
branches/devel-framework/roundcubemail/index.php
r5690 r5758 49 49 50 50 // check DB connections and exit on failure 51 if ($err_str = $ DB->is_error()) {51 if ($err_str = $RCMAIL->db->is_error()) { 52 52 raise_error(array( 53 53 'code' => 603, … … 129 129 } 130 130 else { 131 $error_code = (isset($RCMAIL->imap) && is_object($RCMAIL->imap)) ? $RCMAIL->imap->get_error_code() : 1;131 $error_code = is_object($RCMAIL->storage) ? $RCMAIL->storage->get_error_code() : 1; 132 132 133 133 $OUTPUT->show_message($error_code < -1 ? 'imaperror' : (!$auth['valid'] ? 'invalidrequest' : 'loginfailed'), 'warning'); … … 140 140 // end session (after optional referer check) 141 141 else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcube_check_referer())) { 142 $userdata = array('user' => $_SESSION['username'], 'host' => $_SESSION['imap_host'], 'lang' => $RCMAIL->user->language); 142 $userdata = array( 143 'user' => $_SESSION['username'], 144 'host' => $_SESSION['storage_host'], 145 'lang' => $RCMAIL->user->language, 146 ); 143 147 $OUTPUT->show_message('loggedout'); 144 148 $RCMAIL->logout_actions(); -
branches/devel-framework/roundcubemail/installer/rcube_install.php
r5662 r5758 42 42 'imap_root' => 'imap_ns_personal', 43 43 'pagesize' => 'mail_pagesize', 44 'default_imap_folders' => 'default_folders', 44 45 ); 45 46 … … 180 181 $value = '%p'; 181 182 } 182 else if ($prop == 'default_ imap_folders') {183 else if ($prop == 'default_folders') { 183 184 $value = array(); 184 foreach ($this->config['default_ imap_folders'] as $_folder) {185 foreach ($this->config['default_folders'] as $_folder) { 185 186 switch ($_folder) { 186 187 case 'Drafts': $_folder = $this->config['drafts_mbox']; break; -
branches/devel-framework/roundcubemail/program/include/main.inc
r5733 r5758 1194 1194 1195 1195 // get mailbox list 1196 $mbox_name = $RCMAIL-> imap->get_mailbox_name();1196 $mbox_name = $RCMAIL->storage->get_folder(); 1197 1197 1198 1198 // build the folders tree 1199 1199 if (empty($a_mailboxes)) { 1200 1200 // get mailbox list 1201 $a_folders = $RCMAIL-> imap->list_mailboxes('', $attrib['folder_name'], $attrib['folder_filter']);1202 $delimiter = $RCMAIL-> imap->get_hierarchy_delimiter();1201 $a_folders = $RCMAIL->storage->list_folders_subscribed('', $attrib['folder_name'], $attrib['folder_filter']); 1202 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 1203 1203 $a_mailboxes = array(); 1204 1204 … … 1251 1251 1252 1252 if ($p['unsubscribed']) 1253 $list = $RCMAIL-> imap->list_unsubscribed('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']);1253 $list = $RCMAIL->storage->list_folders('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']); 1254 1254 else 1255 $list = $RCMAIL-> imap->list_mailboxes('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']);1256 1257 $delimiter = $RCMAIL-> imap->get_hierarchy_delimiter();1255 $list = $RCMAIL->storage->list_folders_subscribed('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']); 1256 1257 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 1258 1258 1259 1259 foreach ($list as $folder) { … … 1286 1286 if (!$path) { 1287 1287 $n_folder = $folder; 1288 $folder = $RCMAIL-> imap->mod_mailbox($folder);1288 $folder = $RCMAIL->storage->mod_folder($folder); 1289 1289 1290 1290 if ($n_folder != $folder) { … … 1341 1341 $maxlength = intval($attrib['maxlength']); 1342 1342 $realnames = (bool)$attrib['realnames']; 1343 $msgcounts = $RCMAIL-> imap->get_cache('messagecount');1343 $msgcounts = $RCMAIL->storage->get_cache('messagecount'); 1344 1344 1345 1345 $out = ''; … … 1433 1433 1434 1434 // skip folders in which it isn't possible to create subfolders 1435 if (!empty($opts['skip_noinferiors']) && ($attrs = $RCMAIL-> imap->mailbox_attributes($folder['id']))1435 if (!empty($opts['skip_noinferiors']) && ($attrs = $RCMAIL->storage->folder_attributes($folder['id'])) 1436 1436 && in_array('\\Noinferiors', $attrs) 1437 1437 ) { … … 1502 1502 1503 1503 $protect_folders = $RCMAIL->config->get('protect_default_folders'); 1504 $default_folders = (array) $RCMAIL->config->get('default_ imap_folders');1505 $delimiter = $RCMAIL-> imap->get_hierarchy_delimiter();1504 $default_folders = (array) $RCMAIL->config->get('default_folders'); 1505 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 1506 1506 $path = explode($delimiter, $path); 1507 1507 $result = array(); … … 1546 1546 global $RCMAIL; 1547 1547 1548 $quota = $RCMAIL-> imap->get_quota();1548 $quota = $RCMAIL->storage->get_quota(); 1549 1549 $quota = $RCMAIL->plugins->exec_hook('quota', $quota); 1550 1550 … … 1592 1592 global $RCMAIL; 1593 1593 1594 $err_code = $RCMAIL-> imap->get_error_code();1595 $res_code = $RCMAIL-> imap->get_response_code();1596 1597 if ($res_code == rcube_ imap::NOPERM) {1594 $err_code = $RCMAIL->storage->get_error_code(); 1595 $res_code = $RCMAIL->storage->get_response_code(); 1596 1597 if ($res_code == rcube_storage::NOPERM) { 1598 1598 $RCMAIL->output->show_message('errornoperm', 'error'); 1599 1599 } 1600 else if ($res_code == rcube_ imap::READONLY) {1600 else if ($res_code == rcube_storage::READONLY) { 1601 1601 $RCMAIL->output->show_message('errorreadonly', 'error'); 1602 1602 } 1603 else if ($err_code && ($err_str = $RCMAIL-> imap->get_error_str())) {1603 else if ($err_code && ($err_str = $RCMAIL->storage->get_error_str())) { 1604 1604 // try to detect access rights problem and display appropriate message 1605 1605 if (stripos($err_str, 'Permission denied') !== false) … … 1967 1967 $d = preg_replace('/^[^\.]+\./', '', $n); 1968 1968 // %h - IMAP host 1969 $h = $_SESSION[' imap_host'] ? $_SESSION['imap_host'] : $host;1969 $h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host; 1970 1970 // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld 1971 1971 $z = preg_replace('/^[^\.]+\./', '', $h); -
branches/devel-framework/roundcubemail/program/include/rcmail.php
r5690 r5758 87 87 88 88 /** 89 * Instance of rcube_ imapclass.90 * 91 * @var rcube_ imap92 */ 93 public $ imap;89 * Instance of rcube_storage class. 90 * 91 * @var rcube_storage 92 */ 93 public $storage; 94 94 95 95 /** … … 172 172 // connect to database 173 173 $this->get_dbh(); 174 175 // set global object for backward compatibility176 $GLOBALS['DB'] = $this->db;177 174 178 175 // start session … … 242 239 if (is_object($user)) { 243 240 $this->user = $user; 244 245 // set global object for backward compatibility246 $GLOBALS['USER'] = $this->user;247 241 248 242 // overwrite config with user preferences … … 425 419 } 426 420 else if ($id && $ldap_config[$id]) { 427 $contacts = new rcube_ldap($ldap_config[$id], $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION[' imap_host']));421 $contacts = new rcube_ldap($ldap_config[$id], $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['storage_host'])); 428 422 } 429 423 else if ($id === '0') { … … 585 579 586 580 /** 587 * Create global IMAP object and connect to server588 * 589 * @ param boolean True if connection should be established590 */ 591 public function imap_init($connect = false)581 * Initialize and get storage object 582 * 583 * @return rcube_storage Storage object 584 */ 585 public function get_storage() 592 586 { 593 587 // already initialized 594 if (is_object($this->imap)) 588 if (!is_object($this->storage)) { 589 $this->storage_init(); 590 } 591 592 return $this->storage; 593 } 594 595 596 /** 597 * Initialize storage object 598 */ 599 public function storage_init() 600 { 601 // already initialized 602 if (is_object($this->storage)) { 595 603 return; 596 597 $this->imap = new rcube_imap(); 598 $this->imap->skip_deleted = $this->config->get('skip_deleted'); 599 600 // enable caching of imap data 601 $imap_cache = $this->config->get('imap_cache'); 604 } 605 606 $driver = $this->config->get('storage_driver', 'imap'); 607 $driver_class = "rcube_$driver"; 608 609 if (!class_exists($driver_class)) { 610 raise_error(array( 611 'code' => 700, 'type' => 'php', 612 'file' => __FILE__, 'line' => __LINE__, 613 'message' => "Storage driver class ($driver) not found!"), 614 true, true); 615 } 616 617 // Initialize storage object 618 $this->storage = new $driver_class; 619 620 // enable caching of mail data 621 $storage_cache = $this->config->get("$driver_cache"); 602 622 $messages_cache = $this->config->get('messages_cache'); 603 623 // for backward compatybility 604 if ($ imap_cache === null && $messages_cache === null && $this->config->get('enable_caching')) {605 $ imap_cache= 'db';624 if ($storage_cache === null && $messages_cache === null && $this->config->get('enable_caching')) { 625 $storage_cache = 'db'; 606 626 $messages_cache = true; 607 627 } 608 628 609 if ($ imap_cache)610 $this-> imap->set_caching($imap_cache);629 if ($storage_cache) 630 $this->storage->set_caching($storage_cache); 611 631 if ($messages_cache) 612 $this-> imap->set_messages_caching(true);632 $this->storage->set_messages_caching(true); 613 633 614 634 // set pagesize from config … … 617 637 $pagesize = $this->config->get('pagesize', 50); 618 638 } 619 $this-> imap->set_pagesize($pagesize);620 621 // set c onnectionoptions639 $this->storage->set_pagesize($pagesize); 640 641 // set class options 622 642 $options = array( 623 'auth_type' => $this->config->get('imap_auth_type', 'check'), 624 'auth_cid' => $this->config->get('imap_auth_cid'), 625 'auth_pw' => $this->config->get('imap_auth_pw'), 626 'debug' => (bool) $this->config->get('imap_debug', 0), 627 'force_caps' => (bool) $this->config->get('imap_force_caps'), 628 'timeout' => (int) $this->config->get('imap_timeout', 0), 643 'auth_type' => $this->config->get("$driver_auth_type", 'check'), 644 'auth_cid' => $this->config->get("$driver_auth_cid"), 645 'auth_pw' => $this->config->get("$driver_auth_pw"), 646 'debug' => (bool) $this->config->get("$driver_debug", 0), 647 'force_caps' => (bool) $this->config->get("$driver_force_caps"), 648 'timeout' => (int) $this->config->get("$driver_timeout", 0), 649 'skip_deleted' => (bool) $this->config->get('skip_deleted'), 629 650 ); 630 651 631 $this->imap->set_options($options); 632 633 // set global object for backward compatibility 634 $GLOBALS['IMAP'] = $this->imap; 635 636 $hook = $this->plugins->exec_hook('imap_init', array('fetch_headers' => $this->imap->fetch_add_headers)); 637 if ($hook['fetch_headers']) 638 $this->imap->fetch_add_headers = $hook['fetch_headers']; 639 640 // support this parameter for backward compatibility but log warning 641 if ($connect) { 642 $this->imap_connect(); 643 raise_error(array( 644 'code' => 800, 'type' => 'imap', 645 'file' => __FILE__, 'line' => __LINE__, 646 'message' => "rcube::imap_init(true) is deprecated, use rcube::imap_connect() instead"), 647 true, false); 648 } 649 } 650 651 652 /** 653 * Connect to IMAP server with stored session data 654 * 655 * @return bool True on success, false on error 656 */ 657 public function imap_connect() 658 { 659 if (!$this->imap) 660 $this->imap_init(); 661 662 if ($_SESSION['imap_host'] && !$this->imap->conn->connected()) { 663 if (!$this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'])) { 652 $hook = $this->plugins->exec_hook("$driver_init", $options); 653 654 $this->storage->set_options($options); 655 $this->set_storage_prop(); 656 } 657 658 659 /** 660 * Connect to the mail storage server with stored session data 661 * 662 * @return bool True on success, False on error 663 */ 664 public function storage_connect() 665 { 666 $storage = $this->get_storage(); 667 668 if ($_SESSION['storage_host'] && !$storage->is_connected()) { 669 $host = $_SESSION['storage_host']; 670 $user = $_SESSION['username']; 671 $port = $_SESSION['storage_port']; 672 $ssl = $_SESSION['storage_ssl']; 673 $pass = $this->decrypt($_SESSION['password']); 674 675 if (!$storage->connect($host, $user, $pass, $port, $ssl)) { 664 676 if ($this->output) 665 $this->output->show_message($ this->imap->get_error_code() == -1 ? 'imaperror' : 'sessionerror', 'error');677 $this->output->show_message($storage->get_error_code() == -1 ? 'imaperror' : 'sessionerror', 'error'); 666 678 } 667 679 else { 668 $this->set_ imap_prop();669 return $ this->imap->conn;680 $this->set_storage_prop(); 681 return $storage->is_connected(); 670 682 } 671 683 } … … 745 757 746 758 /** 747 * Perfom login to the IMAPserver and to the webmail service.759 * Perfom login to the mail server and to the webmail service. 748 760 * This will also create a new user entry if auto_create_user is configured. 749 761 * 750 * @param string IMAPuser name751 * @param string IMAPpassword752 * @param string IMAPhost762 * @param string Mail storage (IMAP) user name 763 * @param string Mail storage (IMAP) password 764 * @param string Mail storage (IMAP) host 753 765 * 754 766 * @return boolean True on success, False on failure … … 786 798 if ($a_host['host']) { 787 799 $host = $a_host['host']; 788 $ imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;800 $ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; 789 801 if (!empty($a_host['port'])) 790 $imap_port = $a_host['port']; 791 else if ($imap_ssl && $imap_ssl != 'tls' && (!$config['default_port'] || $config['default_port'] == 143)) 792 $imap_port = 993; 793 } 794 795 $imap_port = $imap_port ? $imap_port : $config['default_port']; 802 $port = $a_host['port']; 803 else if ($ssl && $ssl != 'tls' && (!$config['default_port'] || $config['default_port'] == 143)) 804 $port = 993; 805 } 806 807 if (!$port) { 808 $port = $config['default_port']; 809 } 796 810 797 811 /* Modify username with domain if required … … 806 820 } 807 821 808 // Convert username to lowercase. If IMAPbackend822 // Convert username to lowercase. If storage backend 809 823 // is case-insensitive we need to store always the same username (#1487113) 810 824 if ($config['login_lc']) { … … 831 845 $username = $user->data['username']; 832 846 833 if (!$this-> imap)834 $this-> imap_init();835 836 // try IMAP login837 if (!($ imap_login = $this->imap->connect($host, $username, $pass, $imap_port, $imap_ssl))) {847 if (!$this->storage) 848 $this->storage_init(); 849 850 // try to log in 851 if (!($login = $this->storage->connect($host, $username, $pass, $port, $ssl))) { 838 852 // try with lowercase 839 853 $username_lc = mb_strtolower($username); … … 843 857 $username_lc = $user->data['username']; 844 858 845 if ($ imap_login = $this->imap->connect($host, $username_lc, $pass, $imap_port, $imap_ssl))859 if ($login = $this->storage->connect($host, $username_lc, $pass, $port, $ssl)) 846 860 $username = $username_lc; 847 861 } 848 862 } 849 863 850 // exit if IMAPlogin failed851 if (!$ imap_login)864 // exit if login failed 865 if (!$login) { 852 866 return false; 867 } 853 868 854 869 // user already registered -> update user's record … … 882 897 // Configure environment 883 898 $this->set_user($user); 884 $this->set_ imap_prop();899 $this->set_storage_prop(); 885 900 $this->session_configure(); 886 901 … … 890 905 // create default folders on first login 891 906 if ($config['create_default_folders'] && (!empty($created) || empty($user->data['last_login']))) { 892 $this-> imap->create_default_folders();907 $this->storage->create_default_folders(); 893 908 } 894 909 895 910 // set session vars 896 $_SESSION['user_id'] = $user->ID;897 $_SESSION['username'] = $user->data['username'];898 $_SESSION[' imap_host'] = $host;899 $_SESSION[' imap_port'] = $imap_port;900 $_SESSION[' imap_ssl'] = $imap_ssl;901 $_SESSION['password'] = $this->encrypt($pass);902 $_SESSION['login_time'] = mktime();911 $_SESSION['user_id'] = $user->ID; 912 $_SESSION['username'] = $user->data['username']; 913 $_SESSION['storage_host'] = $host; 914 $_SESSION['storage_port'] = $port; 915 $_SESSION['storage_ssl'] = $ssl; 916 $_SESSION['password'] = $this->encrypt($pass); 917 $_SESSION['login_time'] = mktime(); 903 918 904 919 if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_') … … 908 923 909 924 // force reloading complete list of subscribed mailboxes 910 $this-> imap->clear_cache('mailboxes', true);925 $this->storage->clear_cache('mailboxes', true); 911 926 912 927 return true; … … 918 933 919 934 /** 920 * Set root dir and last stored mailbox935 * Set storage parameters. 921 936 * This must be done AFTER connecting to the server! 922 937 */ 923 public function set_imap_prop() 924 { 925 $this->imap->set_charset($this->config->get('default_charset', RCMAIL_CHARSET)); 926 927 if ($default_folders = $this->config->get('default_imap_folders')) { 928 $this->imap->set_default_mailboxes($default_folders); 938 private function set_storage_prop() 939 { 940 $storage = $this->get_storage(); 941 942 $storage->set_charset($this->config->get('default_charset', RCMAIL_CHARSET)); 943 944 if ($default_folders = $this->config->get('default_folders')) { 945 $storage->set_default_folders($default_folders); 929 946 } 930 947 if (isset($_SESSION['mbox'])) { 931 $ this->imap->set_mailbox($_SESSION['mbox']);948 $storage->set_folder($_SESSION['mbox']); 932 949 } 933 950 if (isset($_SESSION['page'])) { 934 $ this->imap->set_page($_SESSION['page']);951 $storage->set_page($_SESSION['page']); 935 952 } 936 953 } … … 958 975 list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_POST)); 959 976 if (!empty($domain)) { 960 foreach ($default_host as $ imap_host => $mail_domains) {977 foreach ($default_host as $storage_host => $mail_domains) { 961 978 if (is_array($mail_domains) && in_array($domain, $mail_domains)) { 962 $host = $ imap_host;979 $host = $storage_host; 963 980 break; 964 981 } … … 1168 1185 return; 1169 1186 1170 $this-> imap_connect();1187 $this->storage_connect(); 1171 1188 } 1172 1189 1173 1190 if ($config['logout_purge'] && !empty($config['trash_mbox'])) { 1174 $this-> imap->clear_mailbox($config['trash_mbox']);1191 $this->storage->clear_folder($config['trash_mbox']); 1175 1192 } 1176 1193 1177 1194 if ($config['logout_expunge']) { 1178 $this-> imap->expunge('INBOX');1195 $this->storage->expunge_folder('INBOX'); 1179 1196 } 1180 1197 … … 1208 1225 } 1209 1226 1210 if (is_object($this-> imap))1211 $this-> imap->close();1227 if (is_object($this->storage)) 1228 $this->storage->close(); 1212 1229 1213 1230 // before closing the database connection, write session data … … 1608 1625 private function fix_namespace_settings($user) 1609 1626 { 1610 $prefix = $this-> imap->get_namespace('prefix');1627 $prefix = $this->storage->get_namespace('prefix'); 1611 1628 $prefix_len = strlen($prefix); 1612 1629 … … 1619 1636 1620 1637 // Build namespace prefix regexp 1621 $ns = $this-> imap->get_namespace();1638 $ns = $this->storage->get_namespace(); 1622 1639 $regexp = array(); 1623 1640 … … 1643 1660 } 1644 1661 1645 if (!empty($prefs['default_ imap_folders'])) {1646 foreach ($prefs['default_ imap_folders'] as $idx => $name) {1662 if (!empty($prefs['default_folders'])) { 1663 foreach ($prefs['default_folders'] as $idx => $name) { 1647 1664 if ($name != 'INBOX' && !preg_match($regexp, $name)) { 1648 $prefs['default_ imap_folders'][$idx] = $prefix.$name;1665 $prefs['default_folders'][$idx] = $prefix.$name; 1649 1666 } 1650 1667 } … … 1696 1713 // save updated preferences and reset imap settings (default folders) 1697 1714 $user->save_prefs($prefs); 1698 $this->set_ imap_prop();1715 $this->set_storage_prop(); 1699 1716 } 1700 1717 -
branches/devel-framework/roundcubemail/program/include/rcube_config.php
r5733 r5758 73 73 $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); 74 74 75 if (!empty($this->prop['default_ imap_folders']))76 foreach ($this->prop['default_ imap_folders'] as $n => $folder)77 $this->prop['default_ imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');75 if (!empty($this->prop['default_folders'])) 76 foreach ($this->prop['default_folders'] as $n => $folder) 77 $this->prop['default_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); 78 78 79 79 // set PHP error logging according to config -
branches/devel-framework/roundcubemail/program/include/rcube_imap.php
r5744 r5758 31 31 * @version 2.0 32 32 */ 33 class rcube_imap 33 class rcube_imap extends rcube_storage 34 34 { 35 public $skip_deleted = false;36 public $page_size = 10;37 public $list_page = 1;38 public $threading = false;39 public $fetch_add_headers = '';40 public $get_all_headers = false;41 42 35 /** 43 36 * Instance of rcube_imap_generic … … 52 45 * @var rcube_imap_cache 53 46 */ 54 pr ivate$mcache;47 protected $mcache; 55 48 56 49 /** … … 59 52 * @var rcube_cache 60 53 */ 61 pr ivate$cache;54 protected $cache; 62 55 63 56 /** … … 66 59 * @var array 67 60 */ 68 private $icache = array(); 69 70 private $mailbox = 'INBOX'; 71 private $delimiter = NULL; 72 private $namespace = NULL; 73 private $sort_field = ''; 74 private $sort_order = 'DESC'; 75 private $default_charset = 'ISO-8859-1'; 76 private $struct_charset = NULL; 77 private $default_folders = array('INBOX'); 78 private $uid_id_map = array(); 79 private $msg_headers = array(); 80 public $search_set = NULL; 81 public $search_string = ''; 82 private $search_charset = ''; 83 private $search_sort_field = ''; 84 private $search_threads = false; 85 private $search_sorted = false; 86 private $options = array('auth_method' => 'check'); 87 private $host, $user, $pass, $port, $ssl; 88 private $caching = false; 89 private $messages_caching = false; 90 91 /** 92 * All (additional) headers used (in any way) by Roundcube 93 * Not listed here: DATE, FROM, TO, CC, REPLY-TO, SUBJECT, CONTENT-TYPE, LIST-POST 94 * (used for messages listing) are hardcoded in rcube_imap_generic::fetchHeaders() 95 * 96 * @var array 97 * @see rcube_imap::fetch_add_headers 98 */ 99 private $all_headers = array( 100 'IN-REPLY-TO', 101 'BCC', 102 'MESSAGE-ID', 103 'CONTENT-TRANSFER-ENCODING', 104 'REFERENCES', 105 'X-DRAFT-INFO', 106 'MAIL-FOLLOWUP-TO', 107 'MAIL-REPLY-TO', 108 'RETURN-PATH', 109 ); 110 111 const UNKNOWN = 0; 112 const NOPERM = 1; 113 const READONLY = 2; 114 const TRYCREATE = 3; 115 const INUSE = 4; 116 const OVERQUOTA = 5; 117 const ALREADYEXISTS = 6; 118 const NONEXISTENT = 7; 119 const CONTACTADMIN = 8; 61 protected $icache = array(); 62 63 protected $list_page = 1; 64 protected $delimiter; 65 protected $namespace; 66 protected $sort_field = ''; 67 protected $sort_order = 'DESC'; 68 protected $struct_charset; 69 protected $uid_id_map = array(); 70 protected $msg_headers = array(); 71 protected $search_set; 72 protected $search_string = ''; 73 protected $search_charset = ''; 74 protected $search_sort_field = ''; 75 protected $search_threads = false; 76 protected $search_sorted = false; 77 protected $options = array('auth_method' => 'check'); 78 protected $host, $user, $pass, $port, $ssl; 79 protected $caching = false; 80 protected $messages_caching = false; 81 protected $threading = false; 120 82 121 83 … … 123 85 * Object constructor. 124 86 */ 125 function __construct()87 public function __construct() 126 88 { 127 89 $this->conn = new rcube_imap_generic(); … … 144 106 * @param integer $port Port to connect to 145 107 * @param string $use_ssl SSL schema (either ssl or tls) or null if plain connection 108 * 146 109 * @return boolean TRUE on success, FALSE on failure 147 * @access public 148 */ 149 function connect($host, $user, $pass, $port=143, $use_ssl=null) 110 */ 111 public function connect($host, $user, $pass, $port=143, $use_ssl=null) 150 112 { 151 113 // check for OpenSSL support in PHP build … … 213 175 214 176 /** 215 * Close IMAP connection 177 * Close IMAP connection. 216 178 * Usually done on script shutdown 217 * 218 * @access public 219 */ 220 function close() 179 */ 180 public function close() 221 181 { 222 182 $this->conn->closeConnection(); … … 227 187 228 188 /** 229 * Close IMAP connection and re-connect 230 * This is used to avoid some strange socket errors when talking to Courier IMAP 231 * 232 * @access public 233 */ 234 function reconnect() 235 { 236 $this->conn->closeConnection(); 237 $connected = $this->connect($this->host, $this->user, $this->pass, $this->port, $this->ssl); 238 239 // issue SELECT command to restore connection status 240 if ($connected && strlen($this->mailbox)) 241 $this->conn->select($this->mailbox); 189 * Checks IMAP connection. 190 * 191 * @return boolean TRUE on success, FALSE on failure 192 */ 193 public function is_connected() 194 { 195 return $this->conn && $this->conn->connected(); 242 196 } 243 197 … … 248 202 * @return int Error code 249 203 */ 250 function get_error_code()204 public function get_error_code() 251 205 { 252 206 return $this->conn->errornum; … … 255 209 256 210 /** 257 * Returns messageof last error258 * 259 * @return string Error message260 */ 261 function get_error_str()211 * Returns text of last error 212 * 213 * @return string Error string 214 */ 215 public function get_error_str() 262 216 { 263 217 return $this->conn->error; … … 270 224 * @return int Response code 271 225 */ 272 function get_response_code()226 public function get_response_code() 273 227 { 274 228 switch ($this->conn->resultcode) { … … 296 250 297 251 /** 298 * Returns last command response299 *300 * @return string Response301 */302 function get_response_str()303 {304 return $this->conn->result;305 }306 307 308 /**309 * Set options to be used in rcube_imap_generic::connect()310 *311 * @param array $opt Options array312 */313 function set_options($opt)314 {315 $this->options = array_merge($this->options, (array)$opt);316 }317 318 319 /**320 252 * Activate/deactivate debug mode 321 253 * 322 254 * @param boolean $dbg True if IMAP conversation should be logged 323 * @access public 324 */ 325 function set_debug($dbg = true) 255 */ 256 public function set_debug($dbg = true) 326 257 { 327 258 $this->options['debug'] = $dbg; … … 331 262 332 263 /** 333 * Set default message charset 334 * 335 * This will be used for message decoding if a charset specification is not available 336 * 337 * @param string $cs Charset string 338 * @access public 339 */ 340 function set_charset($cs) 341 { 342 $this->default_charset = $cs; 343 } 344 345 346 /** 347 * This list of folders will be listed above all other folders 348 * 349 * @param array $arr Indexed list of folder names 350 * @access public 351 */ 352 function set_default_mailboxes($arr) 353 { 354 if (is_array($arr)) { 355 $this->default_folders = $arr; 356 357 // add inbox if not included 358 if (!in_array('INBOX', $this->default_folders)) 359 array_unshift($this->default_folders, 'INBOX'); 360 } 361 } 362 363 364 /** 365 * Set internal mailbox reference. 366 * 367 * All operations will be perfomed on this mailbox/folder 368 * 369 * @param string $mailbox Mailbox/Folder name 370 * @access public 371 */ 372 function set_mailbox($mailbox) 373 { 374 if ($this->mailbox == $mailbox) 264 * Set internal folder reference. 265 * All operations will be perfomed on this folder. 266 * 267 * @param string $folder Folder name 268 */ 269 public function set_folder($folder) 270 { 271 if ($this->folder == $folder) 375 272 return; 376 273 377 $this->mailbox = $mailbox; 378 379 // clear messagecount cache for this mailbox 380 $this->_clear_messagecount($mailbox); 381 } 382 383 384 /** 385 * Set internal list page 386 * 387 * @param number $page Page number to list 388 * @access public 389 */ 390 function set_page($page) 391 { 392 $this->list_page = (int)$page; 393 } 394 395 396 /** 397 * Set internal page size 398 * 399 * @param number $size Number of messages to display on one page 400 * @access public 401 */ 402 function set_pagesize($size) 403 { 404 $this->page_size = (int)$size; 274 $this->folder = $folder; 275 276 // clear messagecount cache for this folder 277 $this->clear_messagecount($folder); 405 278 } 406 279 … … 416 289 * 4 - true if sorted, bool 417 290 */ 418 function set_search_set($set)291 public function set_search_set($set) 419 292 { 420 293 $set = (array)$set; … … 434 307 * @return array Search set 435 308 */ 436 function get_search_set() 437 { 309 public function get_search_set() 310 { 311 if (empty($this->search_set)) { 312 return null; 313 } 314 438 315 return array( 439 316 $this->search_string, … … 447 324 448 325 /** 449 * Returns the currently used mailbox name450 *451 * @return string Name of the mailbox/folder452 * @access public453 */454 function get_mailbox_name()455 {456 return $this->mailbox;457 }458 459 460 /**461 326 * Returns the IMAP server's capability 462 327 * 463 328 * @param string $cap Capability name 329 * 464 330 * @return mixed Capability value or TRUE if supported, FALSE if not 465 * @access public 466 */ 467 function get_capability($cap) 331 */ 332 public function get_capability($cap) 468 333 { 469 334 return $this->conn->getCapability(strtoupper($cap)); … … 472 337 473 338 /** 474 * Sets threading flag to the best supported THREAD algorithm 475 * 476 * @param boolean $enable TRUE to enable and FALSE 477 * @return string Algorithm or false if THREAD is not supported 478 * @access public 479 */ 480 function set_threading($enable=false) 481 { 482 $this->threading = false; 483 484 if ($enable && ($caps = $this->get_capability('THREAD'))) { 485 if (in_array('REFS', $caps)) 486 $this->threading = 'REFS'; 487 else if (in_array('REFERENCES', $caps)) 488 $this->threading = 'REFERENCES'; 489 else if (in_array('ORDEREDSUBJECT', $caps)) 490 $this->threading = 'ORDEREDSUBJECT'; 491 } 492 493 return $this->threading; 494 } 495 496 497 /** 498 * Checks the PERMANENTFLAGS capability of the current mailbox 339 * Checks the PERMANENTFLAGS capability of the current folder 499 340 * and returns true if the given flag is supported by the IMAP server 500 341 * 501 342 * @param string $flag Permanentflag name 343 * 502 344 * @return boolean True if this flag is supported 503 * @access public 504 */ 505 function check_permflag($flag) 345 */ 346 public function check_permflag($flag) 506 347 { 507 348 $flag = strtoupper($flag); … … 517 358 * @access public 518 359 */ 519 function get_hierarchy_delimiter()360 public function get_hierarchy_delimiter() 520 361 { 521 362 return $this->delimiter; … … 529 370 * 530 371 * @return array Namespace data 531 * @access public 532 */ 533 function get_namespace($name=null) 372 */ 373 public function get_namespace($name = null) 534 374 { 535 375 $ns = $this->namespace; … … 546 386 /** 547 387 * Sets delimiter and namespaces 548 * 549 * @access private 550 */ 551 private function set_env() 388 */ 389 protected function set_env() 552 390 { 553 391 if ($this->delimiter !== null && $this->namespace !== null) { … … 615 453 } 616 454 617 // Find personal namespace prefix for mod_ mailbox()455 // Find personal namespace prefix for mod_folder() 618 456 // Prefix can be removed when there is only one personal namespace 619 457 if (is_array($this->namespace['personal']) && count($this->namespace['personal']) == 1) { … … 627 465 628 466 /** 629 * Get message count for a specific mailbox630 * 631 * @param string $ mailbox Mailbox/folder name467 * Get message count for a specific folder 468 * 469 * @param string $folder Folder name 632 470 * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT] 633 471 * @param boolean $force Force reading from server and update cache 634 472 * @param boolean $status Enables storing folder status info (max UID/count), 635 * required for mailbox_status() 473 * required for folder_status() 474 * 636 475 * @return int Number of messages 637 * @access public 638 */ 639 function messagecount($mailbox='', $mode='ALL', $force=false, $status=true) 640 { 641 if (!strlen($mailbox)) { 642 $mailbox = $this->mailbox; 643 } 644 645 return $this->_messagecount($mailbox, $mode, $force, $status); 646 } 647 648 649 /** 650 * Private method for getting nr of messages 651 * 652 * @param string $mailbox Mailbox name 476 */ 477 public function count($folder='', $mode='ALL', $force=false, $status=true) 478 { 479 if (!strlen($folder)) { 480 $folder = $this->folder; 481 } 482 483 return $this->messagecount($folder, $mode, $force, $status); 484 } 485 486 487 /** 488 * protected method for getting nr of messages 489 * 490 * @param string $folder Folder name 653 491 * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT] 654 492 * @param boolean $force Force reading from server and update cache 655 493 * @param boolean $status Enables storing folder status info (max UID/count), 656 * required for mailbox_status() 494 * required for folder_status() 495 * 657 496 * @return int Number of messages 658 * @access private 659 * @see rcube_imap::messagecount() 660 */ 661 private function _messagecount($mailbox, $mode='ALL', $force=false, $status=true) 497 * @see rcube_imap::count() 498 */ 499 protected function messagecount($folder, $mode='ALL', $force=false, $status=true) 662 500 { 663 501 $mode = strtoupper($mode); 664 502 665 503 // count search set 666 if ($this->search_string && $ mailbox == $this->mailbox&& ($mode == 'ALL' || $mode == 'THREADS') && !$force) {504 if ($this->search_string && $folder == $this->folder && ($mode == 'ALL' || $mode == 'THREADS') && !$force) { 667 505 if ($mode == 'ALL') 668 506 return $this->search_set->countMessages(); … … 671 509 } 672 510 673 $a_ mailbox_cache = $this->get_cache('messagecount');511 $a_folder_cache = $this->get_cache('messagecount'); 674 512 675 513 // return cached value 676 if (!$force && is_array($a_ mailbox_cache[$mailbox]) && isset($a_mailbox_cache[$mailbox][$mode]))677 return $a_ mailbox_cache[$mailbox][$mode];678 679 if (!is_array($a_ mailbox_cache[$mailbox]))680 $a_ mailbox_cache[$mailbox] = array();514 if (!$force && is_array($a_folder_cache[$folder]) && isset($a_folder_cache[$folder][$mode])) 515 return $a_folder_cache[$folder][$mode]; 516 517 if (!is_array($a_folder_cache[$folder])) 518 $a_folder_cache[$folder] = array(); 681 519 682 520 if ($mode == 'THREADS') { 683 $res = $this->fetch_threads($ mailbox, $force);521 $res = $this->fetch_threads($folder, $force); 684 522 $count = $res->count(); 685 523 686 524 if ($status) { 687 525 $msg_count = $res->countMessages(); 688 $this->set_folder_stats($ mailbox, 'cnt', $msg_count);689 $this->set_folder_stats($ mailbox, 'maxuid', $msg_count ? $this->id2uid($msg_count, $mailbox) : 0);526 $this->set_folder_stats($folder, 'cnt', $msg_count); 527 $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); 690 528 } 691 529 } 692 530 // RECENT count is fetched a bit different 693 531 else if ($mode == 'RECENT') { 694 $count = $this->conn->countRecent($ mailbox);532 $count = $this->conn->countRecent($folder); 695 533 } 696 534 // use SEARCH for message counting 697 else if ( $this->skip_deleted) {535 else if (!empty($this->options['skip_deleted'])) { 698 536 $search_str = "ALL UNDELETED"; 699 537 $keys = array('COUNT'); … … 715 553 // get message count using (E)SEARCH 716 554 // not very performant but more precise (using UNDELETED) 717 $index = $this->conn->search($ mailbox, $search_str, true, $keys);555 $index = $this->conn->search($folder, $search_str, true, $keys); 718 556 $count = $index->count(); 719 557 720 558 if ($mode == 'ALL') { 721 // Cache index data, will be used in message_index_direct()559 // Cache index data, will be used in index_direct() 722 560 $this->icache['undeleted_idx'] = $index; 723 561 724 562 if ($status) { 725 $this->set_folder_stats($ mailbox, 'cnt', $count);726 $this->set_folder_stats($ mailbox, 'maxuid', $index->max());563 $this->set_folder_stats($folder, 'cnt', $count); 564 $this->set_folder_stats($folder, 'maxuid', $index->max()); 727 565 } 728 566 } … … 730 568 else { 731 569 if ($mode == 'UNSEEN') 732 $count = $this->conn->countUnseen($ mailbox);570 $count = $this->conn->countUnseen($folder); 733 571 else { 734 $count = $this->conn->countMessages($ mailbox);572 $count = $this->conn->countMessages($folder); 735 573 if ($status) { 736 $this->set_folder_stats($ mailbox,'cnt', $count);737 $this->set_folder_stats($ mailbox, 'maxuid', $count ? $this->id2uid($count, $mailbox) : 0);574 $this->set_folder_stats($folder,'cnt', $count); 575 $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); 738 576 } 739 577 } 740 578 } 741 579 742 $a_ mailbox_cache[$mailbox][$mode] = (int)$count;580 $a_folder_cache[$folder][$mode] = (int)$count; 743 581 744 582 // write back to cache 745 $this->update_cache('messagecount', $a_ mailbox_cache);583 $this->update_cache('messagecount', $a_folder_cache); 746 584 747 585 return (int)$count; … … 751 589 /** 752 590 * Public method for listing headers 753 * convert mailbox name with root dir first 754 * 755 * @param string $mailbox Mailbox/folder name 591 * 592 * @param string $folder Folder name 756 593 * @param int $page Current page to list 757 594 * @param string $sort_field Header field to sort by … … 760 597 * 761 598 * @return array Indexed array with message header objects 762 * @access public 763 */ 764 public function list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) 765 { 766 if (!strlen($mailbox)) { 767 $mailbox = $this->mailbox; 768 } 769 770 return $this->_list_headers($mailbox, $page, $sort_field, $sort_order, $slice); 771 } 772 773 774 /** 775 * Private method for listing message headers 776 * 777 * @param string $mailbox Mailbox name 599 */ 600 public function list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) 601 { 602 if (!strlen($folder)) { 603 $folder = $this->folder; 604 } 605 606 return $this->_list_messages($folder, $page, $sort_field, $sort_order, $slice); 607 } 608 609 610 /** 611 * protected method for listing message headers 612 * 613 * @param string $folder Folder name 778 614 * @param int $page Current page to list 779 615 * @param string $sort_field Header field to sort by … … 782 618 * 783 619 * @return array Indexed array with message header objects 784 * @see rcube_imap::list_ headers785 */ 786 pr ivate function _list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0)787 { 788 if (!strlen($ mailbox)) {620 * @see rcube_imap::list_messages 621 */ 622 protected function _list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) 623 { 624 if (!strlen($folder)) { 789 625 return array(); 790 626 } … … 794 630 795 631 // use saved message set 796 if ($this->search_string && $ mailbox == $this->mailbox) {797 return $this-> _list_header_set($mailbox, $page, $slice);632 if ($this->search_string && $folder == $this->folder) { 633 return $this->list_header_set($folder, $page, $slice); 798 634 } 799 635 800 636 if ($this->threading) { 801 return $this-> _list_thread_headers($mailbox, $page, $slice);637 return $this->list_thread_headers($folder, $page, $slice); 802 638 } 803 639 804 640 // get UIDs of all messages in the folder, sorted 805 $index = $this-> message_index($mailbox, $this->sort_field, $this->sort_order);641 $index = $this->index($folder, $this->sort_field, $this->sort_order); 806 642 807 643 if ($index->isEmpty()) { … … 819 655 // fetch reqested messages headers 820 656 $a_index = $index->get(); 821 $a_msg_headers = $this->fetch_headers($ mailbox, $a_index);657 $a_msg_headers = $this->fetch_headers($folder, $a_index); 822 658 823 659 return array_values($a_msg_headers); … … 826 662 827 663 /** 828 * Privatemethod for listing message headers using threads829 * 830 * @param string $ mailbox Mailbox/folder name664 * protected method for listing message headers using threads 665 * 666 * @param string $folder Folder name 831 667 * @param int $page Current page to list 832 668 * @param int $slice Number of slice items to extract from result array … … 835 671 * @see rcube_imap::list_headers 836 672 */ 837 pr ivate function _list_thread_headers($mailbox, $page, $slice=0)673 protected function list_thread_headers($folder, $page, $slice=0) 838 674 { 839 675 // get all threads (not sorted) 840 676 if ($mcache = $this->get_mcache_engine()) 841 $threads = $mcache->get_thread($ mailbox);677 $threads = $mcache->get_thread($folder); 842 678 else 843 $threads = $this->fetch_threads($mailbox); 844 845 return $this->_fetch_thread_headers($mailbox, $threads, $page, $slice); 846 } 847 679 $threads = $this->fetch_threads($folder); 680 681 return $this->fetch_thread_headers($folder, $threads, $page, $slice); 682 } 848 683 849 684 /** 850 685 * Method for fetching threads data 851 686 * 852 * @param string $ mailboxFolder name853 * @param bool $force Use IMAP server, no cache687 * @param string $folder Folder name 688 * @param bool $force Use IMAP server, no cache 854 689 * 855 690 * @return rcube_imap_thread Thread data object 856 691 */ 857 function fetch_threads($ mailbox, $force = false)692 function fetch_threads($folder, $force = false) 858 693 { 859 694 if (!$force && ($mcache = $this->get_mcache_engine())) { 860 695 // don't store in self's internal cache, cache has it's own internal cache 861 return $mcache->get_thread($ mailbox);696 return $mcache->get_thread($folder); 862 697 } 863 698 864 699 if (empty($this->icache['threads'])) { 865 700 // get all threads 866 $result = $this->conn->thread($ mailbox, $this->threading,867 $this-> skip_deleted? 'UNDELETED' : '', true);701 $result = $this->conn->thread($folder, $this->threading, 702 $this->options['skip_deleted'] ? 'UNDELETED' : '', true); 868 703 869 704 // add to internal (fast) cache … … 876 711 877 712 /** 878 * Privatemethod for fetching threaded messages headers879 * 880 * @param string $ mailbox Mailboxname713 * protected method for fetching threaded messages headers 714 * 715 * @param string $folder Folder name 881 716 * @param rcube_result_thread $threads Threads data object 882 717 * @param int $page List page number … … 884 719 * 885 720 * @return array Messages headers 886 * @access private 887 */ 888 private function _fetch_thread_headers($mailbox, $threads, $page, $slice=0) 721 */ 722 protected function fetch_thread_headers($folder, $threads, $page, $slice=0) 889 723 { 890 724 // Sort thread structure … … 903 737 904 738 // fetch reqested headers from server 905 $a_msg_headers = $this->fetch_headers($ mailbox, $a_index);739 $a_msg_headers = $this->fetch_headers($folder, $a_index); 906 740 907 741 unset($a_index); 908 742 909 743 // Set depth, has_children and unread_children fields in headers 910 $this-> _set_thread_flags($a_msg_headers, $threads);744 $this->set_thread_flags($a_msg_headers, $threads); 911 745 912 746 return array_values($a_msg_headers); … … 915 749 916 750 /** 917 * Privatemethod for setting threaded messages flags:751 * protected method for setting threaded messages flags: 918 752 * depth, has_children and unread_children 919 753 * … … 922 756 * 923 757 * @return array Message headers array indexed by message UID 924 * @access private 925 */ 926 private function _set_thread_flags(&$headers, $threads) 758 */ 759 protected function set_thread_flags(&$headers, $threads) 927 760 { 928 761 $parents = array(); … … 948 781 949 782 /** 950 * Privatemethod for listing a set of message headers (search results)951 * 952 * @param string $ mailbox Mailbox/folder name783 * protected method for listing a set of message headers (search results) 784 * 785 * @param string $folder Folder name 953 786 * @param int $page Current page to list 954 787 * @param int $slice Number of slice items to extract from result array 955 788 * 956 789 * @return array Indexed array with message header objects 957 * @access private 958 */ 959 private function _list_header_set($mailbox, $page, $slice=0) 960 { 961 if (!strlen($mailbox) || empty($this->search_set) || $this->search_set->isEmpty()) { 790 */ 791 protected function list_header_set($folder, $page, $slice=0) 792 { 793 if (!strlen($folder) || empty($this->search_set) || $this->search_set->isEmpty()) { 962 794 return array(); 963 795 } … … 965 797 // use saved messages from searching 966 798 if ($this->threading) { 967 return $this-> _list_thread_header_set($mailbox, $page, $slice);799 return $this->list_thread_header_set($folder, $page, $slice); 968 800 } 969 801 … … 1013 845 // fetch headers 1014 846 $a_index = $index->get(); 1015 $a_msg_headers = $this->fetch_headers($ mailbox, $a_index);847 $a_msg_headers = $this->fetch_headers($folder, $a_index); 1016 848 1017 849 return array_values($a_msg_headers); … … 1024 856 if (($cnt > 300 && $cnt > $this->page_size) || !$this->sort_field) { 1025 857 // use memory less expensive (and quick) method for big result set 1026 $index = clone $this-> message_index('', $this->sort_field, $this->sort_order);858 $index = clone $this->index('', $this->sort_field, $this->sort_order); 1027 859 // get messages uids for one page... 1028 860 $index->slice($start_msg, min($cnt-$from, $this->page_size)); … … 1033 865 // ...and fetch headers 1034 866 $a_index = $index->get(); 1035 $a_msg_headers = $this->fetch_headers($ mailbox, $a_index);867 $a_msg_headers = $this->fetch_headers($folder, $a_index); 1036 868 1037 869 return array_values($a_msg_headers); … … 1040 872 // for small result set we can fetch all messages headers 1041 873 $a_index = $index->get(); 1042 $a_msg_headers = $this->fetch_headers($ mailbox, $a_index, false);874 $a_msg_headers = $this->fetch_headers($folder, $a_index, false); 1043 875 1044 876 // return empty array if no messages found … … 1063 895 1064 896 /** 1065 * Privatemethod for listing a set of threaded message headers (search results)1066 * 1067 * @param string $ mailbox Mailbox/folder name897 * protected method for listing a set of threaded message headers (search results) 898 * 899 * @param string $folder Folder name 1068 900 * @param int $page Current page to list 1069 901 * @param int $slice Number of slice items to extract from result array 1070 902 * 1071 903 * @return array Indexed array with message header objects 1072 * @access private 1073 * @see rcube_imap::list_header_set() 1074 */ 1075 private function _list_thread_header_set($mailbox, $page, $slice=0) 904 * @see rcube_imap::list_header_set() 905 */ 906 protected function list_thread_header_set($folder, $page, $slice=0) 1076 907 { 1077 908 // update search_set if previous data was fetched with disabled threading … … 1082 913 } 1083 914 1084 return $this-> _fetch_thread_headers($mailbox, clone $this->search_set, $page, $slice);915 return $this->fetch_thread_headers($folder, clone $this->search_set, $page, $slice); 1085 916 } 1086 917 … … 1089 920 * Fetches messages headers (by UID) 1090 921 * 1091 * @param string $ mailbox Mailboxname922 * @param string $folder Folder name 1092 923 * @param array $msgs Message UIDs 1093 924 * @param bool $sort Enables result sorting by $msgs … … 1095 926 * 1096 927 * @return array Messages headers indexed by UID 1097 * @access private 1098 */ 1099 function fetch_headers($mailbox, $msgs, $sort = true, $force = false) 928 */ 929 function fetch_headers($folder, $msgs, $sort = true, $force = false) 1100 930 { 1101 931 if (empty($msgs)) … … 1103 933 1104 934 if (!$force && ($mcache = $this->get_mcache_engine())) { 1105 $headers = $mcache->get_messages($ mailbox, $msgs);935 $headers = $mcache->get_messages($folder, $msgs); 1106 936 } 1107 937 else { 1108 938 // fetch reqested headers from server 1109 939 $headers = $this->conn->fetchHeaders( 1110 $ mailbox, $msgs, true, false, $this->get_fetch_headers());940 $folder, $msgs, true, false, $this->get_fetch_headers()); 1111 941 } 1112 942 … … 1130 960 1131 961 /** 1132 * Returns current status of mailbox962 * Returns current status of folder 1133 963 * 1134 964 * We compare the maximum UID to determine the number of 1135 965 * new messages because the RECENT flag is not reliable. 1136 966 * 1137 * @param string $mailbox Mailbox/folder name 967 * @param string $folder Folder name 968 * 1138 969 * @return int Folder status 1139 970 */ 1140 public function mailbox_status($mailbox= null)1141 { 1142 if (!strlen($ mailbox)) {1143 $ mailbox = $this->mailbox;1144 } 1145 $old = $this->get_folder_stats($ mailbox);971 public function folder_status($folder = null) 972 { 973 if (!strlen($folder)) { 974 $folder = $this->folder; 975 } 976 $old = $this->get_folder_stats($folder); 1146 977 1147 978 // refresh message count -> will update 1148 $this-> _messagecount($mailbox, 'ALL', true);979 $this->messagecount($folder, 'ALL', true); 1149 980 1150 981 $result = 0; … … 1154 985 } 1155 986 1156 $new = $this->get_folder_stats($ mailbox);987 $new = $this->get_folder_stats($folder); 1157 988 1158 989 // got new messages … … 1174 1005 * @TODO: move to separate DB table (cache?) 1175 1006 * 1176 * @param string $ mailbox Mailboxname1007 * @param string $folder Folder name 1177 1008 * @param string $name Data name 1178 1009 * @param mixed $data Data value 1179 1010 */ 1180 pr ivate function set_folder_stats($mailbox, $name, $data)1181 { 1182 $_SESSION['folders'][$ mailbox][$name] = $data;1011 protected function set_folder_stats($folder, $name, $data) 1012 { 1013 $_SESSION['folders'][$folder][$name] = $data; 1183 1014 } 1184 1015 … … 1187 1018 * Gets folder statistic data 1188 1019 * 1189 * @param string $ mailbox Mailboxname1020 * @param string $folder Folder name 1190 1021 * 1191 1022 * @return array Stats data 1192 1023 */ 1193 pr ivate function get_folder_stats($mailbox)1194 { 1195 if ($_SESSION['folders'][$ mailbox])1196 return (array) $_SESSION['folders'][$ mailbox];1024 protected function get_folder_stats($folder) 1025 { 1026 if ($_SESSION['folders'][$folder]) 1027 return (array) $_SESSION['folders'][$folder]; 1197 1028 else 1198 1029 return array(); … … 1203 1034 * Return sorted list of message UIDs 1204 1035 * 1205 * @param string $ mailbox Mailboxto get index from1036 * @param string $folder Folder to get index from 1206 1037 * @param string $sort_field Sort column 1207 1038 * @param string $sort_order Sort order [ASC, DESC] … … 1209 1040 * @return rcube_result_index|rcube_result_thread List of messages (UIDs) 1210 1041 */ 1211 public function message_index($mailbox='', $sort_field=NULL, $sort_order=NULL)1042 public function index($folder = '', $sort_field = NULL, $sort_order = NULL) 1212 1043 { 1213 1044 if ($this->threading) 1214 return $this->thread_index($ mailbox, $sort_field, $sort_order);1045 return $this->thread_index($folder, $sort_field, $sort_order); 1215 1046 1216 1047 $this->set_sort_order($sort_field, $sort_order); 1217 1048 1218 if (!strlen($ mailbox)) {1219 $ mailbox = $this->mailbox;1049 if (!strlen($folder)) { 1050 $folder = $this->folder; 1220 1051 } 1221 1052 … … 1223 1054 if ($this->search_string) { 1224 1055 if ($this->search_threads) { 1225 $this->search($ mailbox, $this->search_string, $this->search_charset, $this->sort_field);1056 $this->search($folder, $this->search_string, $this->search_charset, $this->sort_field); 1226 1057 } 1227 1058 … … 1229 1060 if (!$this->sort_field || $this->search_sorted) { 1230 1061 if ($this->sort_field && $this->search_sort_field != $this->sort_field) { 1231 $this->search($ mailbox, $this->search_string, $this->search_charset, $this->sort_field);1062 $this->search($folder, $this->search_string, $this->search_charset, $this->sort_field); 1232 1063 } 1233 1064 $index = $this->search_set; 1234 1065 } 1235 1066 else { 1236 $index = $this->conn->index($ mailbox, $this->search_set->get(),1237 $this->sort_field, $this-> skip_deleted, true, true);1067 $index = $this->conn->index($folder, $this->search_set->get(), 1068 $this->sort_field, $this->options['skip_deleted'], true, true); 1238 1069 } 1239 1070 … … 1247 1078 // check local cache 1248 1079 if ($mcache = $this->get_mcache_engine()) { 1249 $index = $mcache->get_index($ mailbox, $this->sort_field, $this->sort_order);1080 $index = $mcache->get_index($folder, $this->sort_field, $this->sort_order); 1250 1081 } 1251 1082 // fetch from IMAP server 1252 1083 else { 1253 $index = $this-> message_index_direct(1254 $ mailbox, $this->sort_field, $this->sort_order);1084 $index = $this->index_direct( 1085 $folder, $this->sort_field, $this->sort_order); 1255 1086 } 1256 1087 … … 1263 1094 * Doesn't uses cache by default. 1264 1095 * 1265 * @param string $ mailbox Mailboxto get index from1096 * @param string $folder Folder to get index from 1266 1097 * @param string $sort_field Sort column 1267 1098 * @param string $sort_order Sort order [ASC, DESC] … … 1270 1101 * @return rcube_result_index Sorted list of message UIDs 1271 1102 */ 1272 public function message_index_direct($mailbox, $sort_field = null, $sort_order = null, $skip_cache = true)1103 public function index_direct($folder, $sort_field = null, $sort_order = null, $skip_cache = true) 1273 1104 { 1274 1105 if (!$skip_cache && ($mcache = $this->get_mcache_engine())) { 1275 $index = $mcache->get_index($ mailbox, $sort_field, $sort_order);1106 $index = $mcache->get_index($folder, $sort_field, $sort_order); 1276 1107 } 1277 1108 // use message index sort as default sorting 1278 1109 else if (!$sort_field) { 1279 if ($this-> skip_deleted&& !empty($this->icache['undeleted_idx'])1280 && $this->icache['undeleted_idx']->getParameters('MAILBOX') == $ mailbox1110 if ($this->options['skip_deleted'] && !empty($this->icache['undeleted_idx']) 1111 && $this->icache['undeleted_idx']->getParameters('MAILBOX') == $folder 1281 1112 ) { 1282 1113 $index = $this->icache['undeleted_idx']; 1283 1114 } 1284 1115 else { 1285 $index = $this->conn->search($ mailbox,1286 'ALL' .($this-> skip_deleted? ' UNDELETED' : ''), true);1116 $index = $this->conn->search($folder, 1117 'ALL' .($this->options['skip_deleted'] ? ' UNDELETED' : ''), true); 1287 1118 } 1288 1119 } … … 1290 1121 else { 1291 1122 if ($this->get_capability('SORT')) { 1292 $index = $this->conn->sort($ mailbox, $sort_field,1293 $this-> skip_deleted? 'UNDELETED' : '', true);1123 $index = $this->conn->sort($folder, $sort_field, 1124 $this->options['skip_deleted'] ? 'UNDELETED' : '', true); 1294 1125 } 1295 1126 1296 1127 if (empty($index) || $index->isError()) { 1297 $index = $this->conn->index($ mailbox, "1:*", $sort_field,1298 $this-> skip_deleted, false, true);1128 $index = $this->conn->index($folder, "1:*", $sort_field, 1129 $this->options['skip_deleted'], false, true); 1299 1130 } 1300 1131 } … … 1311 1142 * Return index of threaded message UIDs 1312 1143 * 1313 * @param string $ mailbox Mailboxto get index from1144 * @param string $folder Folder to get index from 1314 1145 * @param string $sort_field Sort column 1315 1146 * @param string $sort_order Sort order [ASC, DESC] … … 1317 1148 * @return rcube_result_thread Message UIDs 1318 1149 */ 1319 function thread_index($mailbox='', $sort_field=NULL, $sort_order=NULL)1320 { 1321 if (!strlen($ mailbox)) {1322 $ mailbox = $this->mailbox;1150 public function thread_index($folder='', $sort_field=NULL, $sort_order=NULL) 1151 { 1152 if (!strlen($folder)) { 1153 $folder = $this->folder; 1323 1154 } 1324 1155 1325 1156 // we have a saved search result, get index from there 1326 if ($this->search_string && $this->search_threads && $ mailbox == $this->mailbox) {1157 if ($this->search_string && $this->search_threads && $folder == $this->folder) { 1327 1158 $threads = $this->search_set; 1328 1159 } 1329 1160 else { 1330 1161 // get all threads (default sort order) 1331 $threads = $this->fetch_threads($ mailbox);1162 $threads = $this->fetch_threads($folder); 1332 1163 } 1333 1164 … … 1344 1175 * @param rcube_result_thread $threads Threads result set 1345 1176 */ 1346 pr ivatefunction sort_threads($threads)1177 protected function sort_threads($threads) 1347 1178 { 1348 1179 if ($threads->isEmpty()) { … … 1355 1186 1356 1187 if ($this->sort_field && ($this->sort_field != 'date' || $this->get_capability('THREAD') != 'REFS')) { 1357 $index = $this-> message_index_direct($this->mailbox, $this->sort_field, $this->sort_order, false);1188 $index = $this->index_direct($this->folder, $this->sort_field, $this->sort_order, false); 1358 1189 1359 1190 if (!$index->isEmpty()) { … … 1372 1203 * Invoke search request to IMAP server 1373 1204 * 1374 * @param string $ mailbox Mailboxname to search in1205 * @param string $folder Folder name to search in 1375 1206 * @param string $str Search criteria 1376 1207 * @param string $charset Search charset 1377 1208 * @param string $sort_field Header field to sort by 1378 * @access public1209 * 1379 1210 * @todo: Search criteria should be provided in non-IMAP format, eg. array 1380 1211 */ 1381 function search($mailbox='', $str='ALL', $charset=NULL, $sort_field=NULL)1382 { 1383 if (!$str) 1212 public function search($folder='', $str='ALL', $charset=NULL, $sort_field=NULL) 1213 { 1214 if (!$str) { 1384 1215 $str = 'ALL'; 1216 } 1217 1218 if (!strlen($folder)) { 1219 $folder = $this->folder; 1220 } 1221 1222 $results = $this->search_index($folder, $str, $charset, $sort_field); 1223 1224 $this->set_search_set(array($str, $results, $charset, $sort_field, 1225 $this->threading || $this->search_sorted ? true : false)); 1226 } 1227 1228 1229 /** 1230 * Direct (real and simple) SEARCH request (without result sorting and caching). 1231 * 1232 * @param string $mailbox Mailbox name to search in 1233 * @param string $str Search string 1234 * 1235 * @return rcube_result_index Search result (UIDs) 1236 */ 1237 public function search_once($mailbox = null, $str = 'ALL') 1238 { 1239 if (!$str) { 1240 return 'ALL'; 1241 } 1385 1242 1386 1243 if (!strlen($mailbox)) { … … 1388 1245 } 1389 1246 1390 $results = $this->_search_index($mailbox, $str, $charset, $sort_field); 1391 1392 $this->set_search_set(array($str, $results, $charset, $sort_field, 1393 $this->threading || $this->search_sorted ? true : false)); 1394 } 1395 1396 1397 /** 1398 * Private search method 1399 * 1400 * @param string $mailbox Mailbox name 1247 $index = $this->conn->search($mailbox, $str, true); 1248 1249 return $index; 1250 } 1251 1252 1253 /** 1254 * protected search method 1255 * 1256 * @param string $folder Folder name 1401 1257 * @param string $criteria Search criteria 1402 1258 * @param string $charset Charset … … 1406 1262 * @see rcube_imap::search() 1407 1263 */ 1408 pr ivate function _search_index($mailbox, $criteria='ALL', $charset=NULL, $sort_field=NULL)1264 protected function search_index($folder, $criteria='ALL', $charset=NULL, $sort_field=NULL) 1409 1265 { 1410 1266 $orig_criteria = $criteria; 1411 1267 1412 if ($this-> skip_deleted&& !preg_match('/UNDELETED/', $criteria))1268 if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) 1413 1269 $criteria = 'UNDELETED '.$criteria; 1414 1270 1415 1271 if ($this->threading) { 1416 $threads = $this->conn->thread($ mailbox, $this->threading, $criteria, true, $charset);1272 $threads = $this->conn->thread($folder, $this->threading, $criteria, true, $charset); 1417 1273 1418 1274 // Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8, 1419 1275 // but I've seen that Courier doesn't support UTF-8) 1420 1276 if ($threads->isError() && $charset && $charset != 'US-ASCII') 1421 $threads = $this->conn->thread($ mailbox, $this->threading,1277 $threads = $this->conn->thread($folder, $this->threading, 1422 1278 $this->convert_criteria($criteria, $charset), true, 'US-ASCII'); 1423 1279 … … 1427 1283 if ($sort_field && $this->get_capability('SORT')) { 1428 1284 $charset = $charset ? $charset : $this->default_charset; 1429 $messages = $this->conn->sort($ mailbox, $sort_field, $criteria, true, $charset);1285 $messages = $this->conn->sort($folder, $sort_field, $criteria, true, $charset); 1430 1286 1431 1287 // Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8, 1432 1288 // but I've seen Courier with disabled UTF-8 support) 1433 1289 if ($messages->isError() && $charset && $charset != 'US-ASCII') 1434 $messages = $this->conn->sort($ mailbox, $sort_field,1290 $messages = $this->conn->sort($folder, $sort_field, 1435 1291 $this->convert_criteria($criteria, $charset), true, 'US-ASCII'); 1436 1292 … … 1441 1297 } 1442 1298 1443 $messages = $this->conn->search($ mailbox,1299 $messages = $this->conn->search($folder, 1444 1300 ($charset ? "CHARSET $charset " : '') . $criteria, true); 1445 1301 1446 1302 // Error, try with US-ASCII (some servers may support only US-ASCII) 1447 1303 if ($messages->isError() && $charset && $charset != 'US-ASCII') 1448 $messages = $this->conn->search($ mailbox,1304 $messages = $this->conn->search($folder, 1449 1305 $this->convert_criteria($criteria, $charset), true); 1450 1306 … … 1452 1308 1453 1309 return $messages; 1454 }1455 1456 1457 /**1458 * Direct (real and simple) SEARCH request to IMAP server,1459 * without result sorting and caching1460 *1461 * @param string $mailbox Mailbox name to search in1462 * @param string $str Search string1463 * @param boolean $ret_uid True if UIDs should be returned1464 *1465 * @return rcube_result_index Search result (UIDs)1466 */1467 function search_once($mailbox='', $str='ALL')1468 {1469 if (!$str)1470 return 'ALL';1471 1472 if (!strlen($mailbox)) {1473 $mailbox = $this->mailbox;1474 }1475 1476 $index = $this->conn->search($mailbox, $str, true);1477 1478 return $index;1479 1310 } 1480 1311 … … 1486 1317 * @param string $charset Original charset 1487 1318 * @param string $dest_charset Destination charset (default US-ASCII) 1319 * 1488 1320 * @return string Search string 1489 * @access private 1490 */ 1491 private function convert_criteria($str, $charset, $dest_charset='US-ASCII') 1321 */ 1322 protected function convert_criteria($str, $charset, $dest_charset='US-ASCII') 1492 1323 { 1493 1324 // convert strings to US_ASCII … … 1518 1349 * @return array Current search set 1519 1350 */ 1520 function refresh_search()1351 public function refresh_search() 1521 1352 { 1522 1353 if (!empty($this->search_string)) { … … 1531 1362 * Return message headers object of a specific message 1532 1363 * 1533 * @param int $id Message sequence ID orUID1534 * @param string $ mailbox Mailboxto read from1364 * @param int $id Message UID 1365 * @param string $folder Folder to read from 1535 1366 * @param bool $force True to skip cache 1536 1367 * 1537 1368 * @return rcube_mail_header Message headers 1538 1369 */ 1539 function get_headers($uid, $mailbox= null, $force = false)1540 { 1541 if (!strlen($ mailbox)) {1542 $ mailbox = $this->mailbox;1370 public function get_message_headers($uid, $folder = null, $force = false) 1371 { 1372 if (!strlen($folder)) { 1373 $folder = $this->folder; 1543 1374 } 1544 1375 1545 1376 // get cached headers 1546 1377 if (!$force && $uid && ($mcache = $this->get_mcache_engine())) { 1547 $headers = $mcache->get_message($ mailbox, $uid);1378 $headers = $mcache->get_message($folder, $uid); 1548 1379 } 1549 1380 else { 1550 1381 $headers = $this->conn->fetchHeader( 1551 $ mailbox, $uid, true, true, $this->get_fetch_headers());1382 $folder, $uid, true, true, $this->get_fetch_headers()); 1552 1383 } 1553 1384 … … 1561 1392 * 1562 1393 * @param int $uid Message UID to fetch 1563 * @param string $ mailbox Mailboxto read from1394 * @param string $folder Folder to read from 1564 1395 * 1565 1396 * @return object rcube_mail_header Message data 1566 1397 */ 1567 function get_message($uid, $mailbox= null)1568 { 1569 if (!strlen($ mailbox)) {1570 $ mailbox = $this->mailbox;1398 public function get_message($uid, $folder = null) 1399 { 1400 if (!strlen($folder)) { 1401 $folder = $this->folder; 1571 1402 } 1572 1403 … … 1578 1409 } 1579 1410 1580 $headers = $this->get_ headers($uid, $mailbox);1411 $headers = $this->get_message_headers($uid, $folder); 1581 1412 1582 1413 // message doesn't exist? … … 1588 1419 return $headers; 1589 1420 1590 $this-> _msg_uid = $uid;1421 $this->msg_uid = $uid; 1591 1422 1592 1423 if (empty($headers->bodystructure)) { 1593 $headers->bodystructure = $this->conn->getStructure($ mailbox, $uid, true);1424 $headers->bodystructure = $this->conn->getStructure($folder, $uid, true); 1594 1425 } 1595 1426 … … 1603 1434 $this->struct_charset = $headers->charset; 1604 1435 else 1605 $this->struct_charset = $this-> _structure_charset($structure);1436 $this->struct_charset = $this->structure_charset($structure); 1606 1437 1607 1438 $headers->ctype = strtolower($headers->ctype); … … 1623 1454 } 1624 1455 1625 $struct = $this-> _structure_part($structure, 0, '', $headers);1456 $struct = $this->structure_part($structure, 0, '', $headers); 1626 1457 1627 1458 // don't trust given content-type … … 1644 1475 * @param int $count 1645 1476 * @param string $parent 1646 * @access private 1647 */ 1648 private function _structure_part($part, $count=0, $parent='', $mime_headers=null) 1477 */ 1478 protected function structure_part($part, $count=0, $parent='', $mime_headers=null) 1649 1479 { 1650 1480 $struct = new rcube_message_part; … … 1698 1528 // headers for parts on all levels 1699 1529 if ($mime_part_headers) { 1700 $mime_part_headers = $this->conn->fetchMIMEHeaders($this-> mailbox,1701 $this-> _msg_uid, $mime_part_headers);1530 $mime_part_headers = $this->conn->fetchMIMEHeaders($this->folder, 1531 $this->msg_uid, $mime_part_headers); 1702 1532 } 1703 1533 … … 1707 1537 break; 1708 1538 $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 1709 $struct->parts[] = $this-> _structure_part($part[$i], ++$count, $struct->mime_id,1539 $struct->parts[] = $this->structure_part($part[$i], ++$count, $struct->mime_id, 1710 1540 $mime_part_headers[$tmp_part_id]); 1711 1541 } … … 1784 1614 if (!is_array($part[8][$i])) 1785 1615 break; 1786 $struct->parts[] = $this-> _structure_part($part[8][$i], ++$count, $struct->mime_id);1616 $struct->parts[] = $this->structure_part($part[8][$i], ++$count, $struct->mime_id); 1787 1617 } 1788 1618 } … … 1801 1631 if (empty($mime_headers)) { 1802 1632 $mime_headers = $this->conn->fetchPartHeader( 1803 $this-> mailbox, $this->_msg_uid, true, $struct->mime_id);1633 $this->folder, $this->msg_uid, true, $struct->mime_id); 1804 1634 } 1805 1635 … … 1825 1655 if ($struct->ctype_primary == 'message' && empty($struct->parts)) { 1826 1656 if (is_array($part[8]) && $di != 8) 1827 $struct->parts[] = $this-> _structure_part($part[8], ++$count, $struct->mime_id);1657 $struct->parts[] = $this->structure_part($part[8], ++$count, $struct->mime_id); 1828 1658 } 1829 1659 } 1830 1660 1831 1661 // normalize filename property 1832 $this-> _set_part_filename($struct, $mime_headers);1662 $this->set_part_filename($struct, $mime_headers); 1833 1663 1834 1664 return $struct; … … 1841 1671 * @param rcube_message_part $part Part object 1842 1672 * @param string $headers Part's raw headers 1843 * @access private 1844 */ 1845 private function _set_part_filename(&$part, $headers=null) 1673 */ 1674 protected function set_part_filename(&$part, $headers=null) 1846 1675 { 1847 1676 if (!empty($part->d_parameters['filename'])) … … 1864 1693 if (!$headers) { 1865 1694 $headers = $this->conn->fetchPartHeader( 1866 $this-> mailbox, $this->_msg_uid, true, $part->mime_id);1695 $this->folder, $this->msg_uid, true, $part->mime_id); 1867 1696 } 1868 1697 $filename_mime = ''; … … 1883 1712 if (!$headers) { 1884 1713 $headers = $this->conn->fetchPartHeader( 1885 $this-> mailbox, $this->_msg_uid, true, $part->mime_id);1714 $this->folder, $this->msg_uid, true, $part->mime_id); 1886 1715 } 1887 1716 $filename_encoded = ''; … … 1902 1731 if (!$headers) { 1903 1732 $headers = $this->conn->fetchPartHeader( 1904 $this-> mailbox, $this->_msg_uid, true, $part->mime_id);1733 $this->folder, $this->msg_uid, true, $part->mime_id); 1905 1734 } 1906 1735 $filename_mime = ''; … … 1921 1750 if (!$headers) { 1922 1751 $headers = $this->conn->fetchPartHeader( 1923 $this-> mailbox, $this->_msg_uid, true, $part->mime_id);1752 $this->folder, $this->msg_uid, true, $part->mime_id); 1924 1753 } 1925 1754 $filename_encoded = ''; … … 1967 1796 * 1968 1797 * @param array $structure Message structure 1798 * 1969 1799 * @return string Charset name 1970 * @access private 1971 */ 1972 private function _structure_charset($structure) 1800 */ 1801 protected function structure_charset($structure) 1973 1802 { 1974 1803 while (is_array($structure)) { … … 1992 1821 * @return string Message/part body if not printed 1993 1822 */ 1994 function get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false)1823 public function get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false) 1995 1824 { 1996 1825 // get part data if not provided 1997 1826 if (!is_object($o_part)) { 1998 $structure = $this->conn->getStructure($this-> mailbox, $uid, true);1827 $structure = $this->conn->getStructure($this->folder, $uid, true); 1999 1828 $part_data = rcube_imap_generic::getStructurePartData($structure, $part); 2000 1829 … … 2007 1836 2008 1837 if ($o_part && $o_part->size) { 2009 $body = $this->conn->handlePartBody($this-> mailbox, $uid, true,1838 $body = $this->conn->handlePartBody($this->folder, $uid, true, 2010 1839 $part ? $part : 'TEXT', $o_part->encoding, $print, $fp); 2011 1840 } … … 2039 1868 2040 1869 /** 2041 * Fetch message body of a specific message from the server2042 *2043 * @param int $uid Message UID2044 * @return string $part Message/part body2045 * @see rcube_imap::get_message_part()2046 */2047 function get_body($uid, $part=1)2048 {2049 $headers = $this->get_headers($uid);2050 return rcube_charset_convert($this->get_message_part($uid, $part, NULL),2051 $headers->charset ? $headers->charset : $this->default_charset);2052 }2053 2054 2055 /**2056 1870 * Returns the whole message source as string (or saves to a file) 2057 1871 * … … 2061 1875 * @return string Message source string 2062 1876 */ 2063 function get_raw_body($uid, $fp=null)2064 { 2065 return $this->conn->handlePartBody($this-> mailbox, $uid,1877 public function get_raw_body($uid, $fp=null) 1878 { 1879 return $this->conn->handlePartBody($this->folder, $uid, 2066 1880 true, null, null, false, $fp); 2067 1881 } … … 2072 1886 * 2073 1887 * @param int $uid Message UID 1888 * 2074 1889 * @return string Message headers string 2075 1890 */ 2076 function get_raw_headers($uid)2077 { 2078 return $this->conn->fetchPartHeader($this-> mailbox, $uid, true);1891 public function get_raw_headers($uid) 1892 { 1893 return $this->conn->fetchPartHeader($this->folder, $uid, true); 2079 1894 } 2080 1895 … … 2085 1900 * @param int $uid Message UID 2086 1901 */ 2087 function print_raw_body($uid)2088 { 2089 $this->conn->handlePartBody($this-> mailbox, $uid, true, NULL, NULL, true);1902 public function print_raw_body($uid) 1903 { 1904 $this->conn->handlePartBody($this->folder, $uid, true, NULL, NULL, true); 2090 1905 } 2091 1906 … … 2096 1911 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2097 1912 * @param string $flag Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT 2098 * @param string $ mailboxFolder name1913 * @param string $folder Folder name 2099 1914 * @param boolean $skip_cache True to skip message cache clean up 2100 1915 * 2101 1916 * @return boolean Operation status 2102 1917 */ 2103 function set_flag($uids, $flag, $mailbox=null, $skip_cache=false)2104 { 2105 if (!strlen($ mailbox)) {2106 $ mailbox = $this->mailbox;1918 public function set_flag($uids, $flag, $folder=null, $skip_cache=false) 1919 { 1920 if (!strlen($folder)) { 1921 $folder = $this->folder; 2107 1922 } 2108 1923 2109 1924 $flag = strtoupper($flag); 2110 list($uids, $all_mode) = $this-> _parse_uids($uids, $mailbox);1925 list($uids, $all_mode) = $this->parse_uids($uids); 2111 1926 2112 1927 if (strpos($flag, 'UN') === 0) 2113 $result = $this->conn->unflag($ mailbox, $uids, substr($flag, 2));1928 $result = $this->conn->unflag($folder, $uids, substr($flag, 2)); 2114 1929 else 2115 $result = $this->conn->flag($ mailbox, $uids, $flag);1930 $result = $this->conn->flag($folder, $uids, $flag); 2116 1931 2117 1932 if ($result) { … … 2121 1936 $status = strpos($flag, 'UN') !== 0; 2122 1937 $mflag = preg_replace('/^UN/', '', $flag); 2123 $mcache->change_flag($ mailbox, $all_mode ? null : explode(',', $uids),1938 $mcache->change_flag($folder, $all_mode ? null : explode(',', $uids), 2124 1939 $mflag, $status); 2125 1940 } … … 2127 1942 // clear cached counters 2128 1943 if ($flag == 'SEEN' || $flag == 'UNSEEN') { 2129 $this-> _clear_messagecount($mailbox, 'SEEN');2130 $this-> _clear_messagecount($mailbox, 'UNSEEN');1944 $this->clear_messagecount($folder, 'SEEN'); 1945 $this->clear_messagecount($folder, 'UNSEEN'); 2131 1946 } 2132 1947 else if ($flag == 'DELETED') { 2133 $this-> _clear_messagecount($mailbox, 'DELETED');1948 $this->clear_messagecount($folder, 'DELETED'); 2134 1949 } 2135 1950 } … … 2140 1955 2141 1956 /** 2142 * Remove message flag for one or several messages 2143 * 2144 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2145 * @param string $flag Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT 2146 * @param string $mailbox Folder name 2147 * 2148 * @return int Number of flagged messages, -1 on failure 2149 * @see set_flag 2150 */ 2151 function unset_flag($uids, $flag, $mailbox=null) 2152 { 2153 return $this->set_flag($uids, 'UN'.$flag, $mailbox); 2154 } 2155 2156 2157 /** 2158 * Append a mail message (source) to a specific mailbox 2159 * 2160 * @param string $mailbox Target mailbox 1957 * Append a mail message (source) to a specific folder 1958 * 1959 * @param string $folder Target folder 2161 1960 * @param string $message The message source string or filename 2162 1961 * @param string $headers Headers string if $message contains only the body … … 2165 1964 * @return int|bool Appended message UID or True on success, False on error 2166 1965 */ 2167 function save_message($mailbox, &$message, $headers='', $is_file=false)2168 { 2169 if (!strlen($ mailbox)) {2170 $ mailbox = $this->mailbox;2171 } 2172 2173 // make sure mailboxexists2174 if ($this-> mailbox_exists($mailbox)) {1966 public function save_message($folder, &$message, $headers='', $is_file=false) 1967 { 1968 if (!strlen($folder)) { 1969 $folder = $this->folder; 1970 } 1971 1972 // make sure folder exists 1973 if ($this->folder_exists($folder)) { 2175 1974 if ($is_file) 2176 $saved = $this->conn->appendFromFile($ mailbox, $message, $headers);1975 $saved = $this->conn->appendFromFile($folder, $message, $headers); 2177 1976 else 2178 $saved = $this->conn->append($ mailbox, $message);1977 $saved = $this->conn->append($folder, $message); 2179 1978 } 2180 1979 2181 1980 if ($saved) { 2182 // increase messagecount of the target mailbox2183 $this-> _set_messagecount($mailbox, 'ALL', 1);1981 // increase messagecount of the target folder 1982 $this->set_messagecount($folder, 'ALL', 1); 2184 1983 } 2185 1984 … … 2189 1988 2190 1989 /** 2191 * Move a message from one mailboxto another1990 * Move a message from one folder to another 2192 1991 * 2193 1992 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2194 * @param string $to_mbox Target mailbox 2195 * @param string $from_mbox Source mailbox 1993 * @param string $to_mbox Target folder 1994 * @param string $from_mbox Source folder 1995 * 2196 1996 * @return boolean True on success, False on error 2197 1997 */ 2198 function move_message($uids, $to_mbox, $from_mbox='')1998 public function move_message($uids, $to_mbox, $from_mbox='') 2199 1999 { 2200 2000 if (!strlen($from_mbox)) { 2201 $from_mbox = $this-> mailbox;2001 $from_mbox = $this->folder; 2202 2002 } 2203 2003 … … 2206 2006 } 2207 2007 2208 list($uids, $all_mode) = $this-> _parse_uids($uids, $from_mbox);2008 list($uids, $all_mode) = $this->parse_uids($uids); 2209 2009 2210 2010 // exit if no message uids are specified … … 2212 2012 return false; 2213 2013 2214 // make sure mailboxexists2215 if ($to_mbox != 'INBOX' && !$this-> mailbox_exists($to_mbox)) {2014 // make sure folder exists 2015 if ($to_mbox != 'INBOX' && !$this->folder_exists($to_mbox)) { 2216 2016 if (in_array($to_mbox, $this->default_folders)) { 2217 if (!$this->create_ mailbox($to_mbox, true)) {2017 if (!$this->create_folder($to_mbox, true)) { 2218 2018 return false; 2219 2019 } … … 2237 2037 2238 2038 // send expunge command in order to have the moved message 2239 // really deleted from the source mailbox2039 // really deleted from the source folder 2240 2040 if ($moved) { 2241 $this-> _expunge($from_mbox, false, $uids);2242 $this-> _clear_messagecount($from_mbox);2243 $this-> _clear_messagecount($to_mbox);2041 $this->expunge_message($uids, $from_mbox, false); 2042 $this->clear_messagecount($from_mbox); 2043 $this->clear_messagecount($to_mbox); 2244 2044 } 2245 2045 // moving failed … … 2253 2053 2254 2054 // remove message ids from search set 2255 if ($this->search_set && $from_mbox == $this-> mailbox) {2055 if ($this->search_set && $from_mbox == $this->folder) { 2256 2056 // threads are too complicated to just remove messages from set 2257 2057 if ($this->search_threads || $all_mode) … … 2271 2071 2272 2072 /** 2273 * Copy a message from one mailboxto another2073 * Copy a message from one folder to another 2274 2074 * 2275 2075 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2276 * @param string $to_mbox Target mailbox 2277 * @param string $from_mbox Source mailbox 2076 * @param string $to_mbox Target folder 2077 * @param string $from_mbox Source folder 2078 * 2278 2079 * @return boolean True on success, False on error 2279 2080 */ 2280 function copy_message($uids, $to_mbox, $from_mbox='')2081 public function copy_message($uids, $to_mbox, $from_mbox='') 2281 2082 { 2282 2083 if (!strlen($from_mbox)) { 2283 $from_mbox = $this-> mailbox;2284 } 2285 2286 list($uids, $all_mode) = $this-> _parse_uids($uids, $from_mbox);2084 $from_mbox = $this->folder; 2085 } 2086 2087 list($uids, $all_mode) = $this->parse_uids($uids); 2287 2088 2288 2089 // exit if no message uids are specified … … 2291 2092 } 2292 2093 2293 // make sure mailboxexists2294 if ($to_mbox != 'INBOX' && !$this-> mailbox_exists($to_mbox)) {2094 // make sure folder exists 2095 if ($to_mbox != 'INBOX' && !$this->folder_exists($to_mbox)) { 2295 2096 if (in_array($to_mbox, $this->default_folders)) { 2296 if (!$this->create_ mailbox($to_mbox, true)) {2097 if (!$this->create_folder($to_mbox, true)) { 2297 2098 return false; 2298 2099 } … … 2307 2108 2308 2109 if ($copied) { 2309 $this-> _clear_messagecount($to_mbox);2110 $this->clear_messagecount($to_mbox); 2310 2111 } 2311 2112 … … 2315 2116 2316 2117 /** 2317 * Mark messages as deleted and expunge mailbox2118 * Mark messages as deleted and expunge them 2318 2119 * 2319 2120 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2320 * @param string $ mailbox Source mailbox2121 * @param string $folder Source folder 2321 2122 * 2322 2123 * @return boolean True on success, False on error 2323 2124 */ 2324 function delete_message($uids, $mailbox='')2325 { 2326 if (!strlen($ mailbox)) {2327 $ mailbox = $this->mailbox;2328 } 2329 2330 list($uids, $all_mode) = $this-> _parse_uids($uids, $mailbox);2125 public function delete_message($uids, $folder='') 2126 { 2127 if (!strlen($folder)) { 2128 $folder = $this->folder; 2129 } 2130 2131 list($uids, $all_mode) = $this->parse_uids($uids); 2331 2132 2332 2133 // exit if no message uids are specified … … 2334 2135 return false; 2335 2136 2336 $deleted = $this->conn->flag($ mailbox, $uids, 'DELETED');2137 $deleted = $this->conn->flag($folder, $uids, 'DELETED'); 2337 2138 2338 2139 if ($deleted) { 2339 2140 // send expunge command in order to have the deleted message 2340 // really deleted from the mailbox2341 $this-> _expunge($mailbox, false, $uids);2342 $this-> _clear_messagecount($mailbox);2343 unset($this->uid_id_map[$ mailbox]);2141 // really deleted from the folder 2142 $this->expunge_message($uids, $folder, false); 2143 $this->clear_messagecount($folder); 2144 unset($this->uid_id_map[$folder]); 2344 2145 2345 2146 // unset threads internal cache … … 2347 2148 2348 2149 // remove message ids from search set 2349 if ($this->search_set && $ mailbox == $this->mailbox) {2150 if ($this->search_set && $folder == $this->folder) { 2350 2151 // threads are too complicated to just remove messages from set 2351 2152 if ($this->search_threads || $all_mode) … … 2356 2157 2357 2158 // remove cached messages 2358 $this->clear_message_cache($ mailbox, $all_mode ? null : explode(',', $uids));2159 $this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids)); 2359 2160 } 2360 2161 … … 2364 2165 2365 2166 /** 2366 * Clear all messages in a specific mailbox2367 *2368 * @param string $mailbox Mailbox name2369 *2370 * @return int Above 0 on success2371 */2372 function clear_mailbox($mailbox=null)2373 {2374 if (!strlen($mailbox)) {2375 $mailbox = $this->mailbox;2376 }2377 2378 // SELECT will set messages count for clearFolder()2379 if ($this->conn->select($mailbox)) {2380 $cleared = $this->conn->clearFolder($mailbox);2381 }2382 2383 // make sure the cache is cleared as well2384 if ($cleared) {2385 $this->clear_message_cache($mailbox);2386 $a_mailbox_cache = $this->get_cache('messagecount');2387 unset($a_mailbox_cache[$mailbox]);2388 $this->update_cache('messagecount', $a_mailbox_cache);2389 }2390 2391 return $cleared;2392 }2393 2394 2395 /**2396 2167 * Send IMAP expunge command and clear cache 2397 2168 * 2398 * @param string $mailbox Mailbox name 2169 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2170 * @param string $folder Folder name 2399 2171 * @param boolean $clear_cache False if cache should not be cleared 2400 2172 * 2401 * @return boolean True on success 2402 */ 2403 function expunge($mailbox='', $clear_cache=true) 2404 { 2405 if (!strlen($mailbox)) { 2406 $mailbox = $this->mailbox; 2407 } 2408 2409 return $this->_expunge($mailbox, $clear_cache); 2410 } 2411 2412 2413 /** 2414 * Send IMAP expunge command and clear cache 2415 * 2416 * @param string $mailbox Mailbox name 2417 * @param boolean $clear_cache False if cache should not be cleared 2418 * @param mixed $uids Message UIDs as array or comma-separated string, or '*' 2419 * @return boolean True on success 2420 * @access private 2421 * @see rcube_imap::expunge() 2422 */ 2423 private function _expunge($mailbox, $clear_cache=true, $uids=NULL) 2173 * @return boolean True on success, False on failure 2174 */ 2175 public function expunge_message($uids, $folder = null, $clear_cache = true) 2424 2176 { 2425 2177 if ($uids && $this->get_capability('UIDPLUS')) 2426 list($uids, $all_mode) = $this-> _parse_uids($uids, $mailbox);2178 list($uids, $all_mode) = $this->parse_uids($uids); 2427 2179 else 2428 2180 $uids = null; 2429 2181 2430 // force mailbox selection and check if mailbox is writeable 2182 if (!strlen($folder)) { 2183 $folder = $this->folder; 2184 } 2185 2186 // force folder selection and check if folder is writeable 2431 2187 // to prevent a situation when CLOSE is executed on closed 2432 // or EXPUNGE on read-only mailbox2433 $result = $this->conn->select($ mailbox);2188 // or EXPUNGE on read-only folder 2189 $result = $this->conn->select($folder); 2434 2190 if (!$result) { 2435 2191 return false; 2436 2192 } 2437 2193 if (!$this->conn->data['READ-WRITE']) { 2438 $this->conn->setError(rcube_imap_generic::ERROR_READONLY, " Mailboxis read-only");2194 $this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Folder is read-only"); 2439 2195 return false; 2440 2196 } … … 2444 2200 $result = $this->conn->close(); 2445 2201 else 2446 $result = $this->conn->expunge($ mailbox, $uids);2202 $result = $this->conn->expunge($folder, $uids); 2447 2203 2448 2204 if ($result && $clear_cache) { 2449 $this->clear_message_cache($ mailbox, $all_mode ? null : explode(',', $uids));2450 $this-> _clear_messagecount($mailbox);2205 $this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids)); 2206 $this->clear_messagecount($folder); 2451 2207 } 2452 2208 2453 2209 return $result; 2454 }2455 2456 2457 /**2458 * Parse message UIDs input2459 *2460 * @param mixed $uids UIDs array or comma-separated list or '*' or '1:*'2461 * @param string $mailbox Mailbox name2462 * @return array Two elements array with UIDs converted to list and ALL flag2463 * @access private2464 */2465 private function _parse_uids($uids, $mailbox)2466 {2467 if ($uids === '*' || $uids === '1:*') {2468 if (empty($this->search_set)) {2469 $uids = '1:*';2470 $all = true;2471 }2472 // get UIDs from current search set2473 else {2474 $uids = join(',', $this->search_set->get());2475 }2476 }2477 else {2478 if (is_array($uids))2479 $uids = join(',', $uids);2480 2481 if (preg_match('/[^0-9,]/', $uids))2482 $uids = '';2483 }2484 2485 return array($uids, (bool) $all);2486 2210 } 2487 2211 … … 2492 2216 2493 2217 /** 2494 * Public method for listing subscribed folders 2218 * Public method for listing subscribed folders. 2495 2219 * 2496 2220 * @param string $root Optional root folder … … 2501 2225 * 2502 2226 * @return array List of folders 2503 * @access public 2504 */ 2505 function list_mailboxes($root='', $name='*', $filter=null, $rights=null, $skip_sort=false) 2227 */ 2228 public function list_folders_subscribed($root='', $name='*', $filter=null, $rights=null, $skip_sort=false) 2506 2229 { 2507 2230 $cache_key = $root.':'.$name; … … 2518 2241 } 2519 2242 2520 $a_mboxes = $this->_list_ mailboxes($root, $name, $filter, $rights);2243 $a_mboxes = $this->_list_folders_subscribed($root, $name, $filter, $rights); 2521 2244 2522 2245 if (!is_array($a_mboxes)) { … … 2534 2257 } 2535 2258 2536 // sort mailboxes (always sort for cache)2259 // sort folders (always sort for cache) 2537 2260 if (!$skip_sort || $this->cache) { 2538 $a_mboxes = $this-> _sort_mailbox_list($a_mboxes);2539 } 2540 2541 // write mailboxlist to cache2261 $a_mboxes = $this->sort_folder_list($a_mboxes); 2262 } 2263 2264 // write folders list to cache 2542 2265 $this->update_cache($cache_key, $a_mboxes); 2543 2266 … … 2547 2270 2548 2271 /** 2549 * Private method for mailboxlisting (LSUB)2272 * protected method for folders listing (LSUB) 2550 2273 * 2551 2274 * @param string $root Optional root folder … … 2555 2278 * 2556 2279 * @return array List of subscribed folders 2557 * @see rcube_imap::list_mailboxes() 2558 * @access private 2559 */ 2560 private function _list_mailboxes($root='', $name='*', $filter=null, $rights=null) 2280 * @see rcube_imap::list_folders_subscribed() 2281 */ 2282 protected function _list_folders_subscribed($root='', $name='*', $filter=null, $rights=null) 2561 2283 { 2562 2284 $a_defaults = $a_out = array(); 2563 2285 2564 // Give plugins a chance to provide a list of mailboxes2565 $data = rcmail::get_instance()->plugins->exec_hook(' mailboxes_list',2286 // Give plugins a chance to provide a list of folders 2287 $data = rcmail::get_instance()->plugins->exec_hook('folders_list', 2566 2288 array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LSUB')); 2567 2289 … … 2577 2299 // #1486225: Some dovecot versions returns wrong result using LIST-EXTENDED 2578 2300 if (!$config->get('imap_force_lsub') && $this->get_capability('LIST-EXTENDED')) { 2579 // This will also set mailboxoptions, LSUB doesn't do that2301 // This will also set folder options, LSUB doesn't do that 2580 2302 $a_folders = $this->conn->listMailboxes($root, $name, 2581 2303 NULL, array('SUBSCRIBED')); … … 2604 2326 ) { 2605 2327 // Some servers returns \Noselect for existing folders 2606 if (!$this-> mailbox_exists($folder)) {2328 if (!$this->folder_exists($folder)) { 2607 2329 $this->conn->unsubscribe($folder); 2608 2330 unset($a_folders[$idx]); … … 2623 2345 2624 2346 /** 2625 * Get a list of all folders available on the IMAPserver2347 * Get a list of all folders available on the server 2626 2348 * 2627 2349 * @param string $root IMAP root dir … … 2633 2355 * @return array Indexed array with folder names 2634 2356 */ 2635 function list_unsubscribed($root='', $name='*', $filter=null, $rights=null, $skip_sort=false)2357 public function list_folders($root='', $name='*', $filter=null, $rights=null, $skip_sort=false) 2636 2358 { 2637 2359 $cache_key = $root.':'.$name; … … 2648 2370 } 2649 2371 2650 // Give plugins a chance to provide a list of mailboxes2651 $data = rcmail::get_instance()->plugins->exec_hook(' mailboxes_list',2372 // Give plugins a chance to provide a list of folders 2373 $data = rcmail::get_instance()->plugins->exec_hook('folders_list', 2652 2374 array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LIST')); 2653 2375 … … 2657 2379 else { 2658 2380 // retrieve list of folders from IMAP server 2659 $a_mboxes = $this->_list_ unsubscribed($root, $name);2381 $a_mboxes = $this->_list_folders($root, $name); 2660 2382 } 2661 2383 … … 2681 2403 // filter folders and sort them 2682 2404 if (!$skip_sort) { 2683 $a_mboxes = $this-> _sort_mailbox_list($a_mboxes);2684 } 2685 2686 // write mailboxlist to cache2405 $a_mboxes = $this->sort_folder_list($a_mboxes); 2406 } 2407 2408 // write folders list to cache 2687 2409 $this->update_cache($cache_key, $a_mboxes); 2688 2410 … … 2692 2414 2693 2415 /** 2694 * Private method for mailboxlisting (LIST)2416 * protected method for folders listing (LIST) 2695 2417 * 2696 2418 * @param string $root Optional root folder … … 2698 2420 * 2699 2421 * @return array List of folders 2700 * @see rcube_imap::list_ unsubscribed()2701 */ 2702 pr ivate function _list_unsubscribed($root='', $name='*')2422 * @see rcube_imap::list_folders() 2423 */ 2424 protected function _list_folders($root='', $name='*') 2703 2425 { 2704 2426 $result = $this->conn->listMailboxes($root, $name); … … 2758 2480 * Filter the given list of folders according to access rights 2759 2481 */ 2760 pr ivatefunction filter_rights($a_folders, $rights)2482 protected function filter_rights($a_folders, $rights) 2761 2483 { 2762 2484 $regex = '/('.$rights.')/'; … … 2777 2499 * @return mixed Quota info or False if not supported 2778 2500 */ 2779 function get_quota()2780 { 2781 if ($this->get_capability('QUOTA')) 2501 public function get_quota() 2502 { 2503 if ($this->get_capability('QUOTA')) { 2782 2504 return $this->conn->getQuota(); 2505 } 2783 2506 2784 2507 return false; … … 2787 2510 2788 2511 /** 2789 * Get mailbox size (size of all messages in a mailbox)2790 * 2791 * @param string $ mailbox Mailboxname2792 * 2793 * @return int Mailboxsize in bytes, False on error2794 */ 2795 function get_mailbox_size($mailbox)2512 * Get folder size (size of all messages in a folder) 2513 * 2514 * @param string $folder Folder name 2515 * 2516 * @return int Folder size in bytes, False on error 2517 */ 2518 public function folder_size($folder) 2796 2519 { 2797 2520 // @TODO: could we try to use QUOTA here? 2798 $result = $this->conn->fetchHeaderIndex($ mailbox, '1:*', 'SIZE', false);2521 $result = $this->conn->fetchHeaderIndex($folder, '1:*', 'SIZE', false); 2799 2522 2800 2523 if (is_array($result)) … … 2806 2529 2807 2530 /** 2808 * Subscribe to a specific mailbox(es) 2809 * 2810 * @param array $a_mboxes Mailbox name(s) 2531 * Subscribe to a specific folder(s) 2532 * 2533 * @param array $folders Folder name(s) 2534 * 2811 2535 * @return boolean True on success 2812 2536 */ 2813 function subscribe($a_mboxes) 2814 { 2815 if (!is_array($a_mboxes)) 2816 $a_mboxes = array($a_mboxes); 2817 2537 public function subscribe($folders) 2538 { 2818 2539 // let this common function do the main work 2819 return $this->_change_subscription($a_mboxes, 'subscribe'); 2820 } 2821 2822 2823 /** 2824 * Unsubscribe mailboxes 2825 * 2826 * @param array $a_mboxes Mailbox name(s) 2540 return $this->change_subscription($folders, 'subscribe'); 2541 } 2542 2543 2544 /** 2545 * Unsubscribe folder(s) 2546 * 2547 * @param array $a_mboxes Folder name(s) 2548 * 2827 2549 * @return boolean True on success 2828 2550 */ 2829 function unsubscribe($a_mboxes) 2830 { 2831 if (!is_array($a_mboxes)) 2832 $a_mboxes = array($a_mboxes); 2833 2551 public function unsubscribe($folders) 2552 { 2834 2553 // let this common function do the main work 2835 return $this-> _change_subscription($a_mboxes, 'unsubscribe');2836 } 2837 2838 2839 /** 2840 * Create a new mailboxon the server and register it in local cache2841 * 2842 * @param string $ mailbox New mailboxname2843 * @param boolean $subscribe True if the new mailboxshould be subscribed2554 return $this->change_subscription($folders, 'unsubscribe'); 2555 } 2556 2557 2558 /** 2559 * Create a new folder on the server and register it in local cache 2560 * 2561 * @param string $folder New folder name 2562 * @param boolean $subscribe True if the new folder should be subscribed 2844 2563 * 2845 2564 * @return boolean True on success 2846 2565 */ 2847 function create_mailbox($mailbox, $subscribe=false)2848 { 2849 $result = $this->conn->createFolder($ mailbox);2566 public function create_folder($folder, $subscribe=false) 2567 { 2568 $result = $this->conn->createFolder($folder); 2850 2569 2851 2570 // try to subscribe it … … 2855 2574 2856 2575 if ($subscribe) 2857 $this->subscribe($ mailbox);2576 $this->subscribe($folder); 2858 2577 } 2859 2578 … … 2863 2582 2864 2583 /** 2865 * Set a new name to an existing mailbox2866 * 2867 * @param string $ mailbox Mailboxto rename2868 * @param string $new_name New mailboxname2584 * Set a new name to an existing folder 2585 * 2586 * @param string $folder Folder to rename 2587 * @param string $new_name New folder name 2869 2588 * 2870 2589 * @return boolean True on success 2871 2590 */ 2872 function rename_mailbox($mailbox, $new_name)2591 public function rename_folder($folder, $new_name) 2873 2592 { 2874 2593 if (!strlen($new_name)) { … … 2879 2598 2880 2599 // get list of subscribed folders 2881 if ((strpos($ mailbox, '%') === false) && (strpos($mailbox, '*') === false)) {2882 $a_subscribed = $this->_list_ mailboxes('', $mailbox. $delm . '*');2883 $subscribed = $this-> mailbox_exists($mailbox, true);2600 if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) { 2601 $a_subscribed = $this->_list_folders_subscribed('', $folder . $delm . '*'); 2602 $subscribed = $this->folder_exists($folder, true); 2884 2603 } 2885 2604 else { 2886 $a_subscribed = $this->_list_ mailboxes();2887 $subscribed = in_array($ mailbox, $a_subscribed);2888 } 2889 2890 $result = $this->conn->renameFolder($ mailbox, $new_name);2605 $a_subscribed = $this->_list_folders_subscribed(); 2606 $subscribed = in_array($folder, $a_subscribed); 2607 } 2608 2609 $result = $this->conn->renameFolder($folder, $new_name); 2891 2610 2892 2611 if ($result) { 2893 2612 // unsubscribe the old folder, subscribe the new one 2894 2613 if ($subscribed) { 2895 $this->conn->unsubscribe($ mailbox);2614 $this->conn->unsubscribe($folder); 2896 2615 $this->conn->subscribe($new_name); 2897 2616 } 2898 2617 2899 // check if mailboxchildren are subscribed2618 // check if folder children are subscribed 2900 2619 foreach ($a_subscribed as $c_subscribed) { 2901 if (strpos($c_subscribed, $ mailbox.$delm) === 0) {2620 if (strpos($c_subscribed, $folder.$delm) === 0) { 2902 2621 $this->conn->unsubscribe($c_subscribed); 2903 $this->conn->subscribe(preg_replace('/^'.preg_quote($ mailbox, '/').'/',2622 $this->conn->subscribe(preg_replace('/^'.preg_quote($folder, '/').'/', 2904 2623 $new_name, $c_subscribed)); 2905 2624 … … 2910 2629 2911 2630 // clear cache 2912 $this->clear_message_cache($ mailbox);2631 $this->clear_message_cache($folder); 2913 2632 $this->clear_cache('mailboxes', true); 2914 2633 } … … 2919 2638 2920 2639 /** 2921 * Remove mailboxfrom server2922 * 2923 * @param string $ mailbox Mailboxname2640 * Remove folder from server 2641 * 2642 * @param string $folder Folder name 2924 2643 * 2925 2644 * @return boolean True on success 2926 2645 */ 2927 function delete_ mailbox($mailbox)2646 function delete_folder($folder) 2928 2647 { 2929 2648 $delm = $this->get_hierarchy_delimiter(); 2930 2649 2931 2650 // get list of folders 2932 if ((strpos($ mailbox, '%') === false) && (strpos($mailbox, '*') === false))2933 $sub_mboxes = $this->list_unsubscribed('', $ mailbox. $delm . '*');2651 if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) 2652 $sub_mboxes = $this->list_unsubscribed('', $folder . $delm . '*'); 2934 2653 else 2935 2654 $sub_mboxes = $this->list_unsubscribed(); 2936 2655 2937 2656 // send delete command to server 2938 $result = $this->conn->deleteFolder($ mailbox);2657 $result = $this->conn->deleteFolder($folder); 2939 2658 2940 2659 if ($result) { 2941 // unsubscribe mailbox2942 $this->conn->unsubscribe($ mailbox);2660 // unsubscribe folder 2661 $this->conn->unsubscribe($folder); 2943 2662 2944 2663 foreach ($sub_mboxes as $c_mbox) { 2945 if (strpos($c_mbox, $ mailbox.$delm) === 0) {2664 if (strpos($c_mbox, $folder.$delm) === 0) { 2946 2665 $this->conn->unsubscribe($c_mbox); 2947 2666 if ($this->conn->deleteFolder($c_mbox)) { … … 2951 2670 } 2952 2671 2953 // clear mailbox-related cache2954 $this->clear_message_cache($ mailbox);2672 // clear folder-related cache 2673 $this->clear_message_cache($folder); 2955 2674 $this->clear_cache('mailboxes', true); 2956 2675 } … … 2963 2682 * Create all folders specified as default 2964 2683 */ 2965 function create_default_folders()2684 public function create_default_folders() 2966 2685 { 2967 2686 // create default folders if they do not exist 2968 2687 foreach ($this->default_folders as $folder) { 2969 if (!$this-> mailbox_exists($folder))2970 $this->create_ mailbox($folder, true);2971 else if (!$this-> mailbox_exists($folder, true))2688 if (!$this->folder_exists($folder)) 2689 $this->create_folder($folder, true); 2690 else if (!$this->folder_exists($folder, true)) 2972 2691 $this->subscribe($folder); 2973 2692 } … … 2978 2697 * Checks if folder exists and is subscribed 2979 2698 * 2980 * @param string $ mailboxFolder name2699 * @param string $folder Folder name 2981 2700 * @param boolean $subscription Enable subscription checking 2982 2701 * 2983 2702 * @return boolean TRUE or FALSE 2984 2703 */ 2985 function mailbox_exists($mailbox, $subscription=false)2986 { 2987 if ($ mailbox== 'INBOX') {2704 public function folder_exists($folder, $subscription=false) 2705 { 2706 if ($folder == 'INBOX') { 2988 2707 return true; 2989 2708 } … … 2991 2710 $key = $subscription ? 'subscribed' : 'existing'; 2992 2711 2993 if (is_array($this->icache[$key]) && in_array($ mailbox, $this->icache[$key]))2712 if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) 2994 2713 return true; 2995 2714 2996 2715 if ($subscription) { 2997 $a_folders = $this->conn->listSubscribed('', $ mailbox);2716 $a_folders = $this->conn->listSubscribed('', $folder); 2998 2717 } 2999 2718 else { 3000 $a_folders = $this->conn->listMailboxes('', $ mailbox);3001 } 3002 3003 if (is_array($a_folders) && in_array($ mailbox, $a_folders)) {3004 $this->icache[$key][] = $ mailbox;2719 $a_folders = $this->conn->listMailboxes('', $folder); 2720 } 2721 2722 if (is_array($a_folders) && in_array($folder, $a_folders)) { 2723 $this->icache[$key][] = $folder; 3005 2724 return true; 3006 2725 } … … 3013 2732 * Returns the namespace where the folder is in 3014 2733 * 3015 * @param string $ mailboxFolder name2734 * @param string $folder Folder name 3016 2735 * 3017 2736 * @return string One of 'personal', 'other' or 'shared' 3018 * @access public 3019 */ 3020 function mailbox_namespace($mailbox) 3021 { 3022 if ($mailbox == 'INBOX') { 2737 */ 2738 public function folder_namespace($folder) 2739 { 2740 if ($folder == 'INBOX') { 3023 2741 return 'personal'; 3024 2742 } … … 3028 2746 foreach ($namespace as $ns) { 3029 2747 if ($len = strlen($ns[0])) { 3030 if (($len > 1 && $ mailbox== substr($ns[0], 0, -1))3031 || strpos($ mailbox, $ns[0]) === 02748 if (($len > 1 && $folder == substr($ns[0], 0, -1)) 2749 || strpos($folder, $ns[0]) === 0 3032 2750 ) { 3033 2751 return $type; … … 3048 2766 * of the folders tree. 3049 2767 * 3050 * @param string $ mailboxFolder name2768 * @param string $folder Folder name 3051 2769 * @param string $mode Mode name (out/in) 3052 2770 * 3053 2771 * @return string Folder name 3054 2772 */ 3055 function mod_mailbox($mailbox, $mode = 'out')3056 { 3057 if (!strlen($ mailbox)) {3058 return $ mailbox;2773 public function mod_folder($folder, $mode = 'out') 2774 { 2775 if (!strlen($folder)) { 2776 return $folder; 3059 2777 } 3060 2778 … … 3063 2781 3064 2782 if (!$prefix_len) { 3065 return $ mailbox;2783 return $folder; 3066 2784 } 3067 2785 3068 2786 // remove prefix for output 3069 2787 if ($mode == 'out') { 3070 if (substr($ mailbox, 0, $prefix_len) === $prefix) {3071 return substr($ mailbox, $prefix_len);2788 if (substr($folder, 0, $prefix_len) === $prefix) { 2789 return substr($folder, $prefix_len); 3072 2790 } 3073 2791 } 3074 2792 // add prefix for input (e.g. folder creation) 3075 2793 else { 3076 return $prefix . $ mailbox;3077 } 3078 3079 return $ mailbox;2794 return $prefix . $folder; 2795 } 2796 2797 return $folder; 3080 2798 } 3081 2799 … … 3084 2802 * Gets folder attributes from LIST response, e.g. \Noselect, \Noinferiors 3085 2803 * 3086 * @param string $ mailboxFolder name2804 * @param string $folder Folder name 3087 2805 * @param bool $force Set to True if attributes should be refreshed 3088 2806 * 3089 2807 * @return array Options list 3090 2808 */ 3091 function mailbox_attributes($mailbox, $force=false)2809 public function folder_attributes($folder, $force=false) 3092 2810 { 3093 2811 // get attributes directly from LIST command 3094 if (!empty($this->conn->data['LIST']) && is_array($this->conn->data['LIST'][$ mailbox])) {3095 $opts = $this->conn->data['LIST'][$ mailbox];2812 if (!empty($this->conn->data['LIST']) && is_array($this->conn->data['LIST'][$folder])) { 2813 $opts = $this->conn->data['LIST'][$folder]; 3096 2814 } 3097 2815 // get cached folder attributes 3098 2816 else if (!$force) { 3099 2817 $opts = $this->get_cache('mailboxes.attributes'); 3100 $opts = $opts[$ mailbox];2818 $opts = $opts[$folder]; 3101 2819 } 3102 2820 3103 2821 if (!is_array($opts)) { 3104 $this->conn->listMailboxes('', $ mailbox);3105 $opts = $this->conn->data['LIST'][$ mailbox];2822 $this->conn->listMailboxes('', $folder); 2823 $opts = $this->conn->data['LIST'][$folder]; 3106 2824 } 3107 2825 … … 3111 2829 3112 2830 /** 3113 * Gets connection (and current mailbox) data: UIDVALIDITY, EXISTS, RECENT,2831 * Gets connection (and current folder) data: UIDVALIDITY, EXISTS, RECENT, 3114 2832 * PERMANENTFLAGS, UIDNEXT, UNSEEN 3115 2833 * 3116 * @param string $ mailboxFolder name2834 * @param string $folder Folder name 3117 2835 * 3118 2836 * @return array Data 3119 2837 */ 3120 function mailbox_data($mailbox)3121 { 3122 if (!strlen($ mailbox))3123 $ mailbox = $this->mailbox !== null ? $this->mailbox: 'INBOX';3124 3125 if ($this->conn->selected != $ mailbox) {3126 if ($this->conn->select($ mailbox))3127 $this-> mailbox = $mailbox;2838 public function folder_data($folder) 2839 { 2840 if (!strlen($folder)) 2841 $folder = $this->folder !== null ? $this->folder : 'INBOX'; 2842 2843 if ($this->conn->selected != $folder) { 2844 if ($this->conn->select($folder)) 2845 $this->folder = $folder; 3128 2846 else 3129 2847 return null; … … 3134 2852 // add (E)SEARCH result for ALL UNDELETED query 3135 2853 if (!empty($this->icache['undeleted_idx']) 3136 && $this->icache['undeleted_idx']->getParameters('MAILBOX') == $ mailbox2854 && $this->icache['undeleted_idx']->getParameters('MAILBOX') == $folder 3137 2855 ) { 3138 2856 $data['UNDELETED'] = $this->icache['undeleted_idx']; … … 3146 2864 * Returns extended information about the folder 3147 2865 * 3148 * @param string $ mailboxFolder name2866 * @param string $folder Folder name 3149 2867 * 3150 2868 * @return array Data 3151 2869 */ 3152 function mailbox_info($mailbox)3153 { 3154 if ($this->icache['options'] && $this->icache['options']['name'] == $ mailbox) {2870 public function folder_info($folder) 2871 { 2872 if ($this->icache['options'] && $this->icache['options']['name'] == $folder) { 3155 2873 return $this->icache['options']; 3156 2874 } … … 3162 2880 // check if the folder is a namespace prefix 3163 2881 if (!empty($namespace)) { 3164 $mbox = $ mailbox. $this->delimiter;2882 $mbox = $folder . $this->delimiter; 3165 2883 foreach ($namespace as $ns) { 3166 2884 if (!empty($ns)) { … … 3176 2894 // check if the folder is other user virtual-root 3177 2895 if (!$options['is_root'] && !empty($namespace) && !empty($namespace['other'])) { 3178 $parts = explode($this->delimiter, $ mailbox);2896 $parts = explode($this->delimiter, $folder); 3179 2897 if (count($parts) == 2) { 3180 2898 $mbox = $parts[0] . $this->delimiter; … … 3188 2906 } 3189 2907 3190 $options['name'] = $ mailbox;3191 $options['attributes'] = $this-> mailbox_attributes($mailbox, true);3192 $options['namespace'] = $this-> mailbox_namespace($mailbox);3193 $options['rights'] = $acl && !$options['is_root'] ? (array)$this->my_rights($ mailbox) : array();3194 $options['special'] = in_array($ mailbox, $this->default_folders);2908 $options['name'] = $folder; 2909 $options['attributes'] = $this->folder_attributes($folder, true); 2910 $options['namespace'] = $this->folder_namespace($folder); 2911 $options['rights'] = $acl && !$options['is_root'] ? (array)$this->my_rights($folder) : array(); 2912 $options['special'] = in_array($folder, $this->default_folders); 3195 2913 3196 2914 // Set 'noselect' and 'norename' flags … … 3227 2945 * Synchronizes messages cache. 3228 2946 * 3229 * @param string $ mailboxFolder name3230 */ 3231 public function mailbox_sync($mailbox)2947 * @param string $folder Folder name 2948 */ 2949 public function folder_sync($folder) 3232 2950 { 3233 2951 if ($mcache = $this->get_mcache_engine()) { 3234 $mcache->synchronize($ mailbox);2952 $mcache->synchronize($folder); 3235 2953 } 3236 2954 } … … 3242 2960 * @return string Space-separated list of header names 3243 2961 */ 3244 private function get_fetch_headers() 3245 { 3246 $headers = explode(' ', $this->fetch_add_headers); 3247 $headers = array_map('strtoupper', $headers); 3248 3249 if ($this->messages_caching || $this->get_all_headers) 2962 protected function get_fetch_headers() 2963 { 2964 if (!empty($this->options['fetch_headers'])) { 2965 $headers = explode(' ', $this->options['fetch_headers']); 2966 $headers = array_map('strtoupper', $headers); 2967 } 2968 else { 2969 $headers = array(); 2970 } 2971 2972 if ($this->messages_caching || $this->options['all_headers']) { 3250 2973 $headers = array_merge($headers, $this->all_headers); 2974 } 3251 2975 3252 2976 return implode(' ', array_unique($headers)); … … 3259 2983 3260 2984 /** 3261 * Changes the ACL on the specified mailbox(SETACL)3262 * 3263 * @param string $ mailbox Mailboxname2985 * Changes the ACL on the specified folder (SETACL) 2986 * 2987 * @param string $folder Folder name 3264 2988 * @param string $user User name 3265 2989 * @param string $acl ACL string 3266 2990 * 3267 2991 * @return boolean True on success, False on failure 3268 *3269 * @access public3270 2992 * @since 0.5-beta 3271 2993 */ 3272 function set_acl($mailbox, $user, $acl)2994 public function set_acl($folder, $user, $acl) 3273 2995 { 3274 2996 if ($this->get_capability('ACL')) 3275 return $this->conn->setACL($ mailbox, $user, $acl);2997 return $this->conn->setACL($folder, $user, $acl); 3276 2998 3277 2999 return false; … … 3282 3004 * Removes any <identifier,rights> pair for the 3283 3005 * specified user from the ACL for the specified 3284 * mailbox(DELETEACL)3285 * 3286 * @param string $ mailbox Mailboxname3006 * folder (DELETEACL) 3007 * 3008 * @param string $folder Folder name 3287 3009 * @param string $user User name 3288 3010 * 3289 3011 * @return boolean True on success, False on failure 3290 *3291 * @access public3292 3012 * @since 0.5-beta 3293 3013 */ 3294 function delete_acl($mailbox, $user)3014 public function delete_acl($folder, $user) 3295 3015 { 3296 3016 if ($this->get_capability('ACL')) 3297 return $this->conn->deleteACL($ mailbox, $user);3017 return $this->conn->deleteACL($folder, $user); 3298 3018 3299 3019 return false; … … 3302 3022 3303 3023 /** 3304 * Returns the access control list for mailbox(GETACL)3305 * 3306 * @param string $ mailbox Mailboxname3024 * Returns the access control list for folder (GETACL) 3025 * 3026 * @param string $folder Folder name 3307 3027 * 3308 3028 * @return array User-rights array on success, NULL on error 3309 * @access public3310 3029 * @since 0.5-beta 3311 3030 */ 3312 function get_acl($mailbox)3031 public function get_acl($folder) 3313 3032 { 3314 3033 if ($this->get_capability('ACL')) 3315 return $this->conn->getACL($ mailbox);3034 return $this->conn->getACL($folder); 3316 3035 3317 3036 return NULL; … … 3321 3040 /** 3322 3041 * Returns information about what rights can be granted to the 3323 * user (identifier) in the ACL for the mailbox(LISTRIGHTS)3324 * 3325 * @param string $ mailbox Mailboxname3042 * user (identifier) in the ACL for the folder (LISTRIGHTS) 3043 * 3044 * @param string $folder Folder name 3326 3045 * @param string $user User name 3327 3046 * 3328 3047 * @return array List of user rights 3329 * @access public3330 3048 * @since 0.5-beta 3331 3049 */ 3332 function list_rights($mailbox, $user)3050 public function list_rights($folder, $user) 3333 3051 { 3334 3052 if ($this->get_capability('ACL')) 3335 return $this->conn->listRights($ mailbox, $user);3053 return $this->conn->listRights($folder, $user); 3336 3054 3337 3055 return NULL; … … 3341 3059 /** 3342 3060 * Returns the set of rights that the current user has to 3343 * mailbox(MYRIGHTS)3344 * 3345 * @param string $ mailbox Mailboxname3061 * folder (MYRIGHTS) 3062 * 3063 * @param string $folder Folder name 3346 3064 * 3347 3065 * @return array MYRIGHTS response on success, NULL on error 3348 * @access public3349 3066 * @since 0.5-beta 3350 3067 */ 3351 function my_rights($mailbox)3068 public function my_rights($folder) 3352 3069 { 3353 3070 if ($this->get_capability('ACL')) 3354 return $this->conn->myRights($ mailbox);3071 return $this->conn->myRights($folder); 3355 3072 3356 3073 return NULL; … … 3361 3078 * Sets IMAP metadata/annotations (SETMETADATA/SETANNOTATION) 3362 3079 * 3363 * @param string $ mailbox Mailboxname (empty for server metadata)3080 * @param string $folder Folder name (empty for server metadata) 3364 3081 * @param array $entries Entry-value array (use NULL value as NIL) 3365 3082 * 3366 3083 * @return boolean True on success, False on failure 3367 * @access public3368 3084 * @since 0.5-beta 3369 3085 */ 3370 function set_metadata($mailbox, $entries)3086 public function set_metadata($folder, $entries) 3371 3087 { 3372 3088 if ($this->get_capability('METADATA') || 3373 (!strlen($ mailbox) && $this->get_capability('METADATA-SERVER'))3089 (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 3374 3090 ) { 3375 return $this->conn->setMetadata($ mailbox, $entries);3091 return $this->conn->setMetadata($folder, $entries); 3376 3092 } 3377 3093 else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) { … … 3380 3096 $entries[$entry] = array($ent, $attr, $value); 3381 3097 } 3382 return $this->conn->setAnnotation($ mailbox, $entries);3098 return $this->conn->setAnnotation($folder, $entries); 3383 3099 } 3384 3100 … … 3390 3106 * Unsets IMAP metadata/annotations (SETMETADATA/SETANNOTATION) 3391 3107 * 3392 * @param string $ mailbox Mailboxname (empty for server metadata)3108 * @param string $folder Folder name (empty for server metadata) 3393 3109 * @param array $entries Entry names array 3394 3110 * 3395 3111 * @return boolean True on success, False on failure 3396 *3397 * @access public3398 3112 * @since 0.5-beta 3399 3113 */ 3400 function delete_metadata($mailbox, $entries)3114 public function delete_metadata($folder, $entries) 3401 3115 { 3402 3116 if ($this->get_capability('METADATA') || 3403 (!strlen($ mailbox) && $this->get_capability('METADATA-SERVER'))3117 (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 3404 3118 ) { 3405 return $this->conn->deleteMetadata($ mailbox, $entries);3119 return $this->conn->deleteMetadata($folder, $entries); 3406 3120 } 3407 3121 else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) { … … 3410 3124 $entries[$idx] = array($ent, $attr, NULL); 3411 3125 } 3412 return $this->conn->setAnnotation($ mailbox, $entries);3126 return $this->conn->setAnnotation($folder, $entries); 3413 3127 } 3414 3128 … … 3420 3134 * Returns IMAP metadata/annotations (GETMETADATA/GETANNOTATION) 3421 3135 * 3422 * @param string $ mailbox Mailboxname (empty for server metadata)3136 * @param string $folder Folder name (empty for server metadata) 3423 3137 * @param array $entries Entries 3424 3138 * @param array $options Command options (with MAXSIZE and DEPTH keys) 3425 3139 * 3426 3140 * @return array Metadata entry-value hash array on success, NULL on error 3427 *3428 * @access public3429 3141 * @since 0.5-beta 3430 3142 */ 3431 function get_metadata($mailbox, $entries, $options=array())3143 public function get_metadata($folder, $entries, $options=array()) 3432 3144 { 3433 3145 if ($this->get_capability('METADATA') || 3434 (!strlen($ mailbox) && $this->get_capability('METADATA-SERVER'))3146 (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 3435 3147 ) { 3436 return $this->conn->getMetadata($ mailbox, $entries, $options);3148 return $this->conn->getMetadata($folder, $entries, $options); 3437 3149 } 3438 3150 else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) { … … 3448 3160 // @TODO: Honor MAXSIZE and DEPTH options 3449 3161 foreach ($queries as $attrib => $entry) 3450 if ($result = $this->conn->getAnnotation($ mailbox, $entry, $attrib))3162 if ($result = $this->conn->getAnnotation($folder, $entry, $attrib)) 3451 3163 $res = array_merge_recursive($res, $result); 3452 3164 … … 3466 3178 * @return array Entry-attribute list, NULL if not supported (?) 3467 3179 */ 3468 pr ivatefunction md2annotate($entry)3180 protected function md2annotate($entry) 3469 3181 { 3470 3182 if (substr($entry, 0, 7) == '/shared') { 3471 3183 return array(substr($entry, 7), 'value.shared'); 3472 3184 } 3473 else if (substr($entry, 0, 8) == '/pr ivate') {3185 else if (substr($entry, 0, 8) == '/protected') { 3474 3186 return array(substr($entry, 8), 'value.priv'); 3475 3187 } … … 3488 3200 * 3489 3201 * @param string $type Cache type (@see rcmail::get_cache) 3490 * @access public 3491 */ 3492 function set_caching($type) 3202 */ 3203 public function set_caching($type) 3493 3204 { 3494 3205 if ($type) { … … 3506 3217 * Getter for IMAP cache object 3507 3218 */ 3508 pr ivatefunction get_cache_engine()3219 protected function get_cache_engine() 3509 3220 { 3510 3221 if ($this->caching && !$this->cache) { … … 3520 3231 * 3521 3232 * @param string $key Cache key 3233 * 3522 3234 * @return mixed 3523 * @access public 3524 */ 3525 function get_cache($key) 3235 */ 3236 public function get_cache($key) 3526 3237 { 3527 3238 if ($cache = $this->get_cache_engine()) { … … 3535 3246 * @param string $key Cache key 3536 3247 * @param mixed $data Data 3537 * @access public 3538 */ 3539 function update_cache($key, $data) 3248 */ 3249 protected function update_cache($key, $data) 3540 3250 { 3541 3251 if ($cache = $this->get_cache_engine()) { … … 3550 3260 * @param boolean $prefix_mode Enable it to clear all keys starting 3551 3261 * with prefix specified in $key 3552 * @access public 3553 */ 3554 function clear_cache($key=null, $prefix_mode=false) 3262 */ 3263 public function clear_cache($key = null, $prefix_mode = false) 3555 3264 { 3556 3265 if ($cache = $this->get_cache_engine()) { … … 3569 3278 * @param boolean $set Flag 3570 3279 */ 3571 function set_messages_caching($set)3280 public function set_messages_caching($set) 3572 3281 { 3573 3282 if ($set) { … … 3586 3295 * Getter for messages cache object 3587 3296 */ 3588 pr ivatefunction get_mcache_engine()3297 protected function get_mcache_engine() 3589 3298 { 3590 3299 if ($this->messages_caching && !$this->mcache) { … … 3592 3301 if ($dbh = $rcmail->get_dbh()) { 3593 3302 $this->mcache = new rcube_imap_cache( 3594 $dbh, $this, $rcmail->user->ID, $this-> skip_deleted);3303 $dbh, $this, $rcmail->user->ID, $this->options['skip_deleted']); 3595 3304 } 3596 3305 } … … 3603 3312 * Clears the messages cache. 3604 3313 * 3605 * @param string $ mailboxFolder name3314 * @param string $folder Folder name 3606 3315 * @param array $uids Optional message UIDs to remove from cache 3607 3316 */ 3608 function clear_message_cache($mailbox= null, $uids = null)3317 protected function clear_message_cache($folder = null, $uids = null) 3609 3318 { 3610 3319 if ($mcache = $this->get_mcache_engine()) { 3611 $mcache->clear($ mailbox, $uids);3320 $mcache->clear($folder, $uids); 3612 3321 } 3613 3322 } … … 3615 3324 3616 3325 /* -------------------------------- 3617 * pr ivatemethods3326 * protected methods 3618 3327 * --------------------------------*/ 3619 3328 … … 3623 3332 * @param string $sort_field Sort column 3624 3333 * @param string $sort_order Sort order 3625 * @access private 3626 */ 3627 private function set_sort_order($sort_field, $sort_order) 3334 */ 3335 protected function set_sort_order($sort_field, $sort_order) 3628 3336 { 3629 3337 if ($sort_field != null) … … 3635 3343 3636 3344 /** 3637 * Sort mailboxes first by default folders and then in alphabethical order 3638 * 3639 * @param array $a_folders Mailboxes list 3640 * @access private 3641 */ 3642 private function _sort_mailbox_list($a_folders) 3345 * Sort folders first by default folders and then in alphabethical order 3346 * 3347 * @param array $a_folders Folders list 3348 */ 3349 protected function sort_folder_list($a_folders) 3643 3350 { 3644 3351 $a_out = $a_defaults = $folders = array(); … … 3670 3377 $a_out[] = (string) $folder; 3671 3378 unset($folders[$key]); 3672 $this-> _rsort($folder, $delimiter, $folders, $a_out);3379 $this->rsort($folder, $delimiter, $folders, $a_out); 3673 3380 } 3674 3381 … … 3678 3385 3679 3386 /** 3680 * @access private3681 */ 3682 pr ivate function _rsort($folder, $delimiter, &$list, &$out)3387 * Recursive method for sorting folders 3388 */ 3389 protected function rsort($folder, $delimiter, &$list, &$out) 3683 3390 { 3684 3391 while (list($key, $name) = each($list)) { … … 3687 3394 $out[] = (string) $name; 3688 3395 unset($list[$key]); 3689 $this-> _rsort($name, $delimiter, $list, $out);3396 $this->rsort($name, $delimiter, $list, $out); 3690 3397 } 3691 3398 } … … 3698 3405 * 3699 3406 * @param int $id Message (sequence) ID 3700 * @param string $ mailbox Mailboxname3407 * @param string $folder Folder name 3701 3408 * 3702 3409 * @return int Message UID 3703 3410 */ 3704 public function id2uid($id, $ mailbox= null)3705 { 3706 if (!strlen($ mailbox)) {3707 $ mailbox = $this->mailbox;3708 } 3709 3710 if ($uid = array_search($id, (array)$this->uid_id_map[$ mailbox])) {3411 public function id2uid($id, $folder = null) 3412 { 3413 if (!strlen($folder)) { 3414 $folder = $this->folder; 3415 } 3416 3417 if ($uid = array_search($id, (array)$this->uid_id_map[$folder])) { 3711 3418 return $uid; 3712 3419 } 3713 3420 3714 $uid = $this->conn->ID2UID($ mailbox, $id);3715 3716 $this->uid_id_map[$ mailbox][$uid] = $id;3421 $uid = $this->conn->ID2UID($folder, $id); 3422 3423 $this->uid_id_map[$folder][$uid] = $id; 3717 3424 3718 3425 return $uid; … … 3721 3428 3722 3429 /** 3723 * Subscribe/unsubscribe a list of mailboxes and update local cache 3724 * @access private 3725 */ 3726 private function _change_subscription($a_mboxes, $mode) 3430 * Subscribe/unsubscribe a list of folders and update local cache 3431 */ 3432 protected function change_subscription($folders, $mode) 3727 3433 { 3728 3434 $updated = false; 3729 3435 3730 if ( is_array($a_mboxes))3731 foreach ( $a_mboxes as $i => $mailbox) {3732 $ a_mboxes[$i] = $mailbox;3436 if (!empty($folders)) { 3437 foreach ((array)$folders as $i => $folder) { 3438 $folders[$i] = $folder; 3733 3439 3734 3440 if ($mode == 'subscribe') 3735 $updated = $this->conn->subscribe($ mailbox);3441 $updated = $this->conn->subscribe($folder); 3736 3442 else if ($mode == 'unsubscribe') 3737 $updated = $this->conn->unsubscribe($mailbox); 3738 } 3739 3740 // clear cached mailbox list(s) 3443 $updated = $this->conn->unsubscribe($folder); 3444 } 3445 } 3446 3447 // clear cached folders list(s) 3741 3448 if ($updated) { 3742 3449 $this->clear_cache('mailboxes', true); … … 3748 3455 3749 3456 /** 3750 * Increde/decrese messagecount for a specific mailbox 3751 * @access private 3752 */ 3753 private function _set_messagecount($mailbox, $mode, $increment) 3457 * Increde/decrese messagecount for a specific folder 3458 */ 3459 protected function set_messagecount($folder, $mode, $increment) 3754 3460 { 3755 3461 $mode = strtoupper($mode); 3756 $a_ mailbox_cache = $this->get_cache('messagecount');3757 3758 if (!is_array($a_ mailbox_cache[$mailbox]) || !isset($a_mailbox_cache[$mailbox][$mode]) || !is_numeric($increment))3462 $a_folder_cache = $this->get_cache('messagecount'); 3463 3464 if (!is_array($a_folder_cache[$folder]) || !isset($a_folder_cache[$folder][$mode]) || !is_numeric($increment)) 3759 3465 return false; 3760 3466 3761 3467 // add incremental value to messagecount 3762 $a_ mailbox_cache[$mailbox][$mode] += $increment;3468 $a_folder_cache[$folder][$mode] += $increment; 3763 3469 3764 3470 // there's something wrong, delete from cache 3765 if ($a_ mailbox_cache[$mailbox][$mode] < 0)3766 unset($a_ mailbox_cache[$mailbox][$mode]);3471 if ($a_folder_cache[$folder][$mode] < 0) 3472 unset($a_folder_cache[$folder][$mode]); 3767 3473 3768 3474 // write back to cache 3769 $this->update_cache('messagecount', $a_ mailbox_cache);3475 $this->update_cache('messagecount', $a_folder_cache); 3770 3476 3771 3477 return true; … … 3774 3480 3775 3481 /** 3776 * Remove messagecount of a specific mailbox from cache 3777 * @access private 3778 */ 3779 private function _clear_messagecount($mailbox, $mode=null) 3780 { 3781 $a_mailbox_cache = $this->get_cache('messagecount'); 3782 3783 if (is_array($a_mailbox_cache[$mailbox])) { 3482 * Remove messagecount of a specific folder from cache 3483 */ 3484 protected function clear_messagecount($folder, $mode=null) 3485 { 3486 $a_folder_cache = $this->get_cache('messagecount'); 3487 3488 if (is_array($a_folder_cache[$folder])) { 3784 3489 if ($mode) { 3785 unset($a_ mailbox_cache[$mailbox][$mode]);3490 unset($a_folder_cache[$folder][$mode]); 3786 3491 } 3787 3492 else { 3788 unset($a_ mailbox_cache[$mailbox]);3789 } 3790 $this->update_cache('messagecount', $a_ mailbox_cache);3493 unset($a_folder_cache[$folder]); 3494 } 3495 $this->update_cache('messagecount', $a_folder_cache); 3791 3496 } 3792 3497 } … … 3803 3508 3804 3509 } // end class rcube_imap 3805 3806 3807 /**3808 * Class representing a message part3809 *3810 * @package Mail3811 */3812 class rcube_message_part3813 {3814 var $mime_id = '';3815 var $ctype_primary = 'text';3816 var $ctype_secondary = 'plain';3817 var $mimetype = 'text/plain';3818 var $disposition = '';3819 var $filename = '';3820 var $encoding = '8bit';3821 var $charset = '';3822 var $size = 0;3823 var $headers = array();3824 var $d_parameters = array();3825 var $ctype_parameters = array();3826 3827 function __clone()3828 {3829 if (isset($this->parts))3830 foreach ($this->parts as $idx => $part)3831 if (is_object($part))3832 $this->parts[$idx] = clone $part;3833 }3834 }3835 3836 3837 /**3838 * Class for sorting an array of rcube_mail_header objects in a predetermined order.3839 *3840 * @package Mail3841 * @author Eric Stadtherr3842 */3843 class rcube_header_sorter3844 {3845 private $uids = array();3846 3847 3848 /**3849 * Set the predetermined sort order.3850 *3851 * @param array $index Numerically indexed array of IMAP UIDs3852 */3853 function set_index($index)3854 {3855 $index = array_flip($index);3856 3857 $this->uids = $index;3858 }3859 3860 /**3861 * Sort the array of header objects3862 *3863 * @param array $headers Array of rcube_mail_header objects indexed by UID3864 */3865 function sort_headers(&$headers)3866 {3867 uksort($headers, array($this, "compare_uids"));3868 }3869 3870 /**3871 * Sort method called by uksort()3872 *3873 * @param int $a Array key (UID)3874 * @param int $b Array key (UID)3875 */3876 function compare_uids($a, $b)3877 {3878 // then find each sequence number in my ordered list3879 $posa = isset($this->uids[$a]) ? intval($this->uids[$a]) : -1;3880 $posb = isset($this->uids[$b]) ? intval($this->uids[$b]) : -1;3881 3882 // return the relative position as the comparison value3883 return $posa - $posb;3884 }3885 } -
branches/devel-framework/roundcubemail/program/include/rcube_imap_cache.php
r5658 r5758 199 199 if ($data === null) { 200 200 // Get mailbox data (UIDVALIDITY, counters, etc.) for status check 201 $mbox_data = $this->imap-> mailbox_data($mailbox);201 $mbox_data = $this->imap->folder_data($mailbox); 202 202 $data = $this->get_index_data($mailbox, $sort_field, $sort_order, $mbox_data); 203 203 … … 260 260 if ($index === null) { 261 261 // Get mailbox data (UIDVALIDITY, counters, etc.) for status check 262 $mbox_data = $this->imap-> mailbox_data($mailbox);262 $mbox_data = $this->imap->folder_data($mailbox); 263 263 264 264 if ($mbox_data['EXISTS']) { … … 372 372 // Get the message from IMAP server 373 373 if (empty($message) && $update) { 374 $message = $this->imap->get_ headers($uid, $mailbox, true);374 $message = $this->imap->get_message_headers($uid, $mailbox, true); 375 375 // cache will be updated in close(), see below 376 376 } … … 741 741 742 742 // Get mailbox data (UIDVALIDITY, counters, etc.) for status check 743 $mbox_data = $this->imap-> mailbox_data($mailbox);743 $mbox_data = $this->imap->folder_data($mailbox); 744 744 745 745 // @TODO: Think about skipping validation checks. … … 902 902 903 903 // Get mailbox data (UIDVALIDITY, HIGHESTMODSEQ, counters, etc.) 904 $mbox_data = $this->imap-> mailbox_data($mailbox);904 $mbox_data = $this->imap->folder_data($mailbox); 905 905 906 906 if (empty($mbox_data)) { … … 987 987 // Get VANISHED 988 988 if ($qresync) { 989 $mbox_data = $this->imap-> mailbox_data($mailbox);989 $mbox_data = $this->imap->folder_data($mailbox); 990 990 991 991 // Removed messages … … 1104 1104 { 1105 1105 if (empty($mbox_data)) { 1106 $mbox_data = $this->imap-> mailbox_data($mailbox);1106 $mbox_data = $this->imap->folder_data($mailbox); 1107 1107 } 1108 1108 1109 1109 if ($mbox_data['EXISTS']) { 1110 1110 // fetch sorted sequence numbers 1111 $index = $this->imap-> message_index_direct($mailbox, $sort_field, $sort_order);1111 $index = $this->imap->index_direct($mailbox, $sort_field, $sort_order); 1112 1112 } 1113 1113 else { -
branches/devel-framework/roundcubemail/program/include/rcube_message.php
r5716 r5758 77 77 $this->uid = $uid; 78 78 $this->app = rcmail::get_instance(); 79 $this-> imap = $this->app->imap;80 $this-> imap->get_all_headers = true;81 82 $this->headers = $this-> imap->get_message($uid);79 $this->storage = $this->app->get_storage(); 80 $this->storage->set_options(array('all_headers' => true)); 81 82 $this->headers = $this->storage->get_message($uid); 83 83 84 84 if (!$this->headers) … … 95 95 'prefer_html' => $this->app->config->get('prefer_html'), 96 96 'get_url' => rcmail_url('get', array( 97 '_mbox' => $this-> imap->get_mailbox_name(), '_uid' => $uid))97 '_mbox' => $this->storage->get_folder(), '_uid' => $uid)) 98 98 ); 99 99 … … 103 103 } 104 104 else { 105 $this->body = $this-> imap->get_body($uid);105 $this->body = $this->storage->get_body($uid); 106 106 } 107 107 … … 177 177 } 178 178 // get from IMAP 179 return $this-> imap->get_message_part($this->uid, $mime_id, $part, NULL, $fp);179 return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp); 180 180 } else 181 181 return null; … … 212 212 $mimetype = strtolower($part->ctype_primary . '/' . $part->ctype_secondary); 213 213 if ($mimetype == 'text/html') { 214 return $this-> imap->get_message_part($this->uid, $mime_id, $part);214 return $this->storage->get_message_part($this->uid, $mime_id, $part); 215 215 } 216 216 } … … 235 235 236 236 if ($mimetype == 'text/plain') { 237 return $this-> imap->get_message_part($this->uid, $mime_id, $part);237 return $this->storage->get_message_part($this->uid, $mime_id, $part); 238 238 } 239 239 else if ($mimetype == 'text/html') { 240 $out = $this-> imap->get_message_part($this->uid, $mime_id, $part);240 $out = $this->storage->get_message_part($this->uid, $mime_id, $part); 241 241 242 242 // remove special chars encoding … … 591 591 // @TODO: attachment may be huge, hadle it via file 592 592 if (!isset($part->body)) 593 $part->body = $this-> imap->get_message_part($this->uid, $part->mime_id, $part);593 $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part); 594 594 595 595 $parts = array(); … … 627 627 // @TODO: messages may be huge, hadle body via file 628 628 if (!isset($part->body)) 629 $part->body = $this-> imap->get_message_part($this->uid, $part->mime_id, $part);629 $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part); 630 630 631 631 $parts = array(); -
branches/devel-framework/roundcubemail/program/include/rcube_template.php
r5647 r5758 805 805 case 'config': 806 806 $value = $this->config[$name]; 807 if (is_array($value) && $value[$_SESSION[' imap_host']]) {808 $value = $value[$_SESSION[' imap_host']];807 if (is_array($value) && $value[$_SESSION['storage_host']]) { 808 $value = $value[$_SESSION['storage_host']]; 809 809 } 810 810 break; -
branches/devel-framework/roundcubemail/program/steps/mail/check_recent.inc
r5563 r5758 20 20 */ 21 21 22 $current = $RCMAIL-> imap->get_mailbox_name();22 $current = $RCMAIL->storage->get_folder(); 23 23 $check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders'); 24 24 25 25 // list of folders to check 26 26 if ($check_all) { 27 $a_mailboxes = $RCMAIL-> imap->list_mailboxes('', '*', 'mail');27 $a_mailboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail'); 28 28 } 29 29 else { … … 38 38 if ($is_current) { 39 39 // Synchronize mailbox cache, handle flag changes 40 $RCMAIL-> imap->mailbox_sync($mbox_name);40 $RCMAIL->storage->folder_sync($mbox_name); 41 41 } 42 42 43 43 // Get mailbox status 44 $status = $RCMAIL-> imap->mailbox_status($mbox_name);44 $status = $RCMAIL->storage->folder_status($mbox_name); 45 45 46 46 if ($status & 1) { … … 59 59 && $_SESSION['search_request'] == $search_request 60 60 ) { 61 $_SESSION['search'] = $RCMAIL-> imap->refresh_search();61 $_SESSION['search'] = $RCMAIL->storage->refresh_search(); 62 62 } 63 63 … … 69 69 continue; 70 70 71 // get overall message count; allow caching because rcube_imap::mailbox_status() did a refresh 72 $all_count = $RCMAIL->imap->messagecount(null, $RCMAIL->imap->threading ? 'THREADS' : 'ALL'); 71 // get overall message count; allow caching because rcube_storage::folder_status() did a refresh 72 $all_count = $RCMAIL->storage->count(null, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); 73 74 $page = $RCMAIL->storage->get_page(); 75 $page_size = $RCMAIL->storage->get_pagesize(); 73 76 74 77 // check current page if we're not on the first page 75 if ($all_count && $ RCMAIL->imap->list_page > 1) {76 $remaining = $all_count - $ RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1);78 if ($all_count && $page > 1) { 79 $remaining = $all_count - $page_size * ($page - 1); 77 80 if ($remaining <= 0) { 78 $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1); 79 $_SESSION['page'] = $RCMAIL->imap->list_page; 81 $page -= 1; 82 $RCMAIL->storage->set_page($page); 83 $_SESSION['page'] = $page; 80 84 } 81 85 } 82 86 83 87 $OUTPUT->set_env('messagecount', $all_count); 84 $OUTPUT->set_env('pagecount', ceil($all_count/$ RCMAIL->imap->page_size));88 $OUTPUT->set_env('pagecount', ceil($all_count/$page_size)); 85 89 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count), $mbox_name); 86 $OUTPUT->set_env('current_page', $all_count ? $ RCMAIL->imap->list_page : 1);90 $OUTPUT->set_env('current_page', $all_count ? $page : 1); 87 91 88 92 // remove old rows (and clear selection if new list is empty) … … 90 94 91 95 if ($all_count) { 92 $a_headers = $RCMAIL-> imap->list_headers($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']);96 $a_headers = $RCMAIL->storage->list_messages($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']); 93 97 // add message rows 94 98 rcmail_js_message_list($a_headers, false); -
branches/devel-framework/roundcubemail/program/steps/mail/compose.inc
r5723 r5758 57 57 'id' => $COMPOSE_ID, 58 58 'param' => request2param(RCUBE_INPUT_GET), 59 'mailbox' => $RCMAIL-> imap->get_mailbox_name(),59 'mailbox' => $RCMAIL->storage->get_folder(), 60 60 ); 61 61 $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID]; … … 135 135 } 136 136 // set current mailbox in client environment 137 $OUTPUT->set_env('mailbox', $RCMAIL-> imap->get_mailbox_name());137 $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); 138 138 $OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false)); 139 139 $OUTPUT->set_env('top_posting', $RCMAIL->config->get('top_posting', false)); … … 148 148 // get reference message and set compose mode 149 149 if ($msg_uid = $COMPOSE['param']['draft_uid']) { 150 $RCMAIL-> imap->set_mailbox($CONFIG['drafts_mbox']);150 $RCMAIL->storage->set_folder($CONFIG['drafts_mbox']); 151 151 $compose_mode = RCUBE_COMPOSE_DRAFT; 152 152 } … … 180 180 // make sure message is marked as read 181 181 if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN'])) 182 $RCMAIL-> imap->set_flag($msg_uid, 'SEEN');182 $RCMAIL->storage->set_flag($msg_uid, 'SEEN'); 183 183 184 184 if (!empty($MESSAGE->headers->charset)) 185 $RCMAIL-> imap->set_charset($MESSAGE->headers->charset);185 $RCMAIL->storage->set_charset($MESSAGE->headers->charset); 186 186 187 187 if ($compose_mode == RCUBE_COMPOSE_REPLY) … … 1052 1052 $path = tempnam($temp_dir, 'rcmAttmnt'); 1053 1053 if ($fp = fopen($path, 'w')) { 1054 $RCMAIL-> imap->get_raw_body($message->uid, $fp);1054 $RCMAIL->storage->get_raw_body($message->uid, $fp); 1055 1055 fclose($fp); 1056 1056 } else 1057 1057 return false; 1058 1058 } else { 1059 $data = $RCMAIL-> imap->get_raw_body($message->uid);1059 $data = $RCMAIL->storage->get_raw_body($message->uid); 1060 1060 } 1061 1061 … … 1429 1429 global $RCMAIL; 1430 1430 1431 if ($RCMAIL-> imap->mailbox_exists($folder, true)) {1431 if ($RCMAIL->storage->folder_exists($folder, true)) { 1432 1432 return true; 1433 1433 } … … 1435 1435 // folder may exist but isn't subscribed (#1485241) 1436 1436 if ($create) { 1437 if (!$RCMAIL-> imap->mailbox_exists($folder))1438 return $RCMAIL-> imap->create_mailbox($folder, true);1437 if (!$RCMAIL->storage->folder_exists($folder)) 1438 return $RCMAIL->storage->create_folder($folder, true); 1439 1439 else 1440 return $RCMAIL-> imap->subscribe($folder);1440 return $RCMAIL->storage->subscribe($folder); 1441 1441 } 1442 1442 -
branches/devel-framework/roundcubemail/program/steps/mail/copy.inc
r5563 r5758 30 30 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true); 31 31 32 $copied = $RCMAIL-> imap->copy_message($uids, $target, $mbox);32 $copied = $RCMAIL->storage->copy_message($uids, $target, $mbox); 33 33 34 34 if (!$copied) { -
branches/devel-framework/roundcubemail/program/steps/mail/folders.inc
r5563 r5758 28 28 if ($RCMAIL->action == 'expunge') { 29 29 30 $success = $RCMAIL-> imap->expunge($mbox);30 $success = $RCMAIL->storage->expunge_folder($mbox); 31 31 32 32 // reload message list if current mailbox … … 49 49 else if ($RCMAIL->action == 'purge') 50 50 { 51 $delimiter = $RCMAIL-> imap->get_hierarchy_delimiter();51 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 52 52 $trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/'; 53 53 $junk_regexp = '/^' . preg_quote($CONFIG['junk_mbox'] . $delimiter, '/') . '/'; … … 57 57 || preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox) 58 58 ) { 59 $success = $RCMAIL-> imap->clear_mailbox($mbox);59 $success = $RCMAIL->storage->clear_folder($mbox); 60 60 61 61 if ($success) { -
branches/devel-framework/roundcubemail/program/steps/mail/func.inc
r5745 r5758 30 30 31 31 // actions that do not require imap connection here 32 $NO IMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get');32 $NOSTORAGE_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get'); 33 33 34 34 // always instantiate imap object (but not yet connect to server) 35 $RCMAIL-> imap_init();35 $RCMAIL->storage_init(); 36 36 37 37 // log in to imap server 38 if (!in_array($RCMAIL->action, $NO IMAP_ACTIONS) && !$RCMAIL->imap_connect()) {38 if (!in_array($RCMAIL->action, $NOSTORAGE_ACTIONS) && !$RCMAIL->storage_connect()) { 39 39 $RCMAIL->kill_session(); 40 40 … … 48 48 // set imap properties and session vars 49 49 if (strlen(trim($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC, true)))) 50 $RCMAIL-> imap->set_mailbox(($_SESSION['mbox'] = $mbox));51 else if ($RCMAIL-> imap)52 $_SESSION['mbox'] = $RCMAIL-> imap->get_mailbox_name();50 $RCMAIL->storage->set_folder(($_SESSION['mbox'] = $mbox)); 51 else if ($RCMAIL->storage) 52 $_SESSION['mbox'] = $RCMAIL->storage->get_folder(); 53 53 54 54 if (!empty($_GET['_page'])) 55 $RCMAIL-> imap->set_page(($_SESSION['page'] = intval($_GET['_page'])));55 $RCMAIL->storage->set_page(($_SESSION['page'] = intval($_GET['_page']))); 56 56 57 57 // set default sort col/order to session … … 70 70 $RCMAIL->user->save_prefs(array('message_threading' => $a_threading)); 71 71 } 72 $RCMAIL-> imap->set_threading($a_threading[$_SESSION['mbox']]);72 $RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]); 73 73 74 74 // set message set for search result … … 76 76 && $_SESSION['search_request'] == $_REQUEST['_search'] 77 77 ) { 78 $RCMAIL-> imap->set_search_set($_SESSION['search']);78 $RCMAIL->storage->set_search_set($_SESSION['search']); 79 79 $OUTPUT->set_env('search_request', $_REQUEST['_search']); 80 80 $OUTPUT->set_env('search_text', $_SESSION['last_text_search']); … … 83 83 // set main env variables, labels and page title 84 84 if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { 85 $mbox_name = $RCMAIL-> imap->get_mailbox_name();85 $mbox_name = $RCMAIL->storage->get_folder(); 86 86 87 87 if (empty($RCMAIL->action)) { … … 90 90 $search_request = md5($mbox_name.$_SESSION['search_filter']); 91 91 92 $RCMAIL-> imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $_SESSION['sort_col']);93 $_SESSION['search'] = $RCMAIL-> imap->get_search_set();92 $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $_SESSION['sort_col']); 93 $_SESSION['search'] = $RCMAIL->storage->get_search_set(); 94 94 $_SESSION['search_request'] = $search_request; 95 95 $OUTPUT->set_env('search_request', $search_request); … … 100 100 } 101 101 102 $threading = (bool) $RCMAIL->storage->get_threading(); 103 102 104 // set current mailbox and some other vars in client environment 103 105 $OUTPUT->set_env('mailbox', $mbox_name); 104 $OUTPUT->set_env('pagesize', $RCMAIL-> imap->page_size);105 $OUTPUT->set_env('quota', $RCMAIL-> imap->get_capability('QUOTA'));106 $OUTPUT->set_env('delimiter', $RCMAIL-> imap->get_hierarchy_delimiter());107 $OUTPUT->set_env('threading', (bool) $RCMAIL->imap->threading);108 $OUTPUT->set_env('threads', $ RCMAIL->imap->threading || $RCMAIL->imap->get_capability('THREAD'));106 $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize()); 107 $OUTPUT->set_env('quota', $RCMAIL->storage->get_capability('QUOTA')); 108 $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter()); 109 $OUTPUT->set_env('threading', $threading); 110 $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD')); 109 111 $OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0)); 110 112 … … 131 133 'copy', 'move', 'quota'); 132 134 133 $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL-> imap->mod_mailbox($mbox_name)));135 $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->storage->mod_folder($mbox_name))); 134 136 } 135 137 … … 162 164 $_SESSION['list_attrib'] = $attrib; 163 165 164 $mbox = $RCMAIL-> imap->get_mailbox_name();165 $delim = $RCMAIL-> imap->get_hierarchy_delimiter();166 $mbox = $RCMAIL->storage->get_folder(); 167 $delim = $RCMAIL->storage->get_hierarchy_delimiter(); 166 168 167 169 // show 'to' instead of 'from' in sent/draft messages … … 219 221 } 220 222 221 $mbox = $RCMAIL-> imap->get_mailbox_name();222 $delim = $RCMAIL-> imap->get_hierarchy_delimiter();223 $mbox = $RCMAIL->storage->get_folder(); 224 $delim = $RCMAIL->storage->get_hierarchy_delimiter(); 223 225 224 226 // make sure 'threads' and 'subject' columns are present … … 318 320 } 319 321 320 if ($RCMAIL-> imap->threading) {322 if ($RCMAIL->storage->get_threading()) { 321 323 $OUTPUT->command('init_threads', (array) $roots, $mbox); 322 324 } … … 431 433 global $RCMAIL; 432 434 433 if ($page===NULL) 434 $page = $RCMAIL->imap->list_page; 435 436 $start_msg = ($page-1) * $RCMAIL->imap->page_size + 1; 435 if ($page === NULL) { 436 $page = $RCMAIL->storage->get_page(); 437 } 438 439 $page_size = $RCMAIL->storage->get_pagesize(); 440 $start_msg = ($page-1) * $page_size + 1; 437 441 438 442 if ($count!==NULL) 439 443 $max = $count; 440 444 else if ($RCMAIL->action) 441 $max = $RCMAIL-> imap->messagecount(NULL, $RCMAIL->imap->threading? 'THREADS' : 'ALL');445 $max = $RCMAIL->storage->count(NULL, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); 442 446 443 447 if ($max==0) 444 448 $out = rcube_label('mailboxempty'); 445 449 else 446 $out = rcube_label(array('name' => $RCMAIL-> imap->threading? 'threadsfromto' : 'messagesfromto',450 $out = rcube_label(array('name' => $RCMAIL->storage->get_threading() ? 'threadsfromto' : 'messagesfromto', 447 451 'vars' => array('from' => $start_msg, 448 'to' => min($max, $start_msg + $ RCMAIL->imap->page_size - 1),452 'to' => min($max, $start_msg + $page_size - 1), 449 453 'count' => $max))); 450 454 … … 469 473 { 470 474 global $RCMAIL; 471 return rcmail_localize_foldername($RCMAIL-> imap->get_mailbox_name());475 return rcmail_localize_foldername($RCMAIL->storage->get_folder()); 472 476 } 473 477 … … 480 484 481 485 if ($count === null) 482 $unseen = $RCMAIL-> imap->messagecount($mbox_name, 'UNSEEN', $force);486 $unseen = $RCMAIL->storage->count($mbox_name, 'UNSEEN', $force); 483 487 else 484 488 $unseen = $count; … … 591 595 $html = preg_replace_callback('/(<[\/]*)([^\s>]+)/', 'rcmail_html_tag_callback', $html); 592 596 593 // charset was converted to UTF-8 in rcube_ imap::get_message_part(),597 // charset was converted to UTF-8 in rcube_storage::get_message_part(), 594 598 // change/add charset specification in HTML accordingly, 595 599 // washtml cannot work without that … … 1011 1015 $out .= html::span('part-notice', rcube_label('messagetoobig'). ' ' 1012 1016 . html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part='.$part->mime_id 1013 .'&_mbox='. urlencode($RCMAIL-> imap->get_mailbox_name()), rcube_label('download')));1017 .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download'))); 1014 1018 continue; 1015 1019 } … … 1057 1061 $out .= html::span('part-notice', rcube_label('messagetoobig'). ' ' 1058 1062 . html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part=0' 1059 .'&_mbox='. urlencode($RCMAIL-> imap->get_mailbox_name()), rcube_label('download')));1063 .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download'))); 1060 1064 } 1061 1065 else { … … 1478 1482 1479 1483 if ($message->headers->mdn_to && empty($message->headers->flags['MDNSENT']) && 1480 ($RCMAIL-> imap->check_permflag('MDNSENT') || $RCMAIL->imap->check_permflag('*')))1484 ($RCMAIL->storage->check_permflag('MDNSENT') || $RCMAIL->storage->check_permflag('*'))) 1481 1485 { 1482 1486 $identity = $RCMAIL->user->get_identity(); … … 1534 1538 if ($sent) 1535 1539 { 1536 $RCMAIL-> imap->set_flag($message->uid, 'MDNSENT');1540 $RCMAIL->storage->set_flag($message->uid, 'MDNSENT'); 1537 1541 return true; 1538 1542 } … … 1597 1601 // Set env variables for messageerror.html template 1598 1602 if ($RCMAIL->action == 'show') { 1599 $mbox_name = $RCMAIL-> imap->get_mailbox_name();1603 $mbox_name = $RCMAIL->storage->get_folder(); 1600 1604 $RCMAIL->output->set_env('mailbox', $mbox_name); 1601 1605 $RCMAIL->output->set_env('uid', null); -
branches/devel-framework/roundcubemail/program/steps/mail/get.inc
r5633 r5758 37 37 38 38 // Now we need IMAP connection 39 if (!$RCMAIL-> imap_connect()) {39 if (!$RCMAIL->storage_connect()) { 40 40 // Get action is often executed simultanously. 41 41 // Some servers have MAXPERIP or other limits. … … 118 118 $out = '<body>' . rcube_label('messagetoobig'). ' ' 119 119 . html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part='.$part->mime_id 120 .'&_mbox='. urlencode($RCMAIL-> imap->get_mailbox_name()), rcube_label('download')) . '</body></html>';120 .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download')) . '</body></html>'; 121 121 } 122 122 else { … … 158 158 stream_filter_register('rcube_content', 'rcube_content_filter') or die('Failed to register content filter'); 159 159 stream_filter_append($stdout, 'rcube_content'); 160 $RCMAIL-> imap->get_message_part($MESSAGE->uid, $part->mime_id, $part, false, $stdout);160 $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, false, $stdout); 161 161 } 162 162 } … … 166 166 echo $part->body; 167 167 else if ($part->size) 168 $RCMAIL-> imap->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);168 $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true); 169 169 } 170 170 } -
branches/devel-framework/roundcubemail/program/steps/mail/getunread.inc
r5563 r5758 20 20 */ 21 21 22 $a_folders = $RCMAIL-> imap->list_mailboxes('', '*', 'mail');22 $a_folders = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail'); 23 23 24 24 if (!empty($a_folders)) 25 25 { 26 $current = $RCMAIL-> imap->get_mailbox_name();26 $current = $RCMAIL->storage->get_folder(); 27 27 $inbox = ($current == 'INBOX'); 28 28 $check_all = (bool)$RCMAIL->config->get('check_all_folders'); … … 34 34 $unseen = $unseen_old; 35 35 else 36 $unseen = $RCMAIL-> imap->messagecount($mbox_row, 'UNSEEN', $unseen_old === null);36 $unseen = $RCMAIL->storage->count($mbox_row, 'UNSEEN', $unseen_old === null); 37 37 38 38 if ($unseen || $unseen_old === null) { -
branches/devel-framework/roundcubemail/program/steps/mail/headers.inc
r5563 r5758 21 21 if ($uid = get_input_value('_uid', RCUBE_INPUT_POST)) 22 22 { 23 $source = $RCMAIL-> imap->get_raw_headers($uid);23 $source = $RCMAIL->storage->get_raw_headers($uid); 24 24 25 25 if ($source !== false) { -
branches/devel-framework/roundcubemail/program/steps/mail/list.inc
r5563 r5758 52 52 $RCMAIL->user->save_prefs($save_arr); 53 53 54 $mbox_name = $RCMAIL->imap->get_mailbox_name(); 54 $mbox_name = $RCMAIL->storage->get_folder(); 55 $threading = (bool) $RCMAIL->storage->get_threading(); 55 56 56 57 // Synchronize mailbox cache, handle flag changes 57 $RCMAIL-> imap->mailbox_sync($mbox_name);58 $RCMAIL->storage->folder_sync($mbox_name); 58 59 59 60 // initialize searching result if search_filter is used … … 61 62 { 62 63 $search_request = md5($mbox_name.$_SESSION['search_filter']); 63 $RCMAIL-> imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);64 $_SESSION['search'] = $RCMAIL-> imap->get_search_set();64 $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col); 65 $_SESSION['search'] = $RCMAIL->storage->get_search_set(); 65 66 $_SESSION['search_request'] = $search_request; 66 67 $OUTPUT->set_env('search_request', $search_request); … … 68 69 69 70 // fetch message headers 70 if ($count = $RCMAIL-> imap->messagecount($mbox_name, $RCMAIL->imap->threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh'])))71 $a_headers = $RCMAIL-> imap->list_headers($mbox_name, NULL, $sort_col, $sort_order);71 if ($count = $RCMAIL->storage->count($mbox_name, $threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh']))) 72 $a_headers = $RCMAIL->storage->list_messages($mbox_name, NULL, $sort_col, $sort_order); 72 73 73 74 // update search set (possible change of threading mode) … … 75 76 && $_SESSION['search_request'] == $_REQUEST['_search'] 76 77 ) { 77 $_SESSION['search'] = $RCMAIL-> imap->get_search_set();78 $_SESSION['search'] = $RCMAIL->storage->get_search_set(); 78 79 } 79 80 // remove old search data … … 92 93 93 94 // update message count display 94 $pages = ceil($count/$RCMAIL-> imap->page_size);95 $pages = ceil($count/$RCMAIL->storage->get_pagesize()); 95 96 $OUTPUT->set_env('messagecount', $count); 96 97 $OUTPUT->set_env('pagecount', $pages); 97 $OUTPUT->set_env('threading', (bool) $RCMAIL->imap->threading);98 $OUTPUT->set_env('current_page', $count ? $RCMAIL-> imap->list_page: 1);98 $OUTPUT->set_env('threading', $threading); 99 $OUTPUT->set_env('current_page', $count ? $RCMAIL->storage->get_page() : 1); 99 100 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name); 100 101 $OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text()); … … 109 110 else { 110 111 // handle IMAP errors (e.g. #1486905) 111 if ($err_code = $RCMAIL-> imap->get_error_code()) {112 if ($err_code = $RCMAIL->storage->get_error_code()) { 112 113 rcmail_display_server_error(); 113 114 } -
branches/devel-framework/roundcubemail/program/steps/mail/mark.inc
r5563 r5758 31 31 'unflagged' => 'UNFLAGGED'); 32 32 33 $threading = (bool) $RCMAIL->storage->get_threading(); 34 33 35 if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST))) 34 36 { … … 37 39 if ($flag == 'DELETED' && $CONFIG['skip_deleted'] && $_POST['_from'] != 'show') { 38 40 // count messages before changing anything 39 $old_count = $RCMAIL-> imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');40 $old_pages = ceil($old_count / $RCMAIL-> imap->page_size);41 $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL'); 42 $old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize()); 41 43 $count = sizeof(explode(',', $uids)); 42 44 } 43 45 44 $marked = $RCMAIL-> imap->set_flag($uids, $flag);46 $marked = $RCMAIL->storage->set_flag($uids, $flag); 45 47 46 48 if (!$marked) { … … 58 60 if ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) { 59 61 $ruids = get_input_value('_ruid', RCUBE_INPUT_POST); 60 $read = $RCMAIL-> imap->set_flag($ruids, 'SEEN');62 $read = $RCMAIL->storage->set_flag($ruids, 'SEEN'); 61 63 62 64 if ($read && !$CONFIG['skip_deleted']) … … 65 67 66 68 if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) { 67 rcmail_send_unread_count($RCMAIL-> imap->get_mailbox_name());69 rcmail_send_unread_count($RCMAIL->storage->get_folder()); 68 70 } 69 71 else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) { … … 74 76 $OUTPUT->command('command', 'list'); 75 77 } else { 78 $search_request = get_input_value('_search', RCUBE_INPUT_GPC); 76 79 // refresh saved search set after moving some messages 77 if ( ($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $RCMAIL->imap->search_set) {78 $_SESSION['search'] = $RCMAIL-> imap->refresh_search();80 if ($search_request && $RCMAIL->storage->get_search_set()) { 81 $_SESSION['search'] = $RCMAIL->storage->refresh_search(); 79 82 } 80 83 81 $msg_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL'); 82 $pages = ceil($msg_count / $RCMAIL->imap->page_size); 83 $nextpage_count = $old_count - $RCMAIL->imap->page_size * $RCMAIL->imap->list_page; 84 $remaining = $msg_count - $RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1); 84 $msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL'); 85 $page_size = $RCMAIL->storage->get_pagesize(); 86 $page = $RCMAIL->storage->get_page(); 87 $pages = ceil($msg_count / $page_size); 88 $nextpage_count = $old_count - $page_size * $page; 89 $remaining = $msg_count - $page_size * ($page - 1); 85 90 86 91 // jump back one page (user removed the whole last page) 87 if ($RCMAIL->imap->list_page > 1 && $remaining == 0) { 88 $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1); 89 $_SESSION['page'] = $RCMAIL->imap->list_page; 92 if ($page > 1 && $remaining == 0) { 93 $page -= 1; 94 $RCMAIL->storage->set_page($page); 95 $_SESSION['page'] = $page; 90 96 $jump_back = true; 91 97 } … … 93 99 // update message count display 94 100 $OUTPUT->set_env('messagecount', $msg_count); 95 $OUTPUT->set_env('current_page', $ RCMAIL->imap->list_page);101 $OUTPUT->set_env('current_page', $page); 96 102 $OUTPUT->set_env('pagecount', $pages); 97 103 98 104 // update mailboxlist 99 $mbox = $RCMAIL-> imap->get_mailbox_name();100 $unseen_count = $msg_count ? $RCMAIL-> imap->messagecount($mbox, 'UNSEEN') : 0;105 $mbox = $RCMAIL->storage->get_folder(); 106 $unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0; 101 107 $old_unseen = rcmail_get_unseen_count($mbox); 102 108 … … 107 113 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox); 108 114 109 if ($ RCMAIL->imap->threading)115 if ($threading) { 110 116 $count = get_input_value('_count', RCUBE_INPUT_POST); 117 } 111 118 112 119 // add new rows from next page (if any) … … 115 122 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 116 123 117 $a_headers = $RCMAIL-> imap->list_headers($mbox, NULL, $sort_col, $sort_order,124 $a_headers = $RCMAIL->storage->list_messages($mbox, NULL, $sort_col, $sort_order, 118 125 $jump_back ? NULL : $count); 119 126 -
branches/devel-framework/roundcubemail/program/steps/mail/move_del.inc
r5563 r5758 25 25 26 26 // count messages before changing anything 27 $old_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL'); 28 $old_pages = ceil($old_count / $RCMAIL->imap->page_size); 27 $threading = (bool) $RCMAIL->storage->get_threading(); 28 $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL'); 29 $old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize()); 29 30 30 31 // move messages … … 34 35 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true); 35 36 36 $moved = $RCMAIL-> imap->move_message($uids, $target, $mbox);37 $moved = $RCMAIL->storage->move_message($uids, $target, $mbox); 37 38 38 39 if (!$moved) { … … 55 56 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true); 56 57 57 $del = $RCMAIL-> imap->delete_message($uids, $mbox);58 $del = $RCMAIL->storage->delete_message($uids, $mbox); 58 59 59 60 if (!$del) { … … 76 77 } 77 78 79 $search_request = get_input_value('_search', RCUBE_INPUT_GPC); 80 78 81 // refresh saved search set after moving some messages 79 if ( ($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $RCMAIL->imap->search_set) {80 $_SESSION['search'] = $RCMAIL-> imap->refresh_search();82 if ($search_request && $RCMAIL->storage->get_search_set()) { 83 $_SESSION['search'] = $RCMAIL->storage->refresh_search(); 81 84 } 82 85 … … 90 93 else 91 94 { 92 $msg_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL'); 93 $pages = ceil($msg_count / $RCMAIL->imap->page_size); 94 $nextpage_count = $old_count - $RCMAIL->imap->page_size * $RCMAIL->imap->list_page; 95 $remaining = $msg_count - $RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1); 95 $msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL'); 96 $page_size = $RCMAIL->storage->get_pagesize(); 97 $page = $RCMAIL->storage->get_page(); 98 $pages = ceil($msg_count / $page_size); 99 $nextpage_count = $old_count - $page_size * $page; 100 $remaining = $msg_count - $page_size * ($page - 1); 96 101 97 102 // jump back one page (user removed the whole last page) 98 if ($RCMAIL->imap->list_page > 1 && $remaining == 0) { 99 $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1); 100 $_SESSION['page'] = $RCMAIL->imap->list_page; 103 if ($page > 1 && $remaining == 0) { 104 $page -= 1; 105 $RCMAIL->storage->set_page($page); 106 $_SESSION['page'] = $page; 101 107 $jump_back = true; 102 108 } … … 104 110 // update message count display 105 111 $OUTPUT->set_env('messagecount', $msg_count); 106 $OUTPUT->set_env('current_page', $ RCMAIL->imap->list_page);112 $OUTPUT->set_env('current_page', $page); 107 113 $OUTPUT->set_env('pagecount', $pages); 108 114 109 115 // update mailboxlist 110 $mbox = $RCMAIL-> imap->get_mailbox_name();111 $unseen_count = $msg_count ? $RCMAIL-> imap->messagecount($mbox, 'UNSEEN') : 0;116 $mbox = $RCMAIL->storage->get_folder(); 117 $unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0; 112 118 $old_unseen = rcmail_get_unseen_count($mbox); 113 119 … … 124 130 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox); 125 131 126 if ($ RCMAIL->imap->threading)132 if ($threading) { 127 133 $count = get_input_value('_count', RCUBE_INPUT_POST); 134 } 128 135 129 136 // add new rows from next page (if any) … … 132 139 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 133 140 134 $a_headers = $RCMAIL-> imap->list_headers($mbox, NULL, $sort_col, $sort_order,141 $a_headers = $RCMAIL->storage->list_messages($mbox, NULL, $sort_col, $sort_order, 135 142 $jump_back ? NULL : $count); 136 143 -
branches/devel-framework/roundcubemail/program/steps/mail/pagenav.inc
r5563 r5758 21 21 22 22 $uid = get_input_value('_uid', RCUBE_INPUT_GET); 23 $index = $RCMAIL-> imap->message_index(null, $_SESSION['sort_col'], $_SESSION['sort_order']);23 $index = $RCMAIL->storage->index(null, $_SESSION['sort_col'], $_SESSION['sort_order']); 24 24 $cnt = $index->countMessages(); 25 25 -
branches/devel-framework/roundcubemail/program/steps/mail/search.inc
r5563 r5758 19 19 20 20 // reset list_page and old search results 21 $RCMAIL-> imap->set_page(1);22 $RCMAIL-> imap->set_search_set(NULL);21 $RCMAIL->storage->set_page(1); 22 $RCMAIL->storage->set_search_set(NULL); 23 23 $_SESSION['page'] = 1; 24 24 … … 108 108 // execute IMAP search 109 109 if ($search_str) 110 $RCMAIL-> imap->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']);110 $RCMAIL->storage->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']); 111 111 112 112 // save search results in session … … 115 115 116 116 if ($search_str) { 117 $_SESSION['search'] = $RCMAIL-> imap->get_search_set();117 $_SESSION['search'] = $RCMAIL->storage->get_search_set(); 118 118 $_SESSION['last_text_search'] = $str; 119 119 } … … 122 122 123 123 // Get the headers 124 $result_h = $RCMAIL-> imap->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);125 $count = $RCMAIL-> imap->messagecount($mbox, $RCMAIL->imap->threading? 'THREADS' : 'ALL');124 $result_h = $RCMAIL->storage->list_messages($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']); 125 $count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); 126 126 127 127 … … 130 130 rcmail_js_message_list($result_h); 131 131 if ($search_str) 132 $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL-> imap->messagecount(NULL, 'ALL')));132 $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL'))); 133 133 } 134 134 // handle IMAP errors (e.g. #1486905) 135 else if ($err_code = $RCMAIL-> imap->get_error_code()) {135 else if ($err_code = $RCMAIL->storage->get_error_code()) { 136 136 rcmail_display_server_error(); 137 137 } … … 143 143 $OUTPUT->set_env('search_request', $search_str ? $search_request : ''); 144 144 $OUTPUT->set_env('messagecount', $count); 145 $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL-> imap->page_size));145 $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize())); 146 146 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1), $mbox); 147 147 $OUTPUT->send(); 148 149 -
branches/devel-framework/roundcubemail/program/steps/mail/sendmail.inc
r5716 r5758 635 635 // set replied/forwarded flag 636 636 if ($COMPOSE['reply_uid']) 637 $RCMAIL-> imap->set_flag($COMPOSE['reply_uid'], 'ANSWERED', $COMPOSE['mailbox']);637 $RCMAIL->storage->set_flag($COMPOSE['reply_uid'], 'ANSWERED', $COMPOSE['mailbox']); 638 638 else if ($COMPOSE['forward_uid']) 639 $RCMAIL-> imap->set_flag($COMPOSE['forward_uid'], 'FORWARDED', $COMPOSE['mailbox']);639 $RCMAIL->storage->set_flag($COMPOSE['forward_uid'], 'FORWARDED', $COMPOSE['mailbox']); 640 640 641 641 } // End of SMTP Delivery Block … … 650 650 if ($store_target) { 651 651 // check if folder is subscribed 652 if ($RCMAIL-> imap->mailbox_exists($store_target, true))652 if ($RCMAIL->storage->folder_exists($store_target, true)) 653 653 $store_folder = true; 654 654 // folder may be existing but not subscribed (#1485241) 655 else if (!$RCMAIL-> imap->mailbox_exists($store_target))656 $store_folder = $RCMAIL-> imap->create_mailbox($store_target, true);657 else if ($RCMAIL-> imap->subscribe($store_target))655 else if (!$RCMAIL->storage->folder_exists($store_target)) 656 $store_folder = $RCMAIL->storage->create_folder($store_target, true); 657 else if ($RCMAIL->storage->subscribe($store_target)) 658 658 $store_folder = true; 659 659 … … 685 685 TRUE, FALSE); 686 686 else { 687 $saved = $RCMAIL-> imap->save_message($store_target, $msg, $headers, $mailbody_file ? true : false);687 $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers, $mailbody_file ? true : false); 688 688 } 689 689 … … 709 709 // delete previous saved draft 710 710 // @TODO: use message UID (remember to check UIDVALIDITY) to skip this SEARCH
