public function query($charset, $cached = false)
    {
        $charset = Horde_String::upper($charset);

        if (isset($this->_charsets[$charset])) {
            return $this->_charsets[$charset];
        } elseif ($cached) {
            return null;
        }

        if (!$this->_baseob) {
            throw new RuntimeException(
                'Base object needs to be defined to query for charset.'
            );
        }

        /* Use a dummy search query and search for BADCHARSET response. */
        $query = new Horde_Imap_Client_Search_Query();
        $query->charset($charset, false);
        $query->ids($this->_baseob->getIdsOb(1, true));
        $query->text('a');
        try {
            $this->_baseob->search('INBOX', $query, array(
                'nocache' => true,
                'sequence' => true
            ));
            $this->_charsets[$charset] = true;
        } catch (Horde_Imap_Client_Exception $e) {
            $this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET);
        }

        $this->notify();

        return $this->_charsets[$charset];
    }
public function query($charset, $cached = false)
    {
        $charset = Horde_String::upper($charset);

        if (isset($this->_charsets[$charset])) {
            return $this->_charsets[$charset];
        } elseif ($cached) {
            return null;
        }

        if (!$this->_baseob) {
            throw new RuntimeException(
                'Base object needs to be defined to query for charset.'
            );
        }

        /* Use a dummy search query and search for BADCHARSET response. */
        $query = new Horde_Imap_Client_Search_Query();
        $query->charset($charset, false);
        $query->ids($this->_baseob->getIdsOb(1, true));
        $query->text('a');
        try {
            $this->_baseob->search('INBOX', $query, array(
                'nocache' => true,
                'sequence' => true
            ));
            $this->_charsets[$charset] = true;
        } catch (Horde_Imap_Client_Exception $e) {
            $this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET);
        }

        $this->notify();

        return $this->_charsets[$charset];
    }
public function query ( $ charset , $ cached = false ) { $ charset = Horde_String :: upper ( $ charset ) ; if ( isset ( $ this -> _charsets [ $ charset ] ) ) { return $ this -> _charsets [ $ charset ] ; } elseif ( $ cached ) { return null ; } if ( ! $ this -> _baseob ) { throw new RuntimeException ( 'Base object needs to be defined to query for charset.' ) ; } /* Use a dummy search query and search for BADCHARSET response. */ $ query = new Horde_Imap_Client_Search_Query ( ) ; $ query -> charset ( $ charset , false ) ; $ query -> ids ( $ this -> _baseob -> getIdsOb ( 1 , true ) ) ; $ query -> text ( 'a' ) ; try { $ this -> _baseob -> search ( 'INBOX' , $ query , array ( 'nocache' => true , 'sequence' => true ) ) ; $ this -> _charsets [ $ charset ] = true ; } catch ( Horde_Imap_Client_Exception $ e ) { $ this -> _charsets [ $ charset ] = ( $ e -> getCode ( ) !== Horde_Imap_Client_Exception :: BADCHARSET ) ; } $ this -> notify ( ) ; return $ this -> _charsets [ $ charset ] ; }
Query the validity of a charset.

@param string $charset  The charset to query.
@param boolean $cached  If true, only query cached values.

@return boolean  True if the charset is valid for searching.
Query the validity of a charset .