roundcubemail/program/include/rcmail.php
public function build_folder_tree(&$arrFolders, $folder, $delm = '/', $path = '')
    {
        // Handle namespace prefix
        $prefix = '';
        if (!$path) {
            $n_folder = $folder;
            $folder   = $this->storage->mod_folder($folder);

            if ($n_folder != $folder) {
                $prefix = substr($n_folder, 0, -strlen($folder));
            }
        }

        $pos = strpos($folder, $delm);

        if ($pos !== false) {
            $subFolders    = substr($folder, $pos+1);
            $currentFolder = substr($folder, 0, $pos);

            // sometimes folder has a delimiter as the last character
            if (!strlen($subFolders)) {
                $virtual = false;
            }
            else if (!isset($arrFolders[$currentFolder])) {
                $virtual = true;
            }
            else {
                $virtual = $arrFolders[$currentFolder]['virtual'];
            }
        }
        else {
            $subFolders    = false;
            $currentFolder = $folder;
            $virtual       = false;
        }

        $path .= $prefix . $currentFolder;

        if (!isset($arrFolders[$currentFolder])) {
            $arrFolders[$currentFolder] = array(
                'id'      => $path,
                'name'    => rcube_charset::convert($currentFolder, 'UTF7-IMAP'),
                'virtual' => $virtual,
                'folders' => array()
            );
        }
        else {
            $arrFolders[$currentFolder]['virtual'] = $virtual;
        }

        if (strlen($subFolders)) {
            $this->build_folder_tree($arrFolders[$currentFolder]['folders'], $subFolders, $delm, $path.$delm);
        }
    }
public function build_folder_tree(&$arrFolders, $folder, $delm = '/', $path = '')
    {
        // Handle namespace prefix
        $prefix = '';
        if (!$path) {
            $n_folder = $folder;
            $folder   = $this->storage->mod_folder($folder);

            if ($n_folder != $folder) {
                $prefix = substr($n_folder, 0, -strlen($folder));
            }
        }

        $pos = strpos($folder, $delm);

        if ($pos !== false) {
            $subFolders    = substr($folder, $pos+1);
            $currentFolder = substr($folder, 0, $pos);

            // sometimes folder has a delimiter as the last character
            if (!strlen($subFolders)) {
                $virtual = false;
            }
            else if (!isset($arrFolders[$currentFolder])) {
                $virtual = true;
            }
            else {
                $virtual = $arrFolders[$currentFolder]['virtual'];
            }
        }
        else {
            $subFolders    = false;
            $currentFolder = $folder;
            $virtual       = false;
        }

        $path .= $prefix . $currentFolder;

        if (!isset($arrFolders[$currentFolder])) {
            $arrFolders[$currentFolder] = array(
                'id'      => $path,
                'name'    => rcube_charset::convert($currentFolder, 'UTF7-IMAP'),
                'virtual' => $virtual,
                'folders' => array()
            );
        }
        else {
            $arrFolders[$currentFolder]['virtual'] = $virtual;
        }

        if (strlen($subFolders)) {
            $this->build_folder_tree($arrFolders[$currentFolder]['folders'], $subFolders, $delm, $path.$delm);
        }
    }
public function build_folder_tree ( & $ arrFolders , $ folder , $ delm = '/' , $ path = '' ) { // Handle namespace prefix $ prefix = '' ; if ( ! $ path ) { $ n_folder = $ folder ; $ folder = $ this -> storage -> mod_folder ( $ folder ) ; if ( $ n_folder != $ folder ) { $ prefix = substr ( $ n_folder , 0 , - strlen ( $ folder ) ) ; } } $ pos = strpos ( $ folder , $ delm ) ; if ( $ pos !== false ) { $ subFolders = substr ( $ folder , $ pos + 1 ) ; $ currentFolder = substr ( $ folder , 0 , $ pos ) ; // sometimes folder has a delimiter as the last character if ( ! strlen ( $ subFolders ) ) { $ virtual = false ; } else if ( ! isset ( $ arrFolders [ $ currentFolder ] ) ) { $ virtual = true ; } else { $ virtual = $ arrFolders [ $ currentFolder ] [ 'virtual' ] ; } } else { $ subFolders = false ; $ currentFolder = $ folder ; $ virtual = false ; } $ path .= $ prefix . $ currentFolder ; if ( ! isset ( $ arrFolders [ $ currentFolder ] ) ) { $ arrFolders [ $ currentFolder ] = array ( 'id' => $ path , 'name' => rcube_charset :: convert ( $ currentFolder , 'UTF7-IMAP' ) , 'virtual' => $ virtual , 'folders' => array ( ) ) ; } else { $ arrFolders [ $ currentFolder ] [ 'virtual' ] = $ virtual ; } if ( strlen ( $ subFolders ) ) { $ this -> build_folder_tree ( $ arrFolders [ $ currentFolder ] [ 'folders' ] , $ subFolders , $ delm , $ path . $ delm ) ; } }
Create a hierarchical array of the mailbox list
Create a hierarchical array of the mailbox list