| | |
| | | */ |
| | | public function check_permflag($flag) |
| | | { |
| | | $flag = strtoupper($flag); |
| | | $imap_flag = $this->conn->flags[$flag]; |
| | | $flag = strtoupper($flag); |
| | | $imap_flag = $this->conn->flags[$flag]; |
| | | $perm_flags = $this->get_permflags($this->folder); |
| | | |
| | | if ($this->folder !== null) { |
| | | $this->check_connection(); |
| | | return in_array_nocase($imap_flag, $perm_flags); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns PERMANENTFLAGS of the specified folder |
| | | * |
| | | * @param string $folder Folder name |
| | | * |
| | | * @return array Flags |
| | | */ |
| | | public function get_permflags($folder) |
| | | { |
| | | if (!strlen($folder)) { |
| | | return array(); |
| | | } |
| | | // @TODO: cache permanent flags (?) |
| | | /* |
| | | Checking PERMANENTFLAGS is rather rare, so we disable caching of it |
| | | Re-think when we'll use it for more than only MDNSENT flag |
| | | |
| | | return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS'])); |
| | | $cache_key = 'mailboxes.permanentflags.' . $folder; |
| | | $permflags = $this->get_cache($cache_key); |
| | | |
| | | if ($permflags !== null) { |
| | | return explode(' ', $permflags); |
| | | } |
| | | */ |
| | | if (!$this->check_connection()) { |
| | | return array(); |
| | | } |
| | | |
| | | if ($this->conn->select($folder)) { |
| | | $permflags = $this->conn->data['PERMANENTFLAGS']; |
| | | } |
| | | else { |
| | | return array(); |
| | | } |
| | | |
| | | if (!is_array($permflags)) { |
| | | $permflags = array(); |
| | | } |
| | | /* |
| | | // Store permflags as string to limit cached object size |
| | | $this->update_cache($cache_key, implode(' ', $permflags)); |
| | | */ |
| | | return $permflags; |
| | | } |
| | | |
| | | |
| | |
| | | $structure[1] = $m[2]; |
| | | } |
| | | else { |
| | | return $headers; |
| | | // Try to parse the message using Mail_mimeDecode package |
| | | // We need a better solution, Mail_mimeDecode parses message |
| | | // in memory, which wouldn't work for very big messages, |
| | | // (it uses up to 10x more memory than the message size) |
| | | // it's also buggy and not actively developed |
| | | if ($headers->size && rcube_utils::mem_check($headers->size * 10)) { |
| | | $raw_msg = $this->get_raw_body($uid); |
| | | $struct = rcube_mime::parse_message($raw_msg); |
| | | } |
| | | else { |
| | | return $headers; |
| | | } |
| | | } |
| | | } |
| | | |
| | | $struct = $this->structure_part($structure, 0, '', $headers); |
| | | if (empty($struct)) { |
| | | $struct = $this->structure_part($structure, 0, '', $headers); |
| | | } |
| | | |
| | | // don't trust given content-type |
| | | if (empty($struct->parts) && !empty($headers->ctype)) { |
| | |
| | | |
| | | // get list of subscribed folders |
| | | if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) { |
| | | $a_subscribed = $this->_list_folders_subscribed('', $folder . $delm . '*'); |
| | | $a_subscribed = $this->list_folders_subscribed('', $folder . $delm . '*'); |
| | | $subscribed = $this->folder_exists($folder, true); |
| | | } |
| | | else { |
| | | $a_subscribed = $this->_list_folders_subscribed(); |
| | | $a_subscribed = $this->list_folders_subscribed(); |
| | | $subscribed = in_array($folder, $a_subscribed); |
| | | } |
| | | |