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/Mails/Listing.php +53 -29 10.2.2 → 11.1.0 View file →
@@ -14,14 +14,16 @@
14 14 public function listing(): void
15 15 {
16 16 acym_setVar('layout', 'listing');
17 17
18 + // Get filters data
18 19 $searchFilter = $this->getVarFiltersListing('string', 'mails_search', '');
19 20 $tagFilter = $this->getVarFiltersListing('string', 'mails_tag', '');
20 - $ordering = $this->getVarFiltersListing('string', 'mails_ordering', 'creation_date');
21 + $ordering = $this->getVarFiltersListing('cmd', 'mails_ordering', 'creation_date');
21 22 $orderingSortOrder = $this->getVarFiltersListing('cmd', 'mails_ordering_sort_order', 'desc');
22 23
23 24 $pagination = new PaginationHelper();
25 + // Get pagination data
24 26 $mailsPerPage = $pagination->getListLimit();
25 27 $page = $this->getVarFiltersListing('int', 'mails_pagination_page', 1);
26 28 $mailClass = new MailClass();
27 29 $status = MailClass::TYPE_STANDARD;
@@ -47,8 +49,9 @@
47 49
48 50 return;
49 51 }
50 52
53 + // Prepare the pagination
51 54 $pagination->setStatus($matchingMails['total']->total, $page, $mailsPerPage);
52 55
53 56 ob_start();
54 57 require acym_getView('mails', 'listing_import', true);
@@ -85,33 +88,39 @@
85 88 $toolbarHelper = new ToolbarHelper();
86 89 $toolbarHelper->addSearchBar($data['search'], 'mails_search', 'ACYM_SEARCH');
87 90 $toolbarHelper->addFilterByTag($data, 'mails_tag', 'acym__templates__filter__tags acym__select');
88 91 $toolbarHelper->addButton(acym_translation('ACYM_ADD_DEFAULT_TMPL'), ['data-task' => 'installDefaultTmpl', 'id' => 'acym__mail__install-default'], 'content_copy');
89 - $otherContent = acym_modal(
90 - '<i class="acymicon-download"></i>'.acym_translation('ACYM_IMPORT'),
91 - $data['templateImportView'],
92 - 'acym__template__import__reveal',
93 - '',
94 - 'class="button button-secondary cell medium-6 large-shrink" data-reload="true" data-ajax="false"'
92 +
93 + $toolbarHelper->addModalButton(
94 + [
95 + 'button' => '<i class="acymicon-download"></i>'.esc_html(acym_translation('ACYM_IMPORT')),
96 + 'modalContent' => $data['templateImportView'],
97 + 'id' => 'acym__template__import__reveal',
98 + 'attributesButton' => [
99 + 'class' => 'button button-secondary cell medium-6 large-shrink',
100 + 'data-reload' => 'true',
101 + 'data-ajax' => 'false',
102 + ],
103 + ]
95 104 );
96 105
97 - $otherContent .= acym_modal(
98 - '<i class="acymicon-add"></i>'.acym_translation('ACYM_CREATE'),
99 - '<div class="cell grid-x grid-margin-x">
100 - <button type="button" data-task="edit" data-editor="html" class="acym__create__template button cell large-auto small-6 margin-top-1 button-secondary">'.acym_translation(
101 - 'ACYM_HTML_EDITOR'
102 - ).'</button>
103 - <button type="button" data-task="edit" data-editor="acyEditor" class="acym__create__template button cell medium-auto margin-top-1">'.acym_translation(
104 - 'ACYM_DD_EDITOR'
105 - ).'</button>
106 + $toolbarHelper->addModalButton(
107 + [
108 + 'button' => '<i class="acymicon-add"></i>'.esc_html(acym_translation('ACYM_CREATE')),
109 + 'modalContent' => '<div class="cell grid-x grid-margin-x">
110 + <button type="button" data-task="edit" data-editor="html" class="acym__create__template button cell large-auto small-6 margin-top-1 button-secondary">'.esc_html(
111 + acym_translation('ACYM_HTML_EDITOR')
112 + ).'</button>
113 + <button type="button" data-task="edit" data-editor="acyEditor" class="acym__create__template button cell medium-auto margin-top-1">'.esc_html(
114 + acym_translation('ACYM_DD_EDITOR')
115 + ).'</button>
106 116 </div>',
107 - '',
108 - '',
109 - 'class="acym_vcenter button cell medium-6 large-shrink"',
110 - true,
111 - false
117 + 'attributesButton' => [
118 + 'class' => 'acym_vcenter button cell medium-6 large-shrink',
119 + ],
120 + 'isLarge' => false,
121 + ]
112 122 );
113 - $toolbarHelper->addOtherContent($otherContent);
114 123
115 124 $data['toolbar'] = $toolbarHelper;
116 125 }
117 126
@@ -116,9 +125,9 @@
116 125 }
117 126
118 127 public function doUploadTemplate(): void
119 128 {
120 - acym_checkToken();
129 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
121 130
122 131 if (!acym_isAdmin() || !acym_isAllowed('mails')) {
123 132 die('Access denied');
124 133 }
@@ -130,10 +139,11 @@
130 139 }
131 140
132 141 public function export(): void
133 142 {
134 - acym_checkToken();
143 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
135 144
145 + // Get passed data and check if we have everything we need
136 146 $templateId = acym_getVar('int', 'templateId', 0);
137 147
138 148 if (empty($templateId)) {
139 149 exit;
@@ -141,8 +151,9 @@
141 151
142 152 $mailClass = new MailClass();
143 153 $template = $mailClass->getOneById($templateId);
144 154
155 + // We have all we need for the export, prepare the headers for the download
145 156 $exportHelper = new ExportHelper();
146 157 $exportHelper->exportTemplate($template);
147 158
148 159 exit;
@@ -149,8 +160,10 @@
149 160 }
150 161
151 162 public function installDefaultTmpl(): void
152 163 {
164 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
165 +
153 166 $updateHelper = new UpdateHelper();
154 167 $updateHelper->installTemplates();
155 168
156 169 $this->listing();
@@ -157,8 +170,10 @@
157 170 }
158 171
159 172 public function favorite(): void
160 173 {
174 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
175 +
161 176 $templateId = acym_getVar('int', 'templateId', 0);
162 177
163 178 if (empty($templateId)) {
164 179 acym_enqueueMessage(acym_translationSprintf('ACYM_NOT_FOUND', acym_translation('ACYM_TEMPLATE')), 'error');
@@ -167,9 +182,9 @@
167 182 return;
168 183 }
169 184
170 185 $favoriteTemplateId = $this->config->get('favorite_template', 0);
171 - $this->config->save(['favorite_template' => (int)$favoriteTemplateId === $templateId ? 0 : $templateId]);
186 + $this->config->saveConfig(['favorite_template' => (int)$favoriteTemplateId === $templateId ? 0 : $templateId]);
172 187
173 188 $this->listing();
174 189 }
175 190
@@ -174,8 +189,10 @@
174 189 }
175 190
176 191 public function massDuplicate(): void
177 192 {
193 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
194 +
178 195 $ids = acym_getVar('array', 'elements_checked', []);
179 196 if (!empty($ids)) {
180 197 $this->duplicate($ids);
181 198 }
@@ -183,8 +200,10 @@
183 200 }
184 201
185 202 public function oneDuplicate(): void
186 203 {
204 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
205 +
187 206 $templateId = acym_getVar('int', 'templateId', 0);
188 207
189 208 if (empty($templateId)) {
190 209 acym_enqueueMessage(acym_translation('ACYM_TEMPLATE_DUPLICATE_ERROR'), 'error');
@@ -211,8 +230,9 @@
211 230
212 231 $newTemplate = $oldTemplate;
213 232 $newTemplate->id = 0;
214 233 $newTemplate->name = $oldTemplate->name.'_copy';
234 + $newTemplate->creator_id = acym_currentUserId();
215 235 unset($newTemplate->thumbnail);
216 236
217 237 $mailClass->save($newTemplate);
218 238 }
@@ -239,19 +259,23 @@
239 259 }
240 260
241 261 public function getMailByIdAjax(): void
242 262 {
243 - acym_checkToken();
263 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
244 264 $mailId = acym_getVar('int', 'id', 0);
245 - if (empty($mailId)) acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_FIND_MAIL'), [], false);
265 + if (empty($mailId)) {
266 + acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_FIND_MAIL'), [], false);
267 + }
246 268
247 269 $mailClass = new MailClass();
248 270 $mail = $mailClass->getOneById($mailId);
249 - if (empty($mail)) acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_FIND_MAIL'), [], false);
271 + if (empty($mail)) {
272 + acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_FIND_MAIL'), [], false);
273 + }
250 274
251 275 if (!$mailClass->hasUserAccess($mailId)) {
252 276 die('Access denied for this mail');
253 277 }
254 278
255 - acym_sendAjaxResponse('', $mail);
279 + acym_sendAjaxResponse('', ['mail' => $mail]);
256 280 }
257 281 }