Zend_Mail_Storage_Exception example


    public function countMessages($flags = null)
    {
        if (!$this->_currentFolder) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('No selected folder to count');
        }

        if ($flags === null) {
            return count($this->_protocol->search(array('ALL')));
        }

        $params = array();
        foreach ((array)$flags as $flag) {
            if (isset(self::$_searchFlags[$flag])) {
                $params[] = self::$_searchFlags[$flag];
            } else {
                

    public function __get($var)
    {
        if (strpos($var, 'has') === 0) {
            $var = strtolower(substr($var, 3));
            return isset($this->_has[$var]) ? $this->_has[$var] : null;
        }

        /** * @see Zend_Mail_Storage_Exception */
        throw new Zend_Mail_Storage_Exception($var . ' not found');
    }


    /** * Get a full list of features supported by the specific mail lib and the server * * @return array list of features as array(featurename => true|false[|null]) */
    public function getCapabilities()
    {
        return $this->_has;
    }

    public function __construct($params)
    {
        if (is_array($params)) {
            $params = (object)$params;
        }

        if (!isset($params->dirname) || !is_dir($params->dirname)) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('no valid dirname given in params');
        }

        $this->_rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        $this->_delim = isset($params->delim) ? $params->delim : '.';

        $this->_buildFolderTree();
        $this->selectFolder(!empty($params->folder) ? $params->folder : 'INBOX');
        $this->_has['top'] = true;
        $this->_has['flags'] = true;
    }

    

    public function __get($name)
    {
        if (!isset($this->_folders[$name])) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception("no subfolder named $name");
        }

        return $this->_folders[$name];
    }

    /** * add or replace subfolder named $name * * @param string $name local name of subfolder * @param Zend_Mail_Storage_Folder $folder instance for new subfolder * @return null */

    public function __construct($params)
    {
        if (is_array($params)) {
            $params = (object)$params;
        }

        if (isset($params->filename)) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('use Zend_Mail_Storage_Mbox for a single file');
        }

        if (!isset($params->dirname) || !is_dir($params->dirname)) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('no valid dirname given in params');
        }

        $this->_rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        

    protected function _getFileData($id$field = null)
    {
        if (!isset($this->_files[$id - 1])) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('id does not exist');
        }

        if (!$field) {
            return $this->_files[$id - 1];
        }

        if (!isset($this->_files[$id - 1][$field])) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('field does not exist');
        }

    public function getRawHeader($id$part = null, $topLines = 0)
    {
        if ($part !== null) {
            // TODO: implement             /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('not implemented');
        }

        return $this->_protocol->top($id, 0, true);
    }

    /* * Get raw content of message or part * * @param int $id number of message * @param null|array|string $part path to part or null for messsage content * @return string raw content * @throws Zend_Mail_Protocol_Exception * @throws Zend_Mail_Storage_Exception */

    public static function initMaildir($dir)
    {
        if (file_exists($dir)) {
            if (!is_dir($dir)) {
                /** * @see Zend_Mail_Storage_Exception */
                throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists');
            }
        } else {
            if (!mkdir($dir)) {
                /** * @see Zend_Mail_Storage_Exception */
                $dir = dirname($dir);
                if (!file_exists($dir)) {
                    throw new Zend_Mail_Storage_Exception("parent $dir not found");
                } else if (!is_dir($dir)) {
                    throw new Zend_Mail_Storage_Exception("parent $dir not a directory");
                }

    protected function _getPos($id)
    {
        if (!isset($this->_positions[$id - 1])) {
            /** * @see Zend_Mail_Storage_Exception */
            throw new Zend_Mail_Storage_Exception('id does not exist');
        }

        return $this->_positions[$id - 1];
    }


    /** * Fetch a message * * @param int $id number of message * @return Zend_Mail_Message_File * @throws Zend_Mail_Storage_Exception */
Home | Imprint | This part of the site doesn't use cookies.