PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
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
← All changes | back/Controllers/MailboxActions/Listing.php +42 -38 10.0.1 → 11.1.0 View file →
@@ -7,37 +7,16 @@
7 7 use AcyMailing\Helpers\WorkflowHelper;
8 8
9 9 trait Listing
10 10 {
11 - private function prepareMailboxesActions(&$data)
11 + public function prepareMailboxesListing(array &$data): void
12 12 {
13 - if (empty($data['allMailboxes'])) {
14 - return;
15 - }
16 -
17 - foreach ($data['allMailboxes'] as $key => $oneMailbox) {
18 - $data['allMailboxes'][$key]->actionsRendered = [];
19 -
20 - $actions = json_decode($oneMailbox->actions, true);
21 - if (empty($actions)) {
22 - continue;
23 - }
24 -
25 - $actionsRendered = [];
26 - foreach ($actions as $action) {
27 - acym_trigger('onAcymMailboxActionSummaryListing', [&$action, &$actionsRendered]);
28 - }
29 -
30 - $data['allMailboxes'][$key]->actionsRendered = $actionsRendered;
31 - }
32 - }
33 -
34 - public function prepareMailboxesListing(&$data)
35 - {
13 + // Prepare the pagination
36 14 $mailboxesPerPage = $data['pagination']->getListLimit();
37 15 $page = $this->getVarFiltersListing('int', 'mailboxes_pagination_page', 1);
38 16 $status = $data['status'];
39 17
18 + // Get the matching mailboxes
40 19 $matchingMailboxes = $this->getMatchingElementsFromData(
41 20 [
42 21 'ordering' => $data['ordering'],
43 22 'search' => $data['search'],
@@ -50,19 +29,18 @@
50 29 $page,
51 30 'mailbox'
52 31 );
53 32
54 - $totalElement = $matchingMailboxes['total'];
55 33 $data['allStatusFilters'] = [
56 34 'all' => $matchingMailboxes['total']->total,
57 35 'active' => $matchingMailboxes['total']->totalActive,
58 36 'inactive' => $matchingMailboxes['total']->total - $matchingMailboxes['total']->totalActive,
59 37 ];
60 - $data['pagination']->setStatus($totalElement->total, $page, $mailboxesPerPage);
38 + $data['pagination']->setStatus($matchingMailboxes['total']->total, $page, $mailboxesPerPage);
61 39 $data['allMailboxes'] = $matchingMailboxes['elements'];
62 40 }
63 41
64 - public function mailboxes()
42 + public function mailboxes(): void
65 43 {
66 44 acym_setVar('layout', 'mailboxes');
67 45 acym_setVar('task', 'mailboxes');
68 46
@@ -77,32 +55,58 @@
77 55
78 56 parent::display($data);
79 57 }
80 58
81 - private function mailboxDoListingAction($action)
59 + public function duplicateMailboxAction(): void
82 60 {
83 - $mailboxClass = new MailboxClass();
84 - if (!method_exists($mailboxClass, $action)) {
61 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
62 +
63 + $mailboxActionSelected = acym_getVar('array', 'elements_checked', []);
64 + if (empty($mailboxActionSelected)) {
85 65 return;
86 66 }
87 67
88 - $mailboxActionSelected = acym_getVar('int', 'elements_checked');
68 + $mailboxClass = new MailboxClass();
69 + $mailboxClass->duplicate($mailboxActionSelected);
89 70
71 + $this->mailboxes();
72 + }
73 +
74 + public function deleteMailboxAction(): void
75 + {
76 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
77 +
78 + $mailboxActionSelected = acym_getVar('array', 'elements_checked');
90 79 if (empty($mailboxActionSelected)) {
91 80 return;
92 81 }
93 82
94 - $mailboxClass->$action($mailboxActionSelected);
83 + $mailboxClass = new MailboxClass();
84 + $mailboxClass->delete($mailboxActionSelected);
95 85
96 86 $this->mailboxes();
97 87 }
98 88
99 - public function duplicateMailboxAction()
89 + private function prepareMailboxesActions(array &$data): void
100 90 {
101 - $this->mailboxDoListingAction('duplicate');
102 - }
91 + if (empty($data['allMailboxes'])) {
92 + return;
93 + }
103 94
104 - public function deleteMailboxAction()
105 - {
106 - $this->mailboxDoListingAction('delete');
95 + foreach ($data['allMailboxes'] as $key => $oneMailbox) {
96 + $data['allMailboxes'][$key]->actionsRendered = [];
97 +
98 + $actions = json_decode($oneMailbox->actions, true);
99 + if (empty($actions)) {
100 + continue;
101 + }
102 +
103 + // We build the actions to display in the listing
104 + $actionsRendered = [];
105 + foreach ($actions as $action) {
106 + acym_trigger('onAcymMailboxActionSummaryListing', [&$action, &$actionsRendered]);
107 + }
108 +
109 + $data['allMailboxes'][$key]->actionsRendered = $actionsRendered;
110 + }
107 111 }
108 112 }