Zend_Mail_Storage_Folder example


    protected function _buildFolderTree($currentDir$parentFolder = null, $parentGlobalName = '')
    {
        if (!$parentFolder) {
            $this->_rootFolder = new Zend_Mail_Storage_Folder('/', '/', false);
            $parentFolder = $this->_rootFolder;
        }

        $dh = @opendir($currentDir);
        if (!$dh) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception("can't read dir $currentDir");
        }
        while (($entry = readdir($dh)) !== false) {
            
if (!@mkdir($fulldir) || !@mkdir($fulldir . DIRECTORY_SEPARATOR . 'cur')) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('error while creating new folder, may be created incompletly');
        }

        mkdir($fulldir . DIRECTORY_SEPARATOR . 'new');
        mkdir($fulldir . DIRECTORY_SEPARATOR . 'tmp');

        $localName = $parent ? substr($folderstrlen($parent) + 1) : $folder;
        $this->getFolders($parent)->$localName = new Zend_Mail_Storage_Folder($localName$folder, true);

        return $fulldir;
    }

    /** * remove a folder * * @param string|Zend_Mail_Storage_Folder $name name or instance of folder * @return null * @throws Zend_Mail_Storage_Exception */
    
public function getFolders($rootFolder = null)
    {
        $folders = $this->_protocol->listMailbox((string)$rootFolder);
        if (!$folders) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('folder not found');
        }

        ksort($folders, SORT_STRING);
        $root = new Zend_Mail_Storage_Folder('/', '/', false);
        $stack = array(null);
        $folderStack = array(null);
        $parentFolder = $root;
        $parent = '';

        foreach ($folders as $globalName => $data) {
            do {
                if (!$parent || strpos($globalName$parent) === 0) {
                    $pos = strrpos($globalName$data['delim']);
                    if ($pos === false) {
                        $localName = $globalName;
                    }
/** * find all subfolders and mbox files for folder structure * * Result is save in Zend_Mail_Storage_Folder instances with the root in $this->_rootFolder. * $parentFolder and $parentGlobalName are only used internally for recursion. * * @return null * @throws Zend_Mail_Storage_Exception */
    protected function _buildFolderTree()
    {
        $this->_rootFolder = new Zend_Mail_Storage_Folder('/', '/', false);
        $this->_rootFolder->INBOX = new Zend_Mail_Storage_Folder('INBOX', 'INBOX', true);

        $dh = @opendir($this->_rootdir);
        if (!$dh) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception("can't read folders in maildir");
        }
        $dirs = array();
        while (($entry = readdir($dh)) !== false) {
            
Home | Imprint | This part of the site doesn't use cookies.