1: <?php
2: /**
3: * Copyright 2003-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 2003-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Base class implementing logging of responses to e-mail messages.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2003-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Maillog
24: {
25: /**
26: * Storage driver.
27: *
28: * @var IMP_Maillog_Storage_Base
29: */
30: public $storage;
31:
32: /**
33: * Constructor.
34: *
35: * @param IMP_Maillog_Storage_Base $storage Storage driver.
36: */
37: public function __construct(IMP_Maillog_Storage_Base $storage)
38: {
39: $this->storage = $storage;
40: }
41:
42: /**
43: * Create a log entry.
44: *
45: * @param mixed $msgs An IMP_Maillog_Message object (or an
46: * array of objects).
47: * @param IMP_Maillog_Log_Base $log The log object.
48: */
49: public function log($msgs, IMP_Maillog_Log_Base $log)
50: {
51: foreach ((is_array($msgs) ? $msgs : array($msgs)) as $val) {
52: $this->storage->saveLog($val, $log);
53: }
54: }
55:
56: /**
57: * Retrieve history for a message.
58: *
59: * @param IMP_Maillog_Message $msg A message object.
60: * @param array $filter Filter these actions.
61: *
62: * @return array List of IMP_Maillog_Log_Base objects.
63: */
64: public function getLog(IMP_Maillog_Message $msg, array $filter = array())
65: {
66: return $this->storage->getLog($msg, $filter);
67: }
68:
69: /**
70: * Delete log entries.
71: *
72: * @param array $msgs An array of message objects to delete.
73: */
74: public function deleteLog(array $msgs)
75: {
76: $this->storage->deleteLogs($msgs);
77: }
78:
79: /**
80: * Retrieve changes to the maillog since the provided timestamp.
81: *
82: * @param integer $ts Timestamp.
83: *
84: * @return array An array of messages (IMP_Maillog_Message objects)
85: * changed since the provided timestamp.
86: */
87: public function getChanges($ts)
88: {
89: return $this->storage->getChanges($ts);
90: }
91:
92: }
93: