/** * Parse a LISTRIGHTS response (RFC 4314 [3.7]). * * @param Horde_Imap_Client_Interaction_Pipeline $pipeline Pipeline * object. * @param Horde_Imap_Client_Tokenize $data The server response. */ protected function _parseListRights(Horde_Imap_Client_Interaction_Pipeline $pipeline, Horde_Imap_Client_Tokenize $data) { // Ignore mailbox and identifier arguments $data->next(); $data->next(); $pipeline->data['listaclrights'] = new Horde_Imap_Client_Data_AclRights(str_split($data->next()), $data->flushIterator()); }
public function testFlushIterator() { $test = 'FOO (BAR (BAZ BAZ2) BAR2) FOO2'; $token = new Horde_Imap_Client_Tokenize($test); $token->rewind(); $token->next(); // FOO $token->next(); // Opening paren $this->assertEquals(array('BAR', 'BAR2'), $token->flushIterator()); $this->assertEquals('FOO2', $token->next()); $token->rewind(); $token->next(); // FOO $token->next(); // Opening paren $this->assertEquals(array(), $token->flushIterator(false)); $this->assertEquals('FOO2', $token->next()); $token->rewind(); $token->next(); // FOO $token->next(); // Opening paren $this->assertEquals(array(), $token->flushIterator(false, false)); $this->assertTrue($token->eos); }
/** * Parse a LISTRIGHTS response (RFC 4314 [3.7]). * * @param Horde_Imap_Client_Tokenzie $data The server response. */ protected function _parseListRights(Horde_Imap_Client_Tokenize $data) { // Ignore mailbox and identifier arguments $data->next(); $required = str_split($data->next()); $data->next(); $this->_temp['listaclrights'] = new Horde_Imap_Client_Data_AclRights($required, $data->flushIterator()); }
/** * Constructor. * * @param Horde_Imap_Client_Tokenize $token Tokenized data returned from * the server. */ public function __construct(Horde_Imap_Client_Tokenize $token) { $this->token = $token; /* Check for response status. */ $status = $token->current(); $valid = array('BAD', 'BYE', 'NO', 'OK', 'PREAUTH'); if (in_array($status, $valid)) { $this->status = constant(__CLASS__ . '::' . $status); $resp_text = $token->next(); /* Check for response code. Only occurs if there is a response * status. */ if (is_string($resp_text) && $resp_text[0] === '[') { $resp = new stdClass(); $resp->data = array(); if ($resp_text[strlen($resp_text) - 1] === ']') { $resp->code = substr($resp_text, 1, -1); } else { $resp->code = substr($resp_text, 1); while (($elt = $token->next()) !== false) { if (is_string($elt) && $elt[strlen($elt) - 1] === ']') { $resp->data[] = substr($elt, 0, -1); break; } $resp->data[] = is_string($elt) ? $elt : $token->flushIterator(); } } $token->next(); $this->responseCode = $resp; } } }