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/Plugins/Installed.php +0 -205 10.0.1 → 11.1.1 View file →
@@ -1,205 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Plugins;
4 -
5 -use AcyMailing\Classes\PluginClass;
6 -use AcyMailing\Helpers\WorkflowHelper;
7 -
8 -trait Installed
9 -{
10 - public function installed()
11 - {
12 - acym_setVar('layout', 'installed');
13 -
14 - $data = [];
15 - $data['tabs'] = $this->tabs;
16 - $data['tab'] = 'installed';
17 - $data['types'] = $this->types;
18 - $data['level'] = $this->level;
19 - $data['plugins'] = $this->getAllPlugins();
20 - $data['workflowHelper'] = new WorkflowHelper();
21 -
22 - parent::display($data);
23 - }
24 -
25 - public function checkUpdates()
26 - {
27 - acym_checkPluginsVersion();
28 - $this->installed();
29 -
30 - return true;
31 - }
32 -
33 - public function saveSettings()
34 - {
35 - $pluginFolderName = acym_getVar('string', 'plugin__folder_name', '');
36 -
37 - if (empty($pluginFolderName)) {
38 - acym_enqueueMessage(acym_translation('ACYM_COULD_NOT_SAVE_SETTINGS'));
39 - $this->installed();
40 -
41 - return;
42 - }
43 -
44 - $pluginClass = new PluginClass();
45 - $plugin = $pluginClass->getOnePluginByFolderName($pluginFolderName);
46 -
47 - if (empty($plugin)) {
48 - acym_enqueueMessage(acym_translation('ACYM_COULD_NOT_SAVE_SETTINGS'));
49 - $this->installed();
50 -
51 - return;
52 - }
53 - $plugin->settings = empty($plugin->settings) ? [] : json_decode($plugin->settings, true);
54 -
55 - $pluginSettings = acym_getVar('array', $pluginFolderName, []);
56 -
57 - if (empty($pluginSettings)) {
58 - acym_enqueueMessage(acym_translation('ACYM_COULD_NOT_SAVE_SETTINGS'));
59 - $this->installed();
60 -
61 - return;
62 - }
63 -
64 - foreach ($pluginSettings as $key => $value) {
65 - if ($value == 'on') $value = 1;
66 - $plugin->settings[$key] = ['value' => $value];
67 - }
68 -
69 - foreach ($plugin->settings as $key => $value) {
70 - if (!array_key_exists($key, $pluginSettings)) $plugin->settings[$key] = ['value' => ''];
71 - }
72 -
73 - $plugin->settings = json_encode($plugin->settings);
74 - $pluginClass->save($plugin);
75 -
76 - $this->installed();
77 - }
78 -
79 - private function isLatestAcyMailingVersion()
80 - {
81 - $currentVersion = $this->config->get('version', '');
82 - $latestVersion = $this->config->get('latestversion', '');
83 - if (!version_compare($currentVersion, $latestVersion, '>=')) {
84 - acym_sendAjaxResponse(acym_translation('ACYM_NEED_LATEST_VERSION_TO_DOWNLOAD'), [], false);
85 - }
86 - }
87 -
88 - public function update()
89 - {
90 - $this->isLatestAcyMailingVersion();
91 -
92 - $plugin = acym_getVar('array', 'plugin');
93 -
94 - $pluginClass = new PluginClass();
95 - $id = $pluginClass->updateAddon($plugin['folder_name']);
96 - if (!empty($id)) {
97 - acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_SUCCESSFULLY_UPDATED'));
98 - } else {
99 - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_UPDATE_ADD_ON'), [], false);
100 - }
101 - }
102 -
103 - public function deletePlugin()
104 - {
105 - $pluginClass = new PluginClass();
106 - $id = acym_getVar('int', 'id');
107 -
108 - $plugin = $pluginClass->getOneById($id);
109 -
110 - if (empty($plugin)) {
111 - acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_NOT_FOUND'), [], false);
112 - }
113 -
114 - $routePlugin = dirname(acym_getPluginPath($plugin->folder_name));
115 -
116 - if (file_exists($routePlugin)) {
117 - acym_deleteFolder($routePlugin);
118 - if ($pluginClass->delete($id)) {
119 - acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_SUCCESSFULLY_DELETED'));
120 - }
121 - }
122 - acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_NOT_FOUND'), [], false);
123 - }
124 -
125 - public function toggleActivate()
126 - {
127 - $pluginClass = new PluginClass();
128 - $id = acym_getVar('int', 'id');
129 -
130 - $plugin = $pluginClass->getOneById($id);
131 -
132 -
133 - if (empty($plugin)) {
134 - acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_NOT_FOUND'), [], false);
135 - }
136 -
137 - $plugin->active = $plugin->active == 0 ? 1 : 0;
138 -
139 - if (!$pluginClass->save($plugin)) {
140 - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_SAVE_ADD_ON'), [], false);
141 - }
142 -
143 - acym_sendAjaxResponse();
144 - }
145 -
146 - private function getPluginClassAjaxCustomView()
147 - {
148 - $return = [];
149 - $return['folderName'] = acym_getVar('string', 'plugin');
150 - $return['className'] = acym_getVar('string', 'plugin_class');
151 -
152 - if (empty($return['folderName']) && empty($return['className'])) {
153 - acym_sendAjaxResponse(acym_translation('ACYM_CUSTOM_VIEW_NOT_FOUND'), [], false);
154 - }
155 -
156 - return $return;
157 - }
158 -
159 - public function getCustomViewPlugin()
160 - {
161 - $plugin = $this->getPluginClassAjaxCustomView();
162 -
163 - $customLayoutPath = ACYM_CUSTOM_PLUGIN_LAYOUT.$plugin['folderName'].'.html';
164 -
165 - $customView = '';
166 -
167 - if (file_exists($customLayoutPath)) $customView = acym_fileGetContent($customLayoutPath);
168 - if (empty($customView)) acym_trigger('getStandardStructure', [&$customView], $plugin['className']);
169 -
170 - acym_sendAjaxResponse('', ['content' => $customView]);
171 - }
172 -
173 - public function saveCustomViewPlugin()
174 - {
175 - $plugin = $this->getPluginClassAjaxCustomView();
176 - $pluginCustomView = acym_getVar('string', 'custom_view', '');
177 - $pluginCustomView = urldecode($pluginCustomView);
178 -
179 - $customLayoutPath = ACYM_CUSTOM_PLUGIN_LAYOUT.$plugin['folderName'].'.html';
180 -
181 - $result = acym_writeFile($customLayoutPath, $pluginCustomView);
182 -
183 - if ($result) {
184 - acym_sendAjaxResponse(acym_translation('ACYM_CUSTOM_VIEW_WELL_SAVED'));
185 - } else {
186 - acym_sendAjaxResponse(acym_translation('ACYM_CUSTOM_VIEW_SAVED_FAILED'), [], false);
187 - }
188 - }
189 -
190 - public function deleteCustomViewPlugin()
191 - {
192 - $plugin = $this->getPluginClassAjaxCustomView();
193 -
194 - $customLayoutPath = ACYM_CUSTOM_PLUGIN_LAYOUT.$plugin['folderName'].'.html';
195 -
196 - if (file_exists($customLayoutPath) && !acym_deleteFile($customLayoutPath)) {
197 - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_DELETE_CUSTOM_VIEW'), [], false);
198 - }
199 -
200 - $customView = '';
201 - acym_trigger('getStandardStructure', [&$customView], $plugin['className']);
202 -
203 - acym_sendAjaxResponse(acym_translation('ACYM_CUSTOM_VIEW_WELL_DELETED'), ['content' => $customView]);
204 - }
205 -}