| | |
| | | $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(); |
| | |
| | | $options['rights'] = $acl && !$options['is_root'] ? (array)$this->my_rights($mailbox) : array(); |
| | | $options['special'] = in_array($mailbox, $this->default_folders); |
| | | |
| | | // Set 'noselect' and 'norename' flags |
| | | if (is_array($options['options'])) { |
| | | foreach ($options['options'] as $opt) { |
| | | $opt = strtolower($opt); |
| | |
| | | } |
| | | |
| | | if (!empty($options['rights'])) { |
| | | $options['norename'] = !in_array('x', $options['rights']) && |
| | | (!in_array('c', $options['rights']) || !in_array('d', $options['rights'])); |
| | | $options['norename'] = !in_array('x', $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; |
| | | } |
| | |
| | | $str = self::explode_header_string(',;', $str, true); |
| | | $result = array(); |
| | | |
| | | // simplified regexp, supporting quoted local part |
| | | $email_rx = '(\S+|("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+"))@\S+'; |
| | | |
| | | foreach ($str as $key => $val) { |
| | | $name = ''; |
| | | $address = ''; |
| | | $val = trim($val); |
| | | |
| | | if (preg_match('/(.*)<(\S+@\S+)>$/', $val, $m)) { |
| | | if (preg_match('/(.*)<('.$email_rx.')>$/', $val, $m)) { |
| | | $address = $m[2]; |
| | | $name = trim($m[1]); |
| | | } |
| | | else if (preg_match('/^(\S+@\S+)$/', $val, $m)) { |
| | | else if (preg_match('/^('.$email_rx.')$/', $val, $m)) { |
| | | $address = $m[1]; |
| | | $name = ''; |
| | | } |
| | |
| | | |
| | | // dequote and/or decode name |
| | | if ($name) { |
| | | if ($name[0] == '"') { |
| | | if ($name[0] == '"' && $name[strlen($name)-1] == '"') { |
| | | $name = substr($name, 1, -1); |
| | | $name = stripslashes($name); |
| | | } |