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/Queue/Campaigns.php +0 -157 10.2.2 → 11.1.1 View file →
@@ -1,157 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Queue;
4 -
5 -use AcyMailing\Classes\CampaignClass;
6 -use AcyMailing\Classes\QueueClass;
7 -use AcyMailing\Classes\TagClass;
8 -use AcyMailing\Helpers\PaginationHelper;
9 -use AcyMailing\Helpers\ToolbarHelper;
10 -use AcyMailing\Helpers\WorkflowHelper;
11 -
12 -trait Campaigns
13 -{
14 - public function campaigns(): void
15 - {
16 - acym_setVar('layout', 'campaigns');
17 -
18 - if (ACYM_PRODUCTION) {
19 - if (acym_level(ACYM_ESSENTIAL) && $this->config->get('cron_last', 0) < (time() - 43200)) {
20 - $message = acym_translation('ACYM_CREATE_CRON_REMINDER');
21 - $message .= ' <a id="acym__queue__configure-cron" href="'.acym_completeLink('configuration&tab=license').'">'.acym_translation('ACYM_GOTO_CONFIG').'</a>';
22 -
23 - $notification = [
24 - 'name' => 'cron_reminder',
25 - 'removable' => 1,
26 - ];
27 - acym_enqueueMessage($message, 'warning', true, [$notification]);
28 -
29 - }
30 - }
31 -
32 - $searchFilter = $this->getVarFiltersListing('string', 'cqueue_search', '');
33 - $tagFilter = $this->getVarFiltersListing('string', 'cqueue_tag', '');
34 - $status = $this->getVarFiltersListing('string', 'cqueue_status', '');
35 -
36 - $pagination = new PaginationHelper();
37 - $campaignsPerPage = $pagination->getListLimit();
38 - $page = $this->getVarFiltersListing('int', 'cqueue_pagination_page', 1);
39 -
40 - $queueClass = new QueueClass();
41 - $matchingElements = $queueClass->getMatchingCampaigns(
42 - [
43 - 'search' => $searchFilter,
44 - 'tag' => $tagFilter,
45 - 'status' => $status,
46 - 'campaignsPerPage' => $campaignsPerPage,
47 - 'offset' => ($page - 1) * $campaignsPerPage,
48 - ]
49 - );
50 -
51 - $pagination->setStatus((int)$matchingElements['total']->total, $page, $campaignsPerPage);
52 - $tagClass = new TagClass();
53 -
54 - $viewData = [
55 - 'allElements' => $matchingElements['elements'],
56 - 'pagination' => $pagination,
57 - 'search' => $searchFilter,
58 - 'tag' => $tagFilter,
59 - 'allTags' => $tagClass->getAllTagsByType(TagClass::TYPE_MAIL),
60 - 'numberPerStatus' => $matchingElements['status'],
61 - 'status' => $status,
62 - 'campaignClass' => new CampaignClass(),
63 - 'languages' => acym_getLanguages(),
64 - 'workflowHelper' => new WorkflowHelper(),
65 - ];
66 -
67 - $this->prepareToolbar($viewData);
68 -
69 - $this->breadcrumb[acym_translation('ACYM_MAILS')] = acym_completeLink('queue');
70 - parent::display($viewData);
71 - }
72 -
73 - public function prepareToolbar(array &$data): void
74 - {
75 - $toolbarHelper = new ToolbarHelper();
76 - $toolbarHelper->addSearchBar($data['search'], 'cqueue_search', 'ACYM_SEARCH');
77 - $toolbarHelper->addButton(
78 - acym_translation('ACYM_EMPTY_QUEUE'),
79 - [
80 - 'data-task' => 'emptyQueue',
81 - 'data-confirmation-message' => 'ACYM_ARE_YOU_SURE',
82 - ],
83 - 'close'
84 - );
85 - $otherContent = acym_modal(
86 - '<i class="acymicon-paper-plane"></i>'.acym_translation('ACYM_SEND_MAILS_MANUALLY'),
87 - '',
88 - null,
89 - 'data-reveal-larger',
90 - 'class="cell medium-6 large-shrink button" data-reload="true" data-ajax="true" data-iframe="&ctrl=queue&task=continuesend&id=0&totalsend=0"'
91 - );
92 - $toolbarHelper->addOtherContent($otherContent);
93 - $toolbarHelper->addFilterByTag($data, 'cqueue_tag', 'acym__queue__filter__tags acym__select');
94 -
95 - $data['toolbar'] = $toolbarHelper;
96 - if (!empty($data['tag'])) {
97 - $data['status_toolbar'] = [
98 - 'cqueue_tag' => $data['tag'],
99 - ];
100 - }
101 - }
102 -
103 - public function cancelSending(): void
104 - {
105 - $mailId = acym_getVar('int', 'acym__queue__cancel__mail_id');
106 -
107 - if (!empty($mailId)) {
108 - $hasStat = acym_loadResult('SELECT COUNT(*) FROM #__acym_user_stat WHERE mail_id = '.intval($mailId));
109 -
110 - acym_query('DELETE FROM #__acym_queue WHERE mail_id = '.intval($mailId));
111 - acym_query('UPDATE #__acym_mail_stat SET total_subscribers = sent WHERE mail_id = '.intval($mailId));
112 - acym_query('UPDATE #__acym_campaign SET active = 1 WHERE mail_id = '.intval($mailId));
113 - if (empty($hasStat)) {
114 - acym_query('UPDATE #__acym_campaign SET draft = "1", sent = "0", sending_date = NULL WHERE mail_id = '.intval($mailId));
115 - acym_query('DELETE FROM #__acym_mail_stat WHERE mail_id = '.intval($mailId));
116 - }
117 - } else {
118 - acym_enqueueMessage(acym_translation('ACYM_ERROR_QUEUE_CANCEL_CAMPAIGN'), 'error');
119 - }
120 - }
121 -
122 - public function cancelCampaignSending(): void
123 - {
124 - $this->cancelSending();
125 - $this->campaigns();
126 - }
127 -
128 - public function playPauseSending(): void
129 - {
130 - $active = acym_getVar('int', 'acym__queue__play_pause__active__new_value');
131 - $campaignId = acym_getVar('int', 'acym__queue__play_pause__campaign_id');
132 -
133 - if (!empty($campaignId)) {
134 - $queueClass = new QueueClass();
135 - $queueClass->unpauseCampaign($campaignId, $active);
136 - } else {
137 - if (!empty($active)) {
138 - acym_enqueueMessage(acym_translation('ACYM_ERROR_QUEUE_RESUME'), 'error');
139 - } else {
140 - acym_enqueueMessage(acym_translation('ACYM_ERROR_QUEUE_PAUSE'), 'error');
141 - }
142 - }
143 -
144 - $this->campaigns();
145 - }
146 -
147 - public function emptyQueue(): void
148 - {
149 - acym_checkToken();
150 -
151 - $queueClass = new QueueClass();
152 - $deleted = $queueClass->emptyQueue();
153 - acym_enqueueMessage(acym_translationSprintf('ACYM_EMAILS_REMOVED_QUEUE', $deleted));
154 -
155 - $this->campaigns();
156 - }
157 -}