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/ZonesController.php +0 -85 10.0.1 → 11.1.1 View file →
@@ -1,85 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers;
4 -
5 -use AcyMailing\Core\AcymController;
6 -use AcyMailing\Classes\ZoneClass;
7 -
8 -class ZonesController extends AcymController
9 -{
10 - const ZONE_IMAGE_FOLDER = ACYM_UPLOAD_FOLDER.'zones'.DS;
11 -
12 - public function save()
13 - {
14 - acym_checkToken();
15 -
16 - $zone = new \stdClass();
17 - $zone->name = acym_getVar('string', 'name');
18 - $zone->content = acym_getVar('string', 'content', '', 'default', ACYM_ALLOWRAW);
19 -
20 - if (empty($zone->name) || empty($zone->content)) {
21 - acym_sendAjaxResponse(acym_translation('ACYM_FAILED_CUSTOM_ZONE_SAVE'), [], false);
22 - }
23 -
24 - $zoneClass = new ZoneClass();
25 - $existingZone = $zoneClass->getOneByName($zone->name);
26 -
27 - if (!empty($existingZone)) {
28 - acym_sendAjaxResponse(acym_translation('ACYM_FAILED_CUSTOM_ZONE_SAVE_EXISTING'), [], false);
29 - }
30 -
31 - $zone->id = $zoneClass->save($zone);
32 -
33 - $dataResponse = ['id' => $zone->id];
34 -
35 - if (!empty($_FILES['image']['name'])) {
36 - $extension = pathinfo($_FILES['image']['name']);
37 - $newPath = self::ZONE_IMAGE_FOLDER.$zone->id.'.'.$extension['extension'];
38 -
39 - if (in_array($extension['extension'], acym_getImageFileExtensions()) && acym_uploadFile($_FILES['image']['tmp_name'], ACYM_ROOT.$newPath)) {
40 - $zone->image = $newPath;
41 - if ($zoneClass->save($zone)) {
42 - $dataResponse['image'] = acym_rootURI().$newPath;
43 - }
44 - }
45 - }
46 -
47 - acym_sendAjaxResponse('', $dataResponse);
48 - }
49 -
50 - private function getZoneData()
51 - {
52 - acym_checkToken();
53 - $zoneId = acym_getVar('int', 'zoneId', 0);
54 - if (empty($zoneId)) {
55 - acym_sendAjaxResponse(acym_translation('ACYM_FAILED_CUSTOM_ZONE_FIND'), [], false);
56 - }
57 -
58 - $zoneClass = new ZoneClass();
59 - $zone = $zoneClass->getOneById($zoneId);
60 - if (empty($zone)) {
61 - acym_sendAjaxResponse(acym_translation('ACYM_FAILED_CUSTOM_ZONE_FIND'), [], false);
62 - }
63 -
64 - return [
65 - 'zoneClass' => $zoneClass,
66 - 'zoneId' => $zoneId,
67 - 'zone' => $zone,
68 - ];
69 - }
70 -
71 - public function getForInsertion()
72 - {
73 - $zoneData = $this->getZoneData();
74 -
75 - acym_sendAjaxResponse('', ['content' => $zoneData['zone']->content]);
76 - }
77 -
78 - public function delete()
79 - {
80 - $zoneData = $this->getZoneData();
81 - $zoneData['zoneClass']->delete($zoneData['zoneId']);
82 -
83 - acym_sendAjaxResponse();
84 - }
85 -}