| | |
| | | var $search_sort_field = ''; |
| | | var $debug_level = 1; |
| | | var $error_code = 0; |
| | | var $options = array('imap' => 'check'); |
| | | |
| | | |
| | | /** |
| | |
| | | * @return boolean TRUE on success, FALSE on failure |
| | | * @access public |
| | | */ |
| | | function connect($host, $user, $pass, $port=143, $use_ssl=null, $auth_type=null) |
| | | function connect($host, $user, $pass, $port=143, $use_ssl=null) |
| | | { |
| | | global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE; |
| | | |
| | |
| | | $ICL_PORT = $port; |
| | | $IMAP_USE_INTERNAL_DATE = false; |
| | | |
| | | $this->conn = iil_Connect($host, $user, $pass, array('imap' => $auth_type ? $auth_type : 'check')); |
| | | $this->conn = iil_Connect($host, $user, $pass, $this->options); |
| | | $this->host = $host; |
| | | $this->user = $user; |
| | | $this->pass = $pass; |
| | |
| | | iil_C_Select($this->conn, $this->mailbox); |
| | | } |
| | | |
| | | /** |
| | | * Set options to be used in iil_Connect() |
| | | */ |
| | | function set_options($opt) |
| | | { |
| | | $this->options = array_merge((array)$opt, $this->options); |
| | | } |
| | | |
| | | /** |
| | | * Set a root folder for the IMAP connection. |
| | |
| | | $root = substr($root, 0, -1); |
| | | |
| | | $this->root_dir = $root; |
| | | $this->options['rootdir'] = $root; |
| | | |
| | | if (empty($this->delimiter)) |
| | | $this->get_hierarchy_delimiter(); |
| | |
| | | // we have a saved search result. get index from there |
| | | if (!isset($this->cache[$key]) && $this->search_string && $mailbox == $this->mailbox) |
| | | { |
| | | $this->cache[$key] = $a_msg_headers = array(); |
| | | $this->cache[$key] = array(); |
| | | |
| | | if ($this->get_capability('sort')) |
| | | { |
| | |
| | | else if ($this->sort_order=="DESC") |
| | | arsort($a_index); |
| | | |
| | | $this->cache[$key] = $a_index; |
| | | $this->cache[$key] = array_keys($a_index); |
| | | } |
| | | } |
| | | |
| | |
| | | if ($cache_status>0) |
| | | { |
| | | $a_index = $this->get_message_cache_index($cache_key, TRUE, $this->sort_field, $this->sort_order); |
| | | return array_values($a_index); |
| | | return array_keys($a_index); |
| | | } |
| | | |
| | | |
| | | // fetch complete message index |
| | | $msg_count = $this->_messagecount($mailbox); |
| | |
| | | else if ($this->sort_order=="DESC") |
| | | arsort($a_index); |
| | | |
| | | $this->cache[$key] = $a_index; |
| | | $this->cache[$key] = array_keys($a_index); |
| | | } |
| | | |
| | | return $this->cache[$key]; |
| | |
| | | $folders[$folder] = rc_strtolower(rcube_charset_convert($folder, 'UTF-7')); |
| | | } |
| | | |
| | | // sort folders and place defaults on the top |
| | | asort($folders, SORT_LOCALE_STRING); |
| | | ksort($a_defaults); |
| | | |
| | | $folders = array_merge($a_defaults, array_keys($folders)); |
| | | |
| | | // finally we must rebuild the list to move |
| | | // subfolders of default folders to their place... |
| | | // ...also do this for the rest of folders because |
| | | // asort() is not properly sorting case sensitive names |
| | | |
| | | // set the type of folder name variable (#1485527) |
| | | while (list($key, $folder) = each($folders)) { |
| | | // set the type of folder name variable (#1485527) |
| | | $a_out[] = (string) $folder; |
| | | unset($folders[$key]); |
| | | foreach ($folders as $idx => $f) { |
| | | if (strpos($f, $folder.$delimiter) === 0) { |
| | | $a_out[] = (string) $f; |
| | | unset($folders[$idx]); |
| | | } |
| | | } |
| | | reset($folders); |
| | | $this->_rsort($folder, $delimiter, $folders, $a_out); |
| | | } |
| | | |
| | | return $a_out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function _rsort($folder, $delimiter, &$list, &$out) |
| | | { |
| | | while (list($key, $name) = each($list)) { |
| | | if (strpos($name, $folder.$delimiter) === 0) { |
| | | // set the type of folder name variable (#1485527) |
| | | $out[] = (string) $name; |
| | | unset($list[$key]); |
| | | $this->_rsort($name, $delimiter, $list, $out); |
| | | } |
| | | } |
| | | reset($list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @access private |
| | | */ |