1: <?php
2: /**
3: * Copyright 2014 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 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Object representing a message to be logged.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: *
23: * @property-read IMP_Indices $indices Indices object.
24: * @property-read string $msgid Message-ID.
25: */
26: class IMP_Maillog_Message
27: {
28: /**
29: * Index of the message.
30: *
31: * @var IMP_Indices
32: */
33: protected $_indices = null;
34:
35: /**
36: * Message-ID.
37: *
38: * @var string
39: */
40: protected $_msgid = null;
41:
42: /**
43: * Constructor.
44: *
45: * @param mixed $data See add().
46: */
47: public function __construct($data)
48: {
49: $this->add($data);
50: }
51:
52: /**
53: *
54: */
55: public function add($data)
56: {
57: if ($data instanceof IMP_Indices) {
58: $this->_indices = $data;
59: } else {
60: $this->_msgid = strval($data);
61: }
62: }
63:
64: /**
65: */
66: public function __toString()
67: {
68: return $this->msgid;
69: }
70:
71: /**
72: */
73: public function __get($name)
74: {
75: switch ($name) {
76: case 'indices':
77: return $this->_indices;
78:
79: case 'msgid':
80: if (!$this->_msgid) {
81: list($mbox, $uid) = $this->indices->getSingle();
82:
83: $query = new Horde_Imap_Client_Fetch_Query();
84: $query->envelope();
85:
86: $imp_imap = $mbox->imp_imap;
87:
88: $ret = $imp_imap->fetch($mbox, $query, array(
89: 'ids' => $imp_imap->getIdsOb($uid)
90: ));
91:
92: $this->_msgid = ($ob = $ret->first())
93: ? $ob->getEnvelope()->message_id
94: : '';
95: }
96:
97: return $this->_msgid;
98: }
99: }
100:
101: }
102: