示例#1
0
 /**
  * select given folder
  *
  * folder must be selectable!
  *
  * @param Zend_Mail_Folder|string global name of folder or instance for subfolder
  * @throws Zend_Mail_Exception
  */
 public function selectFolder($globalName)
 {
     // TODO: check $globalName for ..! could be user submitted data
     $this->_currentFolder = (string) $globalName;
     // rootdir is same as INBOX in maildir
     if (strpos($this->_currentFolder, 'INBOX') === 0) {
         $this->_currentFolder = substr($this->_currentFolder, 6);
     }
     try {
         $this->_openMaildir($this->_currentFolder ? $this->_rootdir . '.' . $this->_currentFolder : $this->_rootdir);
     } catch (Zend_Mail_Exception $e) {
         // check what went wrong
         // if folder does not exist getFolders() throws an exception
         if (!$this->getFolders($this->_currentFolder)->isSelectable()) {
             throw Zend::Exception('Zend_Mail_Exception', "{$this->_currentFolder} is not selectable");
         }
         // seems like file has vanished; rebuilding folder tree - but it's still an exception
         $this->_buildFolderTree($this->_rootdir);
         throw Zend::Exception('Zend_Mail_Exception', 'seems like the mbox file has vanished, I\'ve rebuild the ' . 'folder tree, search for an other folder and try again');
     }
 }