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: * Abstract log entry.
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 string $action Action.
24: * @property-read string $date Formatted date string.
25: * @property-read string $message Log message.
26: * @property integer $timestamp Timestamp.
27: */
28: abstract class IMP_Maillog_Log_Base
29: {
30: /**
31: * Action.
32: *
33: * @var string
34: */
35: protected $_action;
36:
37: /**
38: * Timestamp.
39: *
40: * @var integer
41: */
42: protected $_timestamp;
43:
44: /**
45: */
46: public function __get($name)
47: {
48: global $prefs;
49:
50: switch ($name) {
51: case 'action':
52: return $this->_action;
53:
54: case 'date':
55: return strftime(
56: $prefs->getValue('date_format') . ' ' . $prefs->getValue('time_format_mini'),
57: $this->timestamp
58: );
59:
60: case 'message':
61: return $this->_getMessage();
62:
63: case 'timestamp':
64: if (!$this->_timestamp) {
65: $this->_timestamp = time();
66: }
67: return $this->_timestamp;
68: }
69: }
70:
71: /**
72: */
73: public function __set($name, $value)
74: {
75: switch ($name) {
76: case 'timestamp':
77: $this->_timestamp = intval($value);
78: break;
79: }
80: }
81:
82: /**
83: */
84: public function __tostring()
85: {
86: return $this->message;
87: }
88:
89: /**
90: * The log message.
91: *
92: * @return string Log message.
93: */
94: abstract protected function _getMessage();
95:
96: }
97: