Changeset 89dcf540 in github


Ignore:
Timestamp:
Nov 15, 2011 3:23:24 AM (18 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
305b366b
Parents:
485c69d
Message:
  • Fix listing of folders in hidden namespaces (#1486796)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r485c69d r89dcf540  
    22=========================== 
    33 
     4- Fix listing of folders in hidden namespaces (#1486796) 
    45- Don't consider \Noselect flag when building folders tree (#1488004) 
    56- Fix sorting autocomplete results (#1488084) 
  • program/include/rcube_imap.php

    r1cb0d64 r89dcf540  
    30053005 
    30063006    /** 
    3007      * Private method for mailbox listing 
     3007     * Private method for mailbox listing (LSUB) 
    30083008     * 
    30093009     * @param   string  $root   Optional root folder 
     
    30123012     * @param   string  $rights Optional ACL requirements 
    30133013     * 
    3014      * @return  array   List of mailboxes/folders 
     3014     * @return  array   List of subscribed folders 
    30153015     * @see     rcube_imap::list_mailboxes() 
    30163016     * @access  private 
     
    31153115        else { 
    31163116            // retrieve list of folders from IMAP server 
    3117             $a_mboxes = $this->conn->listMailboxes($root, $name); 
     3117            $a_mboxes = $this->_list_unsubscribed($root, $name); 
    31183118        } 
    31193119 
     
    31463146 
    31473147        return $a_mboxes; 
     3148    } 
     3149 
     3150 
     3151    /** 
     3152     * Private method for mailbox listing (LIST) 
     3153     * 
     3154     * @param   string  $root   Optional root folder 
     3155     * @param   string  $name   Optional name pattern 
     3156     * 
     3157     * @return  array   List of folders 
     3158     * @see     rcube_imap::list_unsubscribed() 
     3159     */ 
     3160    private function _list_unsubscribed($root='', $name='*') 
     3161    { 
     3162        $result = $this->conn->listMailboxes($root, $name); 
     3163 
     3164        if (!is_array($result)) { 
     3165            return array(); 
     3166        } 
     3167 
     3168        // #1486796: some server configurations doesn't 
     3169        // return folders in all namespaces, we'll try to detect that situation 
     3170        // and ask for these namespaces separately 
     3171        if ($root == '' && $name = '*') { 
     3172            $delim     = $this->get_hierarchy_delimiter(); 
     3173            $namespace = $this->get_namespace(); 
     3174            $search    = array(); 
     3175 
     3176            // build list of namespace prefixes 
     3177            foreach ((array)$namespace as $ns) { 
     3178                if (is_array($ns)) { 
     3179                    foreach ($ns as $ns_data) { 
     3180                        if ($len = strlen($ns_data[0])) { 
     3181                            $search = array('len' => $len, 'prefix' => $ns_data[0]); 
     3182                        } 
     3183                    } 
     3184                } 
     3185            } 
     3186 
     3187            if (!empty($search)) { 
     3188                // go through all folders detecting namespace usage 
     3189                foreach ($list as $folder) { 
     3190                    foreach ($search as $idx => $s) { 
     3191                        if ($s['prefix'] == substr($folder, 0, $s['len'])) { 
     3192                            unset($search[$idx]); 
     3193                        } 
     3194                    } 
     3195                    if (empty($search)) { 
     3196                        break; 
     3197                    } 
     3198                } 
     3199 
     3200                // get folders in hidden namespaces and add to the result 
     3201                foreach ($search as $s) { 
     3202                    $list = $this->conn->listMailboxes($s['prefix'], $name); 
     3203 
     3204                    if (!empty($list)) { 
     3205                        $result = array_merge($result, $list); 
     3206                    } 
     3207                } 
     3208            } 
     3209        } 
     3210 
     3211        return $result; 
    31483212    } 
    31493213 
Note: See TracChangeset for help on using the changeset viewer.