roundcubemail/program/lib/Roundcube/rcube_imap.php
public function folder_exists($folder, $subscription = false)
    {
        if ($folder == 'INBOX') {
            return true;
        }

        $key = $subscription ? 'subscribed' : 'existing';

        if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
            return true;
        }

        if (!$this->check_connection()) {
            return false;
        }

        if ($subscription) {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder])
                && in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])
            ) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listSubscribed('', $folder);
            }
        }
        else {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listMailboxes('', $folder);
            }
        }

        if (is_array($a_folders) && in_array($folder, $a_folders)) {
            $this->icache[$key][] = $folder;
            return true;
        }

        return false;
    }
public function folder_exists($folder, $subscription = false)
    {
        if ($folder == 'INBOX') {
            return true;
        }

        $key = $subscription ? 'subscribed' : 'existing';

        if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
            return true;
        }

        if (!$this->check_connection()) {
            return false;
        }

        if ($subscription) {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder])
                && in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])
            ) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listSubscribed('', $folder);
            }
        }
        else {
            // It's possible we already called LIST command, check LIST data
            if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
                $a_folders = array($folder);
            }
            else {
                $a_folders = $this->conn->listMailboxes('', $folder);
            }
        }

        if (is_array($a_folders) && in_array($folder, $a_folders)) {
            $this->icache[$key][] = $folder;
            return true;
        }

        return false;
    }
public function folder_exists ( $ folder , $ subscription = false ) { if ( $ folder == 'INBOX' ) { return true ; } $ key = $ subscription ? 'subscribed' : 'existing' ; if ( is_array ( $ this -> icache [ $ key ] ) && in_array ( $ folder , $ this -> icache [ $ key ] ) ) { return true ; } if ( ! $ this -> check_connection ( ) ) { return false ; } if ( $ subscription ) { // It's possible we already called LIST command, check LIST data if ( ! empty ( $ this -> conn -> data [ 'LIST' ] ) && ! empty ( $ this -> conn -> data [ 'LIST' ] [ $ folder ] ) && in_array_nocase ( '\\Subscribed' , $ this -> conn -> data [ 'LIST' ] [ $ folder ] ) ) { $ a_folders = array ( $ folder ) ; } else { $ a_folders = $ this -> conn -> listSubscribed ( '' , $ folder ) ; } } else { // It's possible we already called LIST command, check LIST data if ( ! empty ( $ this -> conn -> data [ 'LIST' ] ) && isset ( $ this -> conn -> data [ 'LIST' ] [ $ folder ] ) ) { $ a_folders = array ( $ folder ) ; } else { $ a_folders = $ this -> conn -> listMailboxes ( '' , $ folder ) ; } } if ( is_array ( $ a_folders ) && in_array ( $ folder , $ a_folders ) ) { $ this -> icache [ $ key ] [ ] = $ folder ; return true ; } return false ; }
Checks if folder exists and is subscribed

@param string   $folder       Folder name
@param boolean  $subscription Enable subscription checking

@return boolean TRUE or FALSE
Checks if folder exists and is subscribed