| | |
| | | function set_search_set($str=null, $msgs=null, $charset=null, $sort_field=null, $threads=false, $sorted=false) |
| | | { |
| | | if (is_array($str) && $msgs == null) |
| | | list($str, $msgs, $charset, $sort_field, $threads) = $str; |
| | | list($str, $msgs, $charset, $sort_field, $threads, $sorted) = $str; |
| | | if ($msgs === false) |
| | | $msgs = array(); |
| | | else if ($msgs != null && !is_array($msgs)) |
| | |
| | | // use message index sort as default sorting |
| | | if (!$this->sort_field) { |
| | | if ($this->skip_deleted) { |
| | | $a_index = $this->_search_index($mailbox, 'ALL'); |
| | | $a_index = $this->conn->search($mailbox, 'ALL UNDELETED'); |
| | | // I didn't found that SEARCH should return sorted IDs |
| | | if (is_array($a_index)) |
| | | sort($a_index); |
| | | } else if ($max = $this->_messagecount($mailbox)) { |
| | | $a_index = range(1, $max); |
| | | } |
| | |
| | | } |
| | | |
| | | // convert charset (if text or message part) |
| | | if ($body && !$skip_charset_conv && |
| | | preg_match('/^(text|message)$/', $o_part->ctype_primary) |
| | | ) { |
| | | if (!$o_part->charset || strtoupper($o_part->charset) == 'US-ASCII') { |
| | | $o_part->charset = $this->default_charset; |
| | | if ($body && preg_match('/^(text|message)$/', $o_part->ctype_primary)) { |
| | | // Remove NULL characters (#1486189) |
| | | $body = str_replace("\x00", '', $body); |
| | | |
| | | if (!$skip_charset_conv) { |
| | | if (!$o_part->charset || strtoupper($o_part->charset) == 'US-ASCII') { |
| | | $o_part->charset = $this->default_charset; |
| | | } |
| | | $body = rcube_charset_convert($body, $o_part->charset); |
| | | } |
| | | $body = rcube_charset_convert($body, $o_part->charset); |
| | | } |
| | | |
| | | return $body; |
| | |
| | | if (isset($data['folders'])) { |
| | | $a_folders = $data['folders']; |
| | | } |
| | | else if (!$this->conn->connected()) { |
| | | return array(); |
| | | } |
| | | else { |
| | | // Server supports LIST-EXTENDED, we can use selection options |
| | | $config = rcmail::get_instance()->config; |
| | |
| | | $a_folders = $this->conn->listMailboxes($root, $name, |
| | | NULL, array('SUBSCRIBED')); |
| | | |
| | | // remove non-existent folders |
| | | if (is_array($a_folders)) { |
| | | // unsubscribe non-existent folders, remove from the list |
| | | if (is_array($a_folders) && $name == '*') { |
| | | foreach ($a_folders as $idx => $folder) { |
| | | if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder]) |
| | | && in_array('\\NonExistent', $opts) |
| | | ) { |
| | | $this->conn->unsubscribe($folder); |
| | | unset($a_folders[$idx]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // retrieve list of folders from IMAP server using LSUB |
| | | else { |
| | | $a_folders = $this->conn->listSubscribed($root, $name); |
| | | |
| | | // unsubscribe non-existent folders, remove from the list |
| | | if (is_array($a_folders) && $name == '*') { |
| | | foreach ($a_folders as $idx => $folder) { |
| | | if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder]) |
| | | && in_array('\\Noselect', $opts) |
| | | ) { |
| | | // Some servers returns \Noselect for existing folders |
| | | if (!$this->mailbox_exists($folder)) { |
| | | $this->conn->unsubscribe($folder); |
| | | unset($a_folders[$idx]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | function mailbox_info($mailbox) |
| | | { |
| | | if ($this->icache['options'] && $this->icache['options']['name'] == $mailbox) { |
| | | return $this->icache['options']; |
| | | } |
| | | |
| | | $acl = $this->get_capability('ACL'); |
| | | $namespace = $this->get_namespace(); |
| | | $options = array(); |
| | |
| | | } |
| | | |
| | | if (!empty($options['rights'])) { |
| | | $options['norename'] = !in_array('x', $options['rights']); |
| | | $options['norename'] = !in_array('x', $options['rights']) && !in_array('d', $options['rights']); |
| | | |
| | | if (!$options['noselect']) { |
| | | $options['noselect'] = !in_array('r', $options['rights']); |
| | | } |
| | |
| | | else { |
| | | $options['norename'] = $options['is_root'] || $options['namespace'] != 'personal'; |
| | | } |
| | | |
| | | $this->icache['options'] = $options; |
| | | |
| | | return $options; |
| | | } |
| | |
| | | // @TODO: Honor MAXSIZE and DEPTH options |
| | | foreach ($queries as $attrib => $entry) |
| | | if ($result = $this->conn->getAnnotation($mailbox, $entry, $attrib)) |
| | | $res = array_merge($res, $result); |
| | | $res = array_merge_recursive($res, $result); |
| | | |
| | | return $res; |
| | | } |
| | |
| | | /** |
| | | * Enable or disable indexes caching |
| | | * |
| | | * @param boolean $type Cache type (@see rcmail::get_cache) |
| | | * @param string $type Cache type (@see rcmail::get_cache) |
| | | * @access public |
| | | */ |
| | | function set_caching($type) |
| | | { |
| | | if ($type) { |
| | | $this->caching = true; |
| | | $this->caching = $type; |
| | | } |
| | | else { |
| | | if ($this->cache) |
| | |
| | | { |
| | | if ($this->caching && !$this->cache) { |
| | | $rcmail = rcmail::get_instance(); |
| | | $this->cache = $rcmail->get_cache('IMAP', $type); |
| | | $this->cache = $rcmail->get_cache('IMAP', $this->caching); |
| | | } |
| | | |
| | | return $this->cache; |