PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Classes / MailArchiveClass.php

MailArchiveClass.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Classes/MailArchiveClass.php

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Classes;
4
5 use AcyMailing\Core\AcymClass;
6
7 class MailArchiveClass extends AcymClass
8 {
9 public function __construct()
10 {
11 parent::__construct();
12
13 $this->table = 'mail_archive';
14 $this->pkey = 'id';
15 }
16
17 public function save($mailArchiveToSave)
18 {
19 $mailArchive = clone $mailArchiveToSave;
20
21 foreach ($mailArchive as $oneAttribute => $value) {
22 if (empty($value) || $oneAttribute === 'settings') {
23 continue;
24 }
25
26 if (is_array($value)) {
27 $mailArchive->$oneAttribute = json_encode($value);
28 }
29 }
30
31 return parent::save($mailArchive);
32 }
33
34 public function getOneByMailId($mailId)
35 {
36 return acym_loadObject('SELECT * FROM #__acym_mail_archive WHERE `mail_id` = '.intval($mailId));
37 }
38
39 public function deleteArchivePeriod(): array
40 {
41 if (empty($this->config->get('delete_archive_history_enabled', 1))) {
42 return [];
43 }
44
45 $deleteOverSecond = $this->config->get('delete_archive_history_after', 86400 * 90);
46 if (empty($deleteOverSecond)) {
47 return [];
48 }
49
50 try {
51 $status = acym_query('DELETE FROM #__acym_mail_archive WHERE `date` < '.intval(time() - $deleteOverSecond));
52 $message = empty($status) ? '' : acym_translationSprintf('ACYM_DELETE_X_ROWS_TABLE_X', $status, strtolower(acym_translation('ACYM_EMAIL_ARCHIVE_HISTORY')));
53 } catch (\Exception $e) {
54 $status = false;
55 $message = $e->getMessage();
56 }
57
58 return [
59 'status' => $status !== false,
60 'message' => $message,
61 ];
62 }
63 }
64