roundcubemail/program/lib/Roundcube/rcube_imap.php
public function get_special_folders($forced = false)
    {
        $result = parent::get_special_folders();
        $rcube  = rcube::get_instance();

        // Lock SPECIAL-USE after user preferences change (#4782)
        if ($rcube->config->get('lock_special_folders')) {
            return $result;
        }

        if (isset($this->icache['special-use'])) {
            return array_merge($result, $this->icache['special-use']);
        }

        if (!$forced || !$this->get_capability('SPECIAL-USE')) {
            return $result;
        }

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

        $types   = array_map(function($value) { return "\\" . ucfirst($value); }, rcube_storage::$folder_types);
        $special = array();

        // request \Subscribed flag in LIST response as performance improvement for folder_exists()
        $folders = $this->conn->listMailboxes('', '*', array('SUBSCRIBED'), array('SPECIAL-USE'));

        if (!empty($folders)) {
            foreach ($folders as $folder) {
                if ($flags = $this->conn->data['LIST'][$folder]) {
                    foreach ($types as $type) {
                        if (in_array($type, $flags)) {
                            $type           = strtolower(substr($type, 1));
                            $special[$type] = $folder;
                        }
                    }
                }
            }
        }

        $this->icache['special-use'] = $special;
        unset($this->icache['special-folders']);

        return array_merge($result, $special);
    }
public function get_special_folders($forced = false)
    {
        $result = parent::get_special_folders();
        $rcube  = rcube::get_instance();

        // Lock SPECIAL-USE after user preferences change (#4782)
        if ($rcube->config->get('lock_special_folders')) {
            return $result;
        }

        if (isset($this->icache['special-use'])) {
            return array_merge($result, $this->icache['special-use']);
        }

        if (!$forced || !$this->get_capability('SPECIAL-USE')) {
            return $result;
        }

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

        $types   = array_map(function($value) { return "\\" . ucfirst($value); }, rcube_storage::$folder_types);
        $special = array();

        // request \Subscribed flag in LIST response as performance improvement for folder_exists()
        $folders = $this->conn->listMailboxes('', '*', array('SUBSCRIBED'), array('SPECIAL-USE'));

        if (!empty($folders)) {
            foreach ($folders as $folder) {
                if ($flags = $this->conn->data['LIST'][$folder]) {
                    foreach ($types as $type) {
                        if (in_array($type, $flags)) {
                            $type           = strtolower(substr($type, 1));
                            $special[$type] = $folder;
                        }
                    }
                }
            }
        }

        $this->icache['special-use'] = $special;
        unset($this->icache['special-folders']);

        return array_merge($result, $special);
    }
public function get_special_folders ( $ forced = false ) { $ result = parent :: get_special_folders ( ) ; $ rcube = rcube :: get_instance ( ) ; // Lock SPECIAL-USE after user preferences change (#4782) if ( $ rcube -> config -> get ( 'lock_special_folders' ) ) { return $ result ; } if ( isset ( $ this -> icache [ 'special-use' ] ) ) { return array_merge ( $ result , $ this -> icache [ 'special-use' ] ) ; } if ( ! $ forced || ! $ this -> get_capability ( 'SPECIAL-USE' ) ) { return $ result ; } if ( ! $ this -> check_connection ( ) ) { return $ result ; } $ types = array_map ( function ( $ value ) { return "\\" . ucfirst ( $ value ) ; } , rcube_storage :: $ folder_types ) ; $ special = array ( ) ; // request \Subscribed flag in LIST response as performance improvement for folder_exists() $ folders = $ this -> conn -> listMailboxes ( '' , '*' , array ( 'SUBSCRIBED' ) , array ( 'SPECIAL-USE' ) ) ; if ( ! empty ( $ folders ) ) { foreach ( $ folders as $ folder ) { if ( $ flags = $ this -> conn -> data [ 'LIST' ] [ $ folder ] ) { foreach ( $ types as $ type ) { if ( in_array ( $ type , $ flags ) ) { $ type = strtolower ( substr ( $ type , 1 ) ) ; $ special [ $ type ] = $ folder ; } } } } } $ this -> icache [ 'special-use' ] = $ special ; unset ( $ this -> icache [ 'special-folders' ] ) ; return array_merge ( $ result , $ special ) ; }
Detect special folder associations stored in storage backend
Detect special folder associations stored in storage backend