1: <?php
2:
3: /**
4: * This file contains the maillog collection and item class.
5: *
6: * @package Core
7: * @subpackage GenericDB_Model
8: * @author Simon Sprankel
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Mail log collection
19: *
20: * @package Core
21: * @subpackage GenericDB_Model
22: */
23: class cApiMailLogCollection extends ItemCollection {
24: /**
25: * Constructor to create an instance of this class.
26: *
27: * @throws cInvalidArgumentException
28: */
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['mail_log'], 'idmail');
32: $this->_setItemClass('cApiMailLog');
33: }
34:
35: /**
36: * Creates a new mail log entry with the given data.
37: *
38: * @param string|array $from
39: * @param string|array $to
40: * @param string|array $replyTo
41: * @param string|array $cc
42: * @param string|array $bcc
43: * @param string $subject
44: * @param string $body
45: * @param string $created
46: * timestamp!
47: * @param string $charset
48: * @param string $contentType
49: *
50: * @return cApiMailLog
51: * @throws cDbException
52: * @throws cException
53: * @throws cInvalidArgumentException
54: */
55: public function create($from, $to, $replyTo, $cc, $bcc, $subject, $body, $created, $charset, $contentType) {
56: $item = $this->createNewItem();
57:
58: $item->set('from', json_encode($from));
59: $item->set('to', json_encode($to));
60: $item->set('reply_to', json_encode($replyTo));
61: $item->set('cc', json_encode($cc));
62: $item->set('bcc', json_encode($bcc));
63: $item->set('subject', $subject);
64: $item->set('body', $body);
65: $date = date('Y-m-d H:i:s', $created);
66: $item->set('created', $date, false);
67: $idclient = cRegistry::getClientId();
68: $item->set('idclient', $idclient);
69: $idlang = cRegistry::getLanguageId();
70: $item->set('idlang', $idlang);
71: $item->set('charset', $charset);
72: $item->set('content_type', $contentType);
73:
74: $item->store();
75:
76: return $item;
77: }
78: }
79:
80: /**
81: * Mail log item
82: *
83: * @package Core
84: * @subpackage GenericDB_Model
85: */
86: class cApiMailLog extends Item
87: {
88: /**
89: * Constructor to create an instance of this class.
90: *
91: * @param mixed $mId
92: *
93: * @throws cDbException
94: * @throws cException
95: */
96: public function __construct($mId = false) {
97: global $cfg;
98: parent::__construct($cfg['tab']['mail_log'], 'idmail');
99: $this->setFilters(array(), array());
100: if ($mId !== false) {
101: $this->loadByPrimaryKey($mId);
102: }
103: }
104: }
105: