Fix new storage object usage (fixes e.g. special folders selectors)

This commit is contained in:
Aleksander Machniak 2012-03-08 20:42:32 +01:00
parent 2948cee6c1
commit 10dad0d289

View file

@ -94,6 +94,9 @@ class kolab_folders extends rcube_plugin
// Get folders list // Get folders list
if ($args['mode'] == 'LIST') { if ($args['mode'] == 'LIST') {
if (!$storage->check_connection()) {
return $args;
}
$args['folders'] = $storage->conn->listMailboxes($args['root'], $args['name']); $args['folders'] = $storage->conn->listMailboxes($args['root'], $args['name']);
} }
else { else {
@ -405,18 +408,22 @@ class kolab_folders extends rcube_plugin
{ {
$storage = $this->rc->get_storage(); $storage = $this->rc->get_storage();
if (!$storage->check_connection()) {
return null;
}
// Code copied from rcube_imap::_list_mailboxes() // Code copied from rcube_imap::_list_mailboxes()
// Server supports LIST-EXTENDED, we can use selection options // Server supports LIST-EXTENDED, we can use selection options
// #1486225: Some dovecot versions returns wrong result using LIST-EXTENDED // #1486225: Some dovecot versions returns wrong result using LIST-EXTENDED
if (!$this->rc->config->get('imap_force_lsub') && $storage->get_capability('LIST-EXTENDED')) { if (!$this->rc->config->get('imap_force_lsub') && $imap->get_capability('LIST-EXTENDED')) {
// This will also set mailbox options, LSUB doesn't do that // This will also set mailbox options, LSUB doesn't do that
$a_folders = $storage->conn->listMailboxes($root, $name, $a_folders = $storage->conn->listMailboxes($root, $name,
NULL, array('SUBSCRIBED')); NULL, array('SUBSCRIBED'));
// remove non-existent folders // remove non-existent folders
if (is_array($a_folders) && $name = '*') { if (is_array($a_folders) && $name = '*' && !empty($storage->conn->data['LIST'])) {
foreach ($a_folders as $idx => $folder) { foreach ($a_folders as $idx => $folder) {
if ($storage->conn->data['LIST'] && ($opts = $storage->conn->data['LIST'][$folder]) if (($opts = $storage->conn->data['LIST'][$folder])
&& in_array('\\NonExistent', $opts) && in_array('\\NonExistent', $opts)
) { ) {
$storage->conn->unsubscribe($folder); $storage->conn->unsubscribe($folder);
@ -430,10 +437,10 @@ class kolab_folders extends rcube_plugin
$a_folders = $storage->conn->listSubscribed($root, $name); $a_folders = $storage->conn->listSubscribed($root, $name);
// unsubscribe non-existent folders, remove from the list // unsubscribe non-existent folders, remove from the list
if (is_array($a_folders) && $name == '*') { if (is_array($a_folders) && $name == '*' && !empty($storage->conn->data['LIST'])) {
foreach ($a_folders as $idx => $folder) { foreach ($a_folders as $idx => $folder) {
if ($storage->conn->data['LIST'] && ($opts = $storage->conn->data['LIST'][$folder]) if (!isset($storage->conn->data['LIST'][$folder])
&& in_array('\\Noselect', $opts) || in_array('\\Noselect', $storage->conn->data['LIST'][$folder])
) { ) {
// Some servers returns \Noselect for existing folders // Some servers returns \Noselect for existing folders
if (!$storage->folder_exists($folder)) { if (!$storage->folder_exists($folder)) {