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 / Controllers / MailboxActions / Listing.php

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

109 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 private function prepareMailboxesActions(&$data)
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 {
36 $mailboxesPerPage = $data['pagination']->getListLimit();
37 $page = $this->getVarFiltersListing('int', 'mailboxes_pagination_page', 1);
38 $status = $data['status'];
39
40 $matchingMailboxes = $this->getMatchingElementsFromData(
41 [
42 'ordering' => $data['ordering'],
43 'search' => $data['search'],
44 'elementsPerPage' => $mailboxesPerPage,
45 'offset' => ($page - 1) * $mailboxesPerPage,
46 'ordering_sort_order' => $data['orderingSortOrder'],
47 'status' => $status,
48 ],
49 $status,
50 $page,
51 'mailbox'
52 );
53
54 $totalElement = $matchingMailboxes['total'];
55 $data['allStatusFilters'] = [
56 'all' => $matchingMailboxes['total']->total,
57 'active' => $matchingMailboxes['total']->totalActive,
58 'inactive' => $matchingMailboxes['total']->total - $matchingMailboxes['total']->totalActive,
59 ];
60 $data['pagination']->setStatus($totalElement->total, $page, $mailboxesPerPage);
61 $data['allMailboxes'] = $matchingMailboxes['elements'];
62 }
63
64 public function mailboxes()
65 {
66 acym_setVar('layout', 'mailboxes');
67 acym_setVar('task', 'mailboxes');
68
69 $data = [
70 'pagination' => new PaginationHelper(),
71 'workflowHelper' => new WorkflowHelper(),
72 ];
73 $this->getAllParamsRequest($data);
74 $this->prepareMailboxesListing($data);
75 $this->prepareMailboxesActions($data);
76 $this->prepareToolbar($data, 'mailboxes');
77
78 parent::display($data);
79 }
80
81 private function mailboxDoListingAction($action)
82 {
83 $mailboxClass = new MailboxClass();
84 if (!method_exists($mailboxClass, $action)) {
85 return;
86 }
87
88 $mailboxActionSelected = acym_getVar('int', 'elements_checked');
89
90 if (empty($mailboxActionSelected)) {
91 return;
92 }
93
94 $mailboxClass->$action($mailboxActionSelected);
95
96 $this->mailboxes();
97 }
98
99 public function duplicateMailboxAction()
100 {
101 $this->mailboxDoListingAction('duplicate');
102 }
103
104 public function deleteMailboxAction()
105 {
106 $this->mailboxDoListingAction('delete');
107 }
108 }
109