1: <?php
 2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 
15: 
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17: 
18: 19: 20: 21: 22: 23: 
24: class cApiMailLogCollection extends ItemCollection {
25: 
26:     27: 28: 
29:     public function __construct() {
30:         global $cfg;
31:         parent::__construct($cfg['tab']['mail_log'], 'idmail');
32:         $this->_setItemClass('cApiMailLog');
33:     }
34: 
35:     36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 
50:     public function create($from, $to, $replyTo, $cc, $bcc, $subject, $body, $created, $charset, $contentType) {
51:         $item = parent::createNewItem();
52: 
53:         $item->set('from', json_encode($from));
54:         $item->set('to', json_encode($to));
55:         $item->set('reply_to', json_encode($replyTo));
56:         $item->set('cc', json_encode($cc));
57:         $item->set('bcc', json_encode($bcc));
58:         $item->set('subject', $subject);
59:         $item->set('body', $body);
60:         $date = date('Y-m-d H:i:s', $created);
61:         $item->set('created', $date, false);
62:         $idclient = cRegistry::getClientId();
63:         $item->set('idclient', $idclient);
64:         $idlang = cRegistry::getLanguageId();
65:         $item->set('idlang', $idlang);
66:         $item->set('charset', $charset);
67:         $item->set('content_type', $contentType);
68: 
69:         $item->store();
70: 
71:         return $item->get('idmail');
72:     }
73: }
74: 
75: 76: 77: 78: 79: 80: 
81: class cApiMailLog extends Item {
82: 
83:     84: 85: 86: 87: 
88:     public function __construct($mId = false) {
89:         global $cfg;
90:         parent::__construct($cfg['tab']['mail_log'], 'idmail');
91:         $this->setFilters(array(), array());
92:         if ($mId !== false) {
93:             $this->loadByPrimaryKey($mId);
94:         }
95:     }
96: }
97: