PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.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
← All changes | back/Controllers/MailboxActions/Listing.php +0 -112 11.0.2 → 11.1.1 View file →
@@ -1,112 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\MailboxActions;
4 -
5 -use AcyMailing\Classes\MailboxClass;
6 -use AcyMailing\Helpers\PaginationHelper;
7 -use AcyMailing\Helpers\WorkflowHelper;
8 -
9 -trait Listing
10 -{
11 - public function prepareMailboxesListing(array &$data): void
12 - {
13 - // Prepare the pagination
14 - $mailboxesPerPage = $data['pagination']->getListLimit();
15 - $page = $this->getVarFiltersListing('int', 'mailboxes_pagination_page', 1);
16 - $status = $data['status'];
17 -
18 - // Get the matching mailboxes
19 - $matchingMailboxes = $this->getMatchingElementsFromData(
20 - [
21 - 'ordering' => $data['ordering'],
22 - 'search' => $data['search'],
23 - 'elementsPerPage' => $mailboxesPerPage,
24 - 'offset' => ($page - 1) * $mailboxesPerPage,
25 - 'ordering_sort_order' => $data['orderingSortOrder'],
26 - 'status' => $status,
27 - ],
28 - $status,
29 - $page,
30 - 'mailbox'
31 - );
32 -
33 - $data['allStatusFilters'] = [
34 - 'all' => $matchingMailboxes['total']->total,
35 - 'active' => $matchingMailboxes['total']->totalActive,
36 - 'inactive' => $matchingMailboxes['total']->total - $matchingMailboxes['total']->totalActive,
37 - ];
38 - $data['pagination']->setStatus($matchingMailboxes['total']->total, $page, $mailboxesPerPage);
39 - $data['allMailboxes'] = $matchingMailboxes['elements'];
40 - }
41 -
42 - public function mailboxes(): void
43 - {
44 - acym_setVar('layout', 'mailboxes');
45 - acym_setVar('task', 'mailboxes');
46 -
47 - $data = [
48 - 'pagination' => new PaginationHelper(),
49 - 'workflowHelper' => new WorkflowHelper(),
50 - ];
51 - $this->getAllParamsRequest($data);
52 - $this->prepareMailboxesListing($data);
53 - $this->prepareMailboxesActions($data);
54 - $this->prepareToolbar($data, 'mailboxes');
55 -
56 - parent::display($data);
57 - }
58 -
59 - public function duplicateMailboxAction(): void
60 - {
61 - wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
62 -
63 - $mailboxActionSelected = acym_getVar('int', 'elements_checked');
64 - if (empty($mailboxActionSelected)) {
65 - return;
66 - }
67 -
68 - $mailboxClass = new MailboxClass();
69 - $mailboxClass->duplicate($mailboxActionSelected);
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');
79 - if (empty($mailboxActionSelected)) {
80 - return;
81 - }
82 -
83 - $mailboxClass = new MailboxClass();
84 - $mailboxClass->delete($mailboxActionSelected);
85 -
86 - $this->mailboxes();
87 - }
88 -
89 - private function prepareMailboxesActions(array &$data): void
90 - {
91 - if (empty($data['allMailboxes'])) {
92 - return;
93 - }
94 -
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 - }
111 - }
112 -}