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/Fields/Listing.php +60 -0 10.1.0 → 11.1.0 View file →
@@ -1,0 +1,60 @@
1 +<?php
2 +
3 +namespace AcyMailing\Controllers\Fields;
4 +
5 +use AcyMailing\Classes\FieldClass;
6 +use AcyMailing\Helpers\ToolbarHelper;
7 +
8 +trait Listing
9 +{
10 + public function listing(): void
11 + {
12 + $data = [];
13 +
14 + if (!acym_level(ACYM_ENTERPRISE)) {
15 + acym_setVar('layout', 'splashscreen');
16 + }
17 +
18 + parent::display($data);
19 + }
20 +
21 + protected function prepareToolbar(array &$data): void
22 + {
23 + $toolbarHelper = new ToolbarHelper();
24 + $toolbarHelper->addButton(acym_translation('ACYM_CREATE'), ['data-task' => 'edit'], 'add', true);
25 +
26 + $data['toolbar'] = $toolbarHelper;
27 + }
28 +
29 + public function ajaxSetOrdering(): void
30 + {
31 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
32 +
33 + $order = json_decode(acym_getVar('string', 'order'), true);
34 + if (empty($order)) {
35 + $order = [];
36 + }
37 +
38 + $i = 1;
39 + $error = false;
40 + foreach ($order as $field) {
41 + $query = 'UPDATE #__acym_field SET `ordering` = '.intval($i).' WHERE `id` = '.intval($field);
42 + $error = acym_query($query) < 0 || $error;
43 + $i++;
44 + }
45 +
46 + acym_sendAjaxResponse('', [], !$error);
47 + }
48 +
49 + public function delete(): void
50 + {
51 + $fieldClass = new FieldClass();
52 + $ids = acym_getVar('array', 'elements_checked', []);
53 + if (in_array('1', $ids) || in_array('2', $ids) || in_array($fieldClass->getLanguageFieldId(), $ids)) {
54 + acym_enqueueMessage(acym_translation('ACYM_CANT_DELETE'), 'error');
55 + $this->listing();
56 + } else {
57 + parent::delete();
58 + }
59 + }
60 +}