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/Helpers/Update/Patchv8.php +0 -370 10.10.2 → 11.1.1 View file →
@@ -1,370 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Classes\ConfigurationClass;
6 -use AcyMailing\Classes\FormClass;
7 -use AcyMailing\Classes\MailClass;
8 -use AcyMailing\Classes\RuleClass;
9 -
10 -trait Patchv8
11 -{
12 - private function updateFor800(): void
13 - {
14 - if ($this->isPreviousVersionAtLeast('8.0.0')) {
15 - return;
16 - }
17 -
18 - $this->updateQuery(
19 - 'CREATE TABLE IF NOT EXISTS `#__acym_mailbox_action` (
20 - `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
21 - `name` varchar(255) DEFAULT NULL,
22 - `frequency` int(10) UNSIGNED NOT NULL DEFAULT 0,
23 - `nextdate` int(10) UNSIGNED NOT NULL DEFAULT 0,
24 - `description` text DEFAULT NULL,
25 - `server` varchar(255) NULL,
26 - `port` varchar(50) NULL,
27 - `connection_method` ENUM(\'imap\', \'pop3\', \'pear\') NULL,
28 - `secure_method` ENUM(\'ssl\', \'tls\') NULL,
29 - `self_signed` tinyint(4) NULL,
30 - `username` varchar(255) NULL,
31 - `password` varchar(50) NULL,
32 - `conditions` text DEFAULT NULL,
33 - `actions` text DEFAULT NULL,
34 - `report` text DEFAULT NULL,
35 - `delete_wrong_emails` tinyint(4) NOT NULL DEFAULT 0,
36 - `senderfrom` tinyint(4) NOT NULL DEFAULT 0,
37 - `senderto` tinyint(4) NOT NULL DEFAULT 0,
38 - `active` tinyint(4) NOT NULL DEFAULT 0,
39 - PRIMARY KEY (`id`),
40 - INDEX `index_#__acym_mailbox_action1`(`name` ASC)
41 - )
42 - ENGINE = InnoDB;'
43 - );
44 - }
45 -
46 - private function updateFor810(): void
47 - {
48 - if ($this->isPreviousVersionAtLeast('8.1.0')) {
49 - return;
50 - }
51 -
52 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `settings` TEXT');
53 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `display_languages` VARCHAR(255)');
54 -
55 - $formClass = new FormClass();
56 - $forms = $formClass->getAll();
57 -
58 - foreach ($forms as $oneForm) {
59 - $oneForm->settings = [];
60 - foreach ($oneForm as $key => $value) {
61 - $optionsPos = strpos($key, '_options');
62 - if (empty($value) || ($key !== 'cookie' && $optionsPos === false)) {
63 - continue;
64 - }
65 -
66 - $category = $key === 'cookie' ? 'cookie' : substr($key, 0, $optionsPos);
67 - $oneForm->settings[$category] = json_decode($value, true);
68 - }
69 -
70 - $oneForm->settings = json_encode($oneForm->settings);
71 - $formClass->save($oneForm);
72 - }
73 -
74 - $this->updateQuery(
75 - 'ALTER TABLE `#__acym_form`
76 - DROP `lists_options`,
77 - DROP `fields_options`,
78 - DROP `style_options`,
79 - DROP `button_options`,
80 - DROP `image_options`,
81 - DROP `termspolicy_options`,
82 - DROP `cookie`,
83 - DROP `redirection_options`,
84 - DROP `display_options`,
85 - DROP `message_options`'
86 - );
87 -
88 - $this->updateQuery('ALTER TABLE `#__acym_user` CHANGE `key` `key` VARCHAR(40) NULL');
89 - }
90 -
91 - private function updateFor811(): void
92 - {
93 - if ($this->isPreviousVersionAtLeast('8.1.1')) {
94 - return;
95 - }
96 -
97 - $formClass = new FormClass();
98 - $forms = $formClass->getAll();
99 -
100 - foreach ($forms as $oneForm) {
101 - if (!empty($oneForm->display_languages)) {
102 - continue;
103 - }
104 - $oneForm->display_languages = '["all"]';
105 - $formClass->save($oneForm);
106 - }
107 - }
108 -
109 - private function updateFor850(): void
110 - {
111 - if ($this->isPreviousVersionAtLeast('8.5.0')) {
112 - return;
113 - }
114 -
115 - $aclPages = [
116 - 'forms',
117 - 'users',
118 - 'fields',
119 - 'lists',
120 - 'segments',
121 - 'campaigns',
122 - 'mails',
123 - 'override',
124 - 'automation',
125 - 'queue',
126 - 'plugins',
127 - 'bounces',
128 - 'stats',
129 - 'configuration',
130 - ];
131 -
132 - $config = acym_config();
133 - $groups = array_keys(acym_getGroups());
134 -
135 - foreach ($aclPages as $page) {
136 - $aclConfig = $config->get('acl_'.$page, 'all');
137 -
138 - if ($aclConfig === 'all') {
139 - continue;
140 - }
141 -
142 - $groupsAuthorized = [];
143 -
144 - foreach ($groups as $group) {
145 - if ($config->get('acl_'.$page.'_'.$group, 1) == 1) {
146 - $groupsAuthorized[] = $group;
147 - }
148 - }
149 -
150 - $config->saveConfig(['acl_'.$page => implode(',', $groupsAuthorized)]);
151 - }
152 -
153 - $queries = file_get_contents(ACYM_BACK.'tables.sql');
154 - $tables = explode('CREATE TABLE IF NOT EXISTS ', $queries);
155 - $tableNames = [];
156 - $indexes = [];
157 - $constraints = [];
158 -
159 - foreach ($tables as $oneTable) {
160 - if (strpos($oneTable, '`#__') !== 0) {
161 - continue;
162 - }
163 - $tableName = substr($oneTable, 1, strpos($oneTable, '`', 1) - 1);
164 - $tableNames[] = $tableName;
165 -
166 - $fields = explode("\n", $oneTable);
167 - foreach ($fields as $key => $oneField) {
168 - $oneField = rtrim(trim($oneField), ',');
169 - if (strpos($oneField, 'INDEX') === 0) {
170 - $firstBackquotePos = strpos($oneField, '`');
171 - $indexName = substr($oneField, $firstBackquotePos + 1, strpos($oneField, '`', $firstBackquotePos + 1) - $firstBackquotePos - 1);
172 -
173 - $indexes[$tableName][$indexName] = $oneField;
174 - } elseif (strpos($oneField, 'FOREIGN KEY') !== false) {
175 - preg_match('/(#__fk.*)\`/Uis', $fields[$key - 1], $matchesConstraints);
176 - preg_match('/(#__.*)\`\(`(.*)`\)/Uis', $fields[$key + 1], $matchesTable);
177 - preg_match('/\`(.*)\`/Uis', $oneField, $matchesColumn);
178 - if (!empty($matchesConstraints) && !empty($matchesTable) && !empty($matchesColumn)) {
179 - if (empty($constraints[$tableName])) $constraints[$tableName] = [];
180 - $constraints[$tableName][$matchesConstraints[1]] = [
181 - 'table' => $matchesTable[1],
182 - 'column' => $matchesColumn[1],
183 - 'table_column' => $matchesTable[2],
184 - ];
185 - }
186 - }
187 - }
188 - }
189 -
190 - foreach ($tableNames as $tableName) {
191 - if (!empty($indexes[$tableName])) {
192 - foreach ($indexes[$tableName] as $newName => $query) {
193 - $oldName = str_replace('#__index_', 'index_#__', $newName);
194 - preg_match('#\(.*\)#U', $query, $matches);
195 - try {
196 - acym_query('ALTER TABLE `'.$tableName.'` DROP INDEX `'.$oldName.'`, ADD INDEX `'.$newName.'`'.$matches[0]);
197 - } catch (\Exception $exception) {
198 - if (function_exists('acym_logError')) {
199 - acym_logError('Error while renaming index '.$oldName.', with the error '.$exception->getMessage());
200 - }
201 - }
202 - }
203 - }
204 -
205 - if (!empty($constraints[$tableName])) {
206 - acym_query('SET FOREIGN_KEY_CHECKS=0;');
207 - foreach ($constraints[$tableName] as $newName => $constraintInfo) {
208 - $oldName = str_replace('#__fk_', 'fk_#__', $newName);
209 - $query = 'ALTER TABLE '.$tableName.' DROP FOREIGN KEY `'.$oldName.'`,ADD CONSTRAINT `'.$newName.'` FOREIGN KEY (`'.$constraintInfo['column'].'`) REFERENCES `'.$constraintInfo['table'].'` (`'.$constraintInfo['table_column'].'`) ON DELETE NO ACTION ON UPDATE NO ACTION;';
210 - try {
211 - acym_query($query);
212 - } catch (\Exception $exception) {
213 - if (function_exists('acym_logError')) {
214 - acym_logError('Error while renaming foreign key '.$oldName.', with the error '.$exception->getMessage());
215 - }
216 - }
217 - }
218 - acym_query('SET FOREIGN_KEY_CHECKS=1;');
219 - }
220 - }
221 - }
222 -
223 - private function updateFor860(): void
224 - {
225 - if ($this->isPreviousVersionAtLeast('8.6.0')) {
226 - return;
227 - }
228 -
229 - $ruleClass = new RuleClass();
230 -
231 - $rule = new \stdClass();
232 - $rule->name = 'ACYM_SUPPRESSION_LIST';
233 - $rule->ordering = 2;
234 - $rule->regex = 'suppression list';
235 - $rule->executed_on = '["body"]';
236 - $rule->action_message = '["delete_message"]';
237 - $rule->action_user = '["unsubscribe_user","block_user","empty_queue_user"]';
238 - $rule->active = 1;
239 - $rule->increment_stats = 1;
240 - $rule->execute_action_after = 0;
241 - $ruleClass->save($rule);
242 -
243 - $rule = new \stdClass();
244 - $rule->name = 'ACYM_REJECTED';
245 - $rule->ordering = 9;
246 - $rule->regex = 'rejected *your *message|email *provider *rejected *it';
247 - $rule->executed_on = '["body"]';
248 - $rule->action_message = '["delete_message"]';
249 - $rule->action_user = '[]';
250 - $rule->active = 1;
251 - $rule->increment_stats = 1;
252 - $rule->execute_action_after = 0;
253 - $ruleClass->save($rule);
254 -
255 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_sent_date` DATETIME NULL');
256 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_open_date` DATETIME NULL');
257 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_click_date` DATETIME NULL');
258 -
259 - $this->updateQuery(
260 - 'CREATE TABLE IF NOT EXISTS `#__acym_mail_archive` (
261 - `id` INT NOT NULL AUTO_INCREMENT,
262 - `mail_id` INT NOT NULL,
263 - `date` INT(10) UNSIGNED NOT NULL,
264 - `body` LONGTEXT NOT NULL,
265 - `subject` VARCHAR(255) NULL,
266 - `settings` TEXT NULL,
267 - `stylesheet` TEXT NULL,
268 - `attachments` TEXT NULL,
269 - PRIMARY KEY (`id`),
270 - CONSTRAINT `#__fk_acym_mail_archive1`
271 - FOREIGN KEY (`mail_id`)
272 - REFERENCES `#__acym_mail`(`id`)
273 - ON DELETE NO ACTION
274 - ON UPDATE NO ACTION
275 - )
276 - ENGINE = InnoDB;'
277 - );
278 - }
279 -
280 - private function updateFor862(): void
281 - {
282 - if ($this->isPreviousVersionAtLeast('8.6.2')) {
283 - return;
284 - }
285 -
286 - $this->updateQuery('DELETE FROM #__acym_campaign WHERE mail_id IS NULL');
287 -
288 - $mailsToClean = acym_loadResultArray(
289 - 'SELECT mail.id
290 - FROM `#__acym_mail` AS mail
291 - LEFT JOIN #__acym_campaign AS campaign
292 - ON mail.id = campaign.mail_id
293 - WHERE campaign.mail_id IS NULL
294 - AND mail.parent_id IS NULL
295 - AND mail.type = '.acym_escapeDB(MailClass::TYPE_STANDARD)
296 - );
297 -
298 - if (!empty($mailsToClean)) {
299 - $this->updateQuery('DELETE FROM #__acym_mail_archive WHERE mail_id IN ('.implode(',', $mailsToClean).')');
300 - $mailClass = new MailClass();
301 - $mailClass->delete($mailsToClean);
302 - }
303 - }
304 -
305 - private function updateFor870(): void
306 - {
307 - if ($this->isPreviousVersionAtLeast('8.7.0')) {
308 - return;
309 - }
310 -
311 - $this->updateQuery('ALTER TABLE #__acym_plugin DROP `features`');
312 - }
313 -
314 - private function updateFor872(ConfigurationClass $config): void
315 - {
316 - if ($this->isPreviousVersionAtLeast('8.7.2')) {
317 - return;
318 - }
319 -
320 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
321 - if (empty($socialIcons['X'])) {
322 - $socialIcons['X'] = ACYM_IMAGES.'logo/x.png';
323 -
324 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
325 - }
326 - }
327 -
328 - private function updateFor873(ConfigurationClass $config): void
329 - {
330 - if ($this->isPreviousVersionAtLeast('8.7.3')) {
331 - return;
332 - }
333 -
334 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
335 -
336 - if (!empty($socialIcons['X']) || empty($socialIcons['x'])) {
337 - if (!empty($socialIcons['X'])) {
338 - unset($socialIcons['X']);
339 - }
340 -
341 - if (empty($socialIcons['x'])) {
342 - $socialIcons['x'] = ACYM_IMAGES.'logo/x.png';
343 - }
344 -
345 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
346 - }
347 - }
348 -
349 - private function updateFor874(ConfigurationClass $config): void
350 - {
351 - if ($this->isPreviousVersionAtLeast('8.7.4') || ACYM_CMS !== 'joomla') {
352 - return;
353 - }
354 -
355 - $config->saveConfig(['malicious_scan' => 1]);
356 - }
357 -
358 - private function updateFor881(ConfigurationClass $config): void
359 - {
360 - if ($this->isPreviousVersionAtLeast('8.7.0')) {
361 - return;
362 - }
363 -
364 - $uploadFolder = $config->get('uploadfolder');
365 - if (!empty($uploadFolder) && strpos($uploadFolder, '\\') !== false) {
366 - $uploadFolder = str_replace('\\', '/', $uploadFolder);
367 - $config->saveConfig(['uploadfolder' => $uploadFolder]);
368 - }
369 - }
370 -}