/**
* Constructor.
*
* @param IMP_Indices $indices The index of the message.
* @param boolean $peek Don't set seen flag?
*/
public function __construct(IMP_Indices $indices, $peek = false)
{
global $injector;
/* Get envelope/header information. We don't use flags in this
* view. */
try {
list($mbox, $uid) = $indices->getSingle();
if (!$uid) {
throw new Exception();
}
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->headers('imp', self::$headersUsed, array('cache' => true, 'peek' => true));
$imp_imap = $mbox->imp_imap;
$imp_imap->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
$ret = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
if (!($ob = $ret->first())) {
throw new Exception();
}
$this->contents = $injector->getInstance('IMP_Factory_Contents')->create($indices);
if (!$peek) {
$this->_loadHeaders();
}
} catch (Exception $e) {
throw new IMP_Exception(_("Requested message not found."));
}
$this->_envelope = $ob->getEnvelope();
$this->_headers = $ob->getHeaders('imp', Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
$this->_indices = $indices;
$this->_peek = $peek;
}