1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\Modules\MailScheduledMessages;
9:
10: /**
11: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
12: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
13: * @copyright Copyright (c) 2023, Afterlogic Corp.
14: */
15: class Manager extends \Aurora\System\Managers\AbstractManagerWithStorage
16: {
17: public function __construct(\Aurora\System\Module\AbstractModule $oModule = null)
18: {
19: parent::__construct($oModule, new Storages\Db\Storage($this));
20: }
21:
22: /**
23: * @return array|bool
24: */
25: public function getMessagesForSend($iTimestamp)
26: {
27: $aMessagesForSend = $this->oStorage->getMessagesForSend($iTimestamp);
28: return $aMessagesForSend;
29: }
30:
31: /**
32: * @param int $iAccountID
33: * @param string $sFolderFullName
34: * @param string $sMessageUid
35: * @param string $sDeviceId
36: *
37: * @return bool
38: */
39: public function addMessage($iAccountID, $sFolderFullName, $sMessageUid, $iTimestamp)
40: {
41: return $this->oStorage->addMessage($iAccountID, $sFolderFullName, $sMessageUid, $iTimestamp);
42: }
43:
44: public function updateMessageScheduleTimestamp($iAccountID, $sFolderFullName, $sMessageUid, $iTimestamp)
45: {
46: return $this->oStorage->updateMessageScheduleTimestamp($iAccountID, $sFolderFullName, $sMessageUid, $iTimestamp);
47: }
48:
49: public function getMessage($iAccountID, $sFolderFullName, $sMessageUid)
50: {
51: return $this->oStorage->getMessage($iAccountID, $sFolderFullName, $sMessageUid);
52: }
53:
54: public function removeMessage($iAccountID, $sFolderFullName, $sMessageUid)
55: {
56: return $this->oStorage->removeMessage($iAccountID, $sFolderFullName, $sMessageUid);
57: }
58:
59: /**
60: * Creates tables required for module work by executing create.sql file.
61: *
62: * @return boolean
63: */
64: public function createTablesFromFile()
65: {
66: $bResult = false;
67:
68: try {
69: $sFilePath = dirname(__FILE__) . '/Storages/Db/sql/create.sql';
70: $bResult = \Aurora\System\Managers\Db::getInstance()->executeSqlFile($sFilePath);
71: } catch (\Aurora\System\Exceptions\BaseException $oException) {
72: $this->setLastException($oException);
73: }
74:
75: return $bResult;
76: }
77:
78: /**
79: * Temp.
80: *
81: * @return boolean
82: */
83: public function insertDataFromFile()
84: {
85: $bResult = false;
86:
87: try {
88: $sFilePath = dirname(__FILE__) . '/Storages/Db/sql/insert.sql';
89: $bResult = \Aurora\System\Managers\Db::getInstance()->executeSqlFile($sFilePath);
90: } catch (\Aurora\System\Exceptions\BaseException $oException) {
91: $this->setLastException($oException);
92: }
93:
94: return $bResult;
95: }
96:
97: /**
98: * Update tables required for module work by executing update.sql file.
99: *
100: * @return boolean
101: */
102: public function updateTables()
103: {
104: return true;
105:
106: // $bResult = false;
107: //
108: // try
109: // {
110: // $sFilePath = dirname(__FILE__) . '/Storages/Db/sql/update.sql';
111: // $bResult = \Aurora\System\Managers\Db::getInstance()->executeSqlFile($sFilePath);
112: // }
113: // catch (\Aurora\System\Exceptions\BaseException $oException)
114: // {
115: // $this->setLastException($oException);
116: // }
117: //
118: // return $bResult;
119: }
120: }
121: