alecpl
2011-08-18 189a0ae4dcd965c9ea1ed3d203cfd5dd28922046
- Unsubscribe from non-existing folders always (on listing), not only in Settings/Folders UI


2 files modified
30 ■■■■■ changed files
program/include/rcube_imap.php 22 ●●●● patch | view | raw | blame | history
program/steps/settings/folders.inc 8 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.php
@@ -3083,20 +3083,36 @@
                $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]);
                            }
                        }
                    }
                }
            }
        }
program/steps/settings/folders.inc
@@ -278,9 +278,6 @@
        $display_folder = str_repeat('    ', $folder['level'])
            . Q($protected ? rcmail_localize_foldername($folder['id']) : $folder['name']);
        if ($sub_key !== false)
            unset($a_subscribed[$sub_key]);
        if ($folder['virtual']) {
            $classes[] = 'virtual';
        }
@@ -327,11 +324,6 @@
        $a_js_folders['rcmrow'.$idx] = array($folder_utf8,
            Q($display_folder), $protected || $folder['virtual']);
    }
    // Unsubscribe from non-existing folders
    foreach ($a_subscribed as $folder) {
        $IMAP->unsubscribe($folder);
    }
    $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table));