1<?php 2/** 3 * Copyright 2014-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (GPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/gpl. 7 * 8 * @category Horde 9 * @copyright 2014-2017 Horde LLC 10 * @license http://www.horde.org/licenses/gpl GPL 11 * @package IMP 12 */ 13 14/** 15 * Object representing a series of logged messages. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @author Jan Schneider <jan@horde.org> 19 * @category Horde 20 * @copyright 2014-2017 Horde LLC 21 * @license http://www.horde.org/licenses/gpl GPL 22 * @package IMP 23 */ 24class IMP_Maillog_Messages implements IteratorAggregate 25{ 26 /** 27 * The messages' mailbox. 28 * 29 * @var IMP_Mailbox 30 */ 31 protected $_mbox; 32 33 /** 34 * IDs of the messages. 35 * 36 * @var Horde_Imap_Client_Ids 37 */ 38 protected $_ids; 39 40 /** 41 * Message-IDs. 42 * 43 * @var array 44 */ 45 protected $_msgids; 46 47 /** 48 * Constructor. 49 * 50 * @param IMP_Mailbox $mbox The messages' mailbox. 51 * @param Horde_Imap_Client_Ids $data IDs of the messages. 52 */ 53 public function __construct(IMP_Mailbox $mbox, Horde_Imap_Client_Ids $data) 54 { 55 $this->_mbox = $mbox; 56 $this->_ids = $data; 57 } 58 59 /** 60 */ 61 public function getMessageIds() 62 { 63 if (isset($this->_msgids)) { 64 return $this->_msgids; 65 } 66 67 $this->_msgids = array(); 68 $query = new Horde_Imap_Client_Fetch_Query(); 69 $query->envelope(); 70 $ret = $this->_mbox->imp_imap->fetch( 71 $this->_mbox, 72 $query, 73 array('ids' => $this->_ids) 74 ); 75 foreach ($ret as $ob) { 76 $this->_msgids[] = $ob->getEnvelope()->message_id; 77 } 78 79 return $this->_msgids; 80 } 81 82 /* Iterator methods. */ 83 84 public function getIterator() 85 { 86 return new ArrayIterator($this->getMessageIds()); 87 } 88} 89