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/Patchv6.php +0 -822 10.10.2 → 11.1.1 View file →
@@ -1,822 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Classes\ActionClass;
6 -use AcyMailing\Classes\ConditionClass;
7 -use AcyMailing\Classes\ConfigurationClass;
8 -use AcyMailing\Classes\FieldClass;
9 -use AcyMailing\Classes\ListClass;
10 -use AcyMailing\Classes\MailClass;
11 -use AcyMailing\Classes\PluginClass;
12 -use AcyMailing\Controllers\PluginsController;
13 -use AcyMailing\Helpers\AutomationHelper;
14 -use AcyMailing\Helpers\UpdateHelper;
15 -
16 -trait Patchv6
17 -{
18 - private function updateFor603(): void
19 - {
20 - if ($this->isPreviousVersionAtLeast('6.0.3')) {
21 - return;
22 - }
23 -
24 - $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD COLUMN `bounce_details` LONGTEXT NULL');
25 - $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD COLUMN `bounce_unique` MEDIUMINT(8) NOT NULL');
26 - $this->updateQuery('ALTER TABLE #__acym_user_stat ADD COLUMN `bounce` TINYINT(4) NOT NULL');
27 - $this->updateQuery('ALTER TABLE #__acym_user_stat ADD COLUMN `bounce_rule` VARCHAR(255) NULL');
28 - $this->updateQuery(
29 - 'CREATE TABLE IF NOT EXISTS `#__acym_history` (
30 - `user_id` INT NOT NULL,
31 - `date` INT NOT NULL,
32 - `ip` VARCHAR(16) DEFAULT NULL,
33 - `action` VARCHAR(50) NOT NULL,
34 - `data` text,
35 - `source` text,
36 - `mail_id` MEDIUMINT DEFAULT NULL,
37 - PRIMARY KEY (`user_id`,`date`)
38 - )'
39 - );
40 - $this->updateQuery('ALTER TABLE #__acym_rule CHANGE `id` `id` INT NOT NULL AUTO_INCREMENT');
41 - $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `increment_stats` TINYINT(3) NOT NULL');
42 - $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `execute_action_after` INT NOT NULL');
43 -
44 - $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_NAME" WHERE `id` = 1 AND `name` = "Name"');
45 - $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_EMAIL" WHERE `id` = 2 AND `name` = "Email"');
46 - $this->updateQuery('UPDATE #__acym_field SET `backend_profile` = 1, `backend_listing` = 1 WHERE `id` IN (1, 2)');
47 -
48 - $this->updateQuery('UPDATE #__acym_mail SET `thumbnail` = ""');
49 -
50 - if (ACYM_CMS === 'wordpress') {
51 - $this->updateQuery('UPDATE #__acym_configuration SET `value` = '.acym_escapeDB(ACYM_UPLOAD_FOLDER).' WHERE `name` = "uploadfolder"');
52 - $this->updateQuery('UPDATE #__acym_configuration SET `value` = '.acym_escapeDB(ACYM_LOGS_FOLDER.'report_{year}_{month}.log').' WHERE `name` = "cron_savepath"');
53 - }
54 - }
55 -
56 - private function updateFor610(): void
57 - {
58 - if ($this->isPreviousVersionAtLeast('6.1.0')) {
59 - return;
60 - }
61 -
62 - $this->updateQuery('DROP TABLE IF EXISTS `#__acym_automation_has_step`, `#__acym_step`, `#__acym_automation`');
63 - $this->updateQuery(
64 - 'CREATE TABLE IF NOT EXISTS `#__acym_automation` (
65 - `id` INT NOT NULL AUTO_INCREMENT,
66 - `name` VARCHAR(255) NOT NULL,
67 - `description` LONGTEXT NULL,
68 - `active` TINYINT(3) NOT NULL,
69 - `report` TEXT NULL,
70 - `tree` LONGTEXT NULL,
71 - PRIMARY KEY (`id`)
72 - )
73 - ENGINE = InnoDB;'
74 - );
75 - $this->updateQuery(
76 - 'CREATE TABLE IF NOT EXISTS `#__acym_step` (
77 - `id` INT NOT NULL AUTO_INCREMENT,
78 - `name` VARCHAR(255) NOT NULL,
79 - `triggers` LONGTEXT NULL,
80 - `automation_id` INT NOT NULL,
81 - `last_execution` INT NULL,
82 - `next_execution` INT NULL,
83 - PRIMARY KEY (`id`),
84 - CONSTRAINT `fk#__acym__step1`
85 - FOREIGN KEY(`automation_id`)
86 - REFERENCES `#__acym_automation` (`id`)
87 - ON DELETE NO ACTION
88 - ON UPDATE NO ACTION
89 - )
90 - ENGINE = InnoDB;'
91 - );
92 - $this->updateQuery(
93 - 'CREATE TABLE IF NOT EXISTS `#__acym_condition` (
94 - `id` INT NOT NULL AUTO_INCREMENT,
95 - `step_id` INT NOT NULL,
96 - `conditions` LONGTEXT NULL,
97 - PRIMARY KEY (`id`),
98 - CONSTRAINT `fk_#__acym_condition1`
99 - FOREIGN KEY (`step_id`)
100 - REFERENCES `#__acym_step` (`id`)
101 - ON DELETE NO ACTION
102 - ON UPDATE NO ACTION
103 - )
104 - ENGINE =InnoDB;'
105 - );
106 - $this->updateQuery(
107 - 'CREATE TABLE IF NOT EXISTS `#__acym_action` (
108 - `id` INT NOT NULL AUTO_INCREMENT,
109 - `condition_id` INT NOT NULL,
110 - `actions` LONGTEXT NULL,
111 - `filters` LONGTEXT NULL,
112 - `order` INT NOT NULL,
113 - PRIMARY KEY (`id`),
114 - CONSTRAINT `fk_#__acym_action1`
115 - FOREIGN KEY (`condition_id`)
116 - REFERENCES `#__acym_condition` (`id`)
117 - ON DELETE NO ACTION
118 - ON UPDATE NO ACTION
119 - )
120 - ENGINE =InnoDB;'
121 - );
122 -
123 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `automation` VARCHAR(50) NOT NULL');
124 -
125 - $query = 'SELECT field.type AS type, userfield.user_id AS user_id, userfield.field_id AS field_id, userfield.value AS user_value
126 - FROM #__acym_user_has_field AS userfield
127 - JOIN #__acym_field AS field ON userfield.field_id = field.id
128 - WHERE field.type IN ("checkbox", "multiple_dropdown")';
129 - $fieldValues = acym_loadObjectList($query);
130 - foreach ($fieldValues as $fieldValue) {
131 - $value = [];
132 - if ('checkbox' === $fieldValue->type) {
133 - $value = json_decode($fieldValue->user_value, true);
134 - $value = array_keys($value);
135 - } elseif ('multiple_dropdown' === $fieldValue->type) {
136 - $value = json_decode($fieldValue->user_value, true);
137 - }
138 - $value = implode(',', $value);
139 - $this->updateQuery(
140 - 'UPDATE #__acym_user_has_field
141 - SET `value` = '.acym_escapeDB($value).'
142 - WHERE user_id = '.intval($fieldValue->user_id).'
143 - AND field_id = '.intval($fieldValue->field_id)
144 - );
145 - }
146 - }
147 -
148 - private function updateFor612(): void
149 - {
150 - if ($this->isPreviousVersionAtLeast('6.1.2')) {
151 - return;
152 - }
153 -
154 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `media_folder` VARCHAR(255) NULL');
155 - $this->updateQuery('ALTER TABLE #__acym_field ADD `namekey` VARCHAR(255) NOT NULL');
156 -
157 - $query = 'SELECT field.type AS type, userfield.user_id AS user_id, userfield.field_id AS field_id, userfield.value AS user_value
158 - FROM #__acym_user_has_field AS userfield
159 - JOIN #__acym_field AS field ON userfield.field_id = field.id
160 - WHERE field.type IN ("phone")';
161 - $fieldValues = acym_loadObjectList($query);
162 -
163 - if (!empty($fieldValues)) {
164 - foreach ($fieldValues as $fieldValue) {
165 - $value = json_decode($fieldValue->user_value, true);
166 - $value = implode(',', $value);
167 - $this->updateQuery(
168 - 'UPDATE #__acym_user_has_field
169 - SET `value` = '.acym_escapeDB($value).'
170 - WHERE user_id = '.intval($fieldValue->user_id).'
171 - AND field_id = '.intval($fieldValue->field_id)
172 - );
173 - }
174 - }
175 -
176 - $fieldClass = new FieldClass();
177 - $fields = acym_loadObjectList('SELECT * FROM #__acym_field');
178 - foreach ($fields as $field) {
179 - if (!empty($field->namekey)) continue;
180 - $field->namekey = $fieldClass->generateNamekey($field->name);
181 - $fieldClass->save($field);
182 - }
183 - }
184 -
185 - private function updateFor613(): void
186 - {
187 - if ($this->isPreviousVersionAtLeast('6.1.3')) {
188 - return;
189 - }
190 -
191 - $this->updateQuery('UPDATE #__acym_user_has_list SET `status` = 1 WHERE `status` = 2');
192 - }
193 -
194 - private function updateFor614(): void
195 - {
196 - if ($this->isPreviousVersionAtLeast('6.1.4')) {
197 - return;
198 - }
199 -
200 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `headers` TEXT NULL');
201 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `autosave` LONGTEXT NULL');
202 -
203 - $columns = acym_getColumns('condition');
204 - if (!in_array('conditions', $columns)) {
205 - $this->updateQuery('ALTER TABLE #__acym_condition CHANGE `condition` `conditions` LONGTEXT NULL');
206 - }
207 -
208 - $this->updateQuery('ALTER TABLE #__acym_automation ADD `admin` TINYINT(3) NULL');
209 - }
210 -
211 - private function updateFor615(ConfigurationClass $config): void
212 - {
213 - if ($this->isPreviousVersionAtLeast('6.1.5')) {
214 - return;
215 - }
216 -
217 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `preheader` VARCHAR(255) NULL');
218 -
219 - $wrongRuleAddresses = acym_loadObjectList('SELECT `id`, `action_message` FROM `#__acym_rule` WHERE `action_message` LIKE "%\"forward_to\":\"\'%"');
220 - if (!empty($wrongRuleAddresses)) {
221 - foreach ($wrongRuleAddresses as $oneRule) {
222 - $actions = json_decode($oneRule->action_message, true);
223 - $actions['forward_to'] = trim($actions['forward_to'], "'");
224 - $this->updateQuery('UPDATE `#__acym_rule` SET `action_message` = '.acym_escapeDB(json_encode($actions)).' WHERE `id` = '.intval($oneRule->id));
225 - }
226 - }
227 -
228 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
229 - if (!empty($socialIcons['google'])) {
230 - unset($socialIcons['google']);
231 -
232 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
233 - }
234 -
235 - $mailsWithGoogle = acym_loadObjectList('SELECT `id`, `body` FROM `#__acym_mail` WHERE `body` LIKE "%googleplus%"');
236 - foreach ($mailsWithGoogle as $oneMail) {
237 - $body = preg_replace('#<a [^>]*googleplus[^>]*>[^<]*<img [^>]*>[^<]*</a>#Uis', '', $oneMail->body);
238 - if (empty($body)) continue;
239 -
240 - $this->updateQuery('UPDATE `#__acym_mail` SET `body` = '.acym_escapeDB($body).' WHERE `id` = '.intval($oneMail->id));
241 - }
242 -
243 - $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_date` DATETIME DEFAULT NULL');
244 - $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_ip` VARCHAR(16) DEFAULT NULL');
245 -
246 - $mails = acym_loadObjectList('SELECT subject, id FROM #__acym_mail');
247 - $mailClass = new MailClass();
248 - $mails = $mailClass->encode($mails);
249 -
250 - foreach ($mails as $oneMail) {
251 - $this->updateQuery('UPDATE #__acym_mail SET `subject` = '.acym_escapeDB($oneMail->subject).' WHERE `id` = '.intval($oneMail->id));
252 - }
253 - }
254 -
255 - private function updateFor616(): void
256 - {
257 - if ($this->isPreviousVersionAtLeast('6.1.6')) {
258 - return;
259 - }
260 -
261 - $mails = acym_loadObjectList('SELECT `id`, `name`, `body`, `autosave`, `preheader` FROM #__acym_mail');
262 - $mailClass = new MailClass();
263 - $mails = $mailClass->encode($mails);
264 -
265 - foreach ($mails as $oneMail) {
266 - $this->updateQuery(
267 - 'UPDATE #__acym_mail SET `body` = '.acym_escapeDB($oneMail->body).', `autosave` = '.acym_escapeDB($oneMail->autosave).', `name` = '.acym_escapeDB(
268 - $oneMail->name
269 - ).', `preheader` = '.acym_escapeDB($oneMail->preheader).' WHERE `id` = '.intval($oneMail->id)
270 - );
271 - }
272 - }
273 -
274 - private function updateFor617(): void
275 - {
276 - if ($this->isPreviousVersionAtLeast('6.1.7')) {
277 - return;
278 - }
279 -
280 - $actionClass = new ActionClass();
281 - $actions = $actionClass->getAll();
282 - foreach ($actions as $action) {
283 - $action->actions = str_replace('{time}', '[time]', $action->actions);
284 - $action->filters = str_replace('{time}', '[time]', $action->filters);
285 - $actionClass->save($action);
286 - }
287 -
288 - $conditionClass = new ConditionClass();
289 - $conditions = $conditionClass->getAll();
290 - foreach ($conditions as $condition) {
291 - $condition->conditions = str_replace('{time}', '[time]', $condition->conditions);
292 - $conditionClass->save($condition);
293 - }
294 - }
295 -
296 - private function updateFor622(ConfigurationClass $config): void
297 - {
298 - if ($this->isPreviousVersionAtLeast('6.2.2')) {
299 - return;
300 - }
301 -
302 - $allowedExtensions = explode(',', $config->get('allowed_files'));
303 - if (!empty($allowedExtensions)) {
304 - $uploadFolder = trim(acym_cleanPath(html_entity_decode(ACYM_UPLOAD_FOLDER)), DS.' ').DS;
305 - $uploadPath = acym_cleanPath(ACYM_ROOT.$uploadFolder.'userfiles'.DS);
306 -
307 - if (file_exists($uploadPath)) {
308 - $files = acym_getFiles($uploadPath);
309 - if (!empty($files)) {
310 - foreach ($files as $fileName) {
311 - if (!preg_match('#\.('.implode('|', $allowedExtensions).')$#Ui', $fileName)) {
312 - acym_deleteFile($uploadPath.DS.$fileName);
313 - }
314 - }
315 - }
316 - }
317 - }
318 - }
319 -
320 - private function updateFor640(): void
321 - {
322 - if ($this->isPreviousVersionAtLeast('6.4.0')) {
323 - return;
324 - }
325 -
326 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `sending_type` VARCHAR(16) DEFAULT NULL');
327 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `sending_params` TEXT DEFAULT NULL');
328 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `parent_id` INT DEFAULT NULL');
329 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `last_trigger` INT DEFAULT NULL');
330 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `next_trigger` INT DEFAULT NULL');
331 -
332 - $this->updateQuery('UPDATE #__acym_campaign SET `sending_type` = "now" WHERE `scheduled` = 0');
333 - $this->updateQuery('UPDATE #__acym_campaign SET `sending_type` = "scheduled" WHERE `scheduled` = 1');
334 - $this->updateQuery('UPDATE #__acym_campaign SET `sending_params` = "[]"');
335 -
336 - $this->updateQuery('ALTER TABLE #__acym_campaign DROP `scheduled`');
337 - }
338 -
339 - private function updateFor650(): void
340 - {
341 - if ($this->isPreviousVersionAtLeast('6.5.0')) {
342 - return;
343 - }
344 -
345 - $this->updateQuery(
346 - 'CREATE TABLE IF NOT EXISTS `#__acym_plugin` (
347 - `id` INT NOT NULL AUTO_INCREMENT,
348 - `title` VARCHAR (100) NOT NULL,
349 - `folder_name` VARCHAR(100) NOT NULL,
350 - `version` VARCHAR (10) NULL,
351 - `active` INT NOT NULL,
352 - `category` VARCHAR (100) NOT NULL,
353 - `level` VARCHAR (50) NOT NULL,
354 - `uptodate` INT NOT NULL,
355 - `features` VARCHAR (255) NOT NULL,
356 - `description` LONGTEXT NOT NULL,
357 - `latest_version` VARCHAR (255) NOT NULL,
358 - PRIMARY KEY (`id`)
359 - )
360 - ENGINE = InnoDB;'
361 - );
362 -
363 - $pluginsBefore650 = [
364 - 'joomla' => [
365 - 'cbuilder' => 'com_comprofiler',
366 - 'eventbooking' => 'com_eventbooking',
367 - 'hikashop' => 'com_hikashop',
368 - 'jevents' => 'com_jevents',
369 - 'payplans' => 'com_payplans',
370 - 'seblod' => 'com_cck',
371 - 'virtuemart' => 'com_virtuemart',
372 - ],
373 - 'wordpress' => [
374 - 'woocommerce' => 'woocommerce',
375 - ],
376 - ];
377 -
378 - $pluginsController = new PluginsController();
379 - foreach ($pluginsBefore650[ACYM_CMS] as $plugin => $extension) {
380 - $install = false;
381 - if (defined('JPATH_ADMINISTRATOR') && file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.$extension.DS)) {
382 - $install = true;
383 - }
384 -
385 - if (defined('WP_PLUGIN_DIR') && file_exists(rtrim(WP_PLUGIN_DIR, DS).DS.$extension.DS)) {
386 - $install = true;
387 - }
388 -
389 - if ($install) {
390 - $error = $pluginsController->download(false, $plugin);
391 - if (!empty($error)) {
392 - acym_enqueueMessage($error, 'error');
393 - }
394 - }
395 - }
396 - $this->updateQuery('ALTER TABLE #__acym_campaign CHANGE `last_trigger` `last_generated` INT DEFAULT NULL');
397 - }
398 -
399 - private function updateFor660(): void
400 - {
401 - if ($this->isPreviousVersionAtLeast('6.6.0')) {
402 - return;
403 - }
404 -
405 - $mailClass = new MailClass();
406 - $firstEmail = $mailClass->getOneByName(acym_translation(UpdateHelper::FIRST_EMAIL_NAME_KEY));
407 - if (!empty($firstEmail)) {
408 - $firstEmail->body = preg_replace(
409 - '#(<em class="acym_remove_dynamic acymicon-close">)(</em>)#Uis',
410 - '$1&zwj;$2',
411 - $firstEmail->body
412 - );
413 -
414 -
415 -
416 - $closing = '<em class="acym_remove_dynamic acymicon-close">&zwj;</em>';
417 -
418 - $firstEmail->body = preg_replace(
419 - '#(<span[^>]+data\-dynamic="{readonline}.+<span class="acym_online">[^<]+</span>[^<]*</a>[^<]*)(</span>)#Uis',
420 - '$1'.$closing.'$2',
421 - $firstEmail->body
422 - );
423 -
424 - $firstEmail->body = preg_replace(
425 - '#(<span[^>]+data\-dynamic="{subscriber:name[^>]+>[^<]+)(</span>)#Uis',
426 - '$1'.$closing.'$2',
427 - $firstEmail->body
428 - );
429 -
430 - $firstEmail->body = preg_replace(
431 - '#(<span[^>]+data\-dynamic="{unsubscribe}.+<span class="acym_unsubscribe">[^<]+</span>[^<]*</a>[^<]*)(</span>)#Uis',
432 - '$1'.$closing.'$2',
433 - $firstEmail->body
434 - );
435 -
436 - $mailClass->save($firstEmail);
437 - }
438 -
439 - $joomlaPluginsBefore650 = [
440 - 'cbuilder',
441 - 'eventbooking',
442 - 'hikashop',
443 - 'jevents',
444 - 'payplans',
445 - 'seblod',
446 - 'virtuemart',
447 - ];
448 -
449 - $installedAddons = acym_loadResultArray('SELECT folder_name FROM #__acym_plugin');
450 -
451 - foreach ($joomlaPluginsBefore650 as $folderName) {
452 - if (in_array($folderName, $installedAddons) || !file_exists(ACYM_ADDONS_FOLDER_PATH.$folderName)) continue;
453 -
454 - acym_deleteFolder(ACYM_ADDONS_FOLDER_PATH.$folderName);
455 - }
456 - }
457 -
458 - private function updateFor670(): void
459 - {
460 - if ($this->isPreviousVersionAtLeast('6.7.0')) {
461 - return;
462 - }
463 -
464 - $this->updateQuery('DELETE FROM #__acym_configuration WHERE `name` = "small_display"');
465 - $this->updateQuery('UPDATE #__acym_configuration SET `value` = REPLACE(REPLACE(`value`, ",", "comma"), ";", "semicol") WHERE `name` = "export_separator"');
466 - $this->updateQuery('ALTER TABLE #__acym_field DROP COLUMN frontend_form');
467 - $this->updateQuery('ALTER TABLE #__acym_field CHANGE `frontend_profile` `frontend_edition` TINYINT(3) NULL');
468 - $this->updateQuery('ALTER TABLE #__acym_field CHANGE `backend_profile` `backend_edition` TINYINT(3) NULL');
469 - $this->updateQuery('ALTER TABLE #__acym_list ADD COLUMN `front_management` INT NULL');
470 - }
471 -
472 - private function updateFor692(): void
473 - {
474 - if ($this->isPreviousVersionAtLeast('6.9.2')) {
475 - return;
476 - }
477 -
478 - $socialFilesFolder = ACYM_ROOT.ACYM_UPLOAD_FOLDER.'socials';
479 - if (file_exists($socialFilesFolder)) {
480 - $uploadedFiles = acym_getFiles($socialFilesFolder);
481 - foreach ($uploadedFiles as $oneFile) {
482 - $extension = acym_fileGetExt($oneFile);
483 - if (!in_array($extension, acym_getImageFileExtensions())) {
484 - acym_deleteFile($socialFilesFolder.DS.$oneFile);
485 - }
486 - }
487 - }
488 - }
489 -
490 - private function updateFor6100(): void
491 - {
492 - if ($this->isPreviousVersionAtLeast('6.10.0')) {
493 - return;
494 - }
495 -
496 - $mailClass = new MailClass();
497 - $fieldColumns = acym_getColumns('field');
498 - if (in_array('backend_filter', $fieldColumns)) {
499 - $this->updateQuery('ALTER TABLE #__acym_field DROP COLUMN backend_filter');
500 - }
501 - if (in_array('frontend_filter', $fieldColumns)) {
502 - $this->updateQuery('ALTER TABLE #__acym_field DROP COLUMN frontend_filter');
503 - }
504 - $mails = acym_loadObjectList('SELECT * FROM #__acym_mail WHERE thumbnail LIKE "%data:image/png;base64%"');
505 - foreach ($mails as $mail) {
506 - unset($mail->thumbnail);
507 - $mailClass->save($mail);
508 - }
509 -
510 - $this->updateQuery('DELETE FROM #__acym_user_has_field WHERE `value` = ""');
511 -
512 - $phoneFields = acym_loadResultArray('SELECT `id` FROM #__acym_field WHERE `type` = "phone"');
513 - if (!empty($phoneFields)) {
514 - $this->updateQuery('DELETE FROM #__acym_user_has_field WHERE `value` LIKE "%," AND `field_id` IN ('.implode(', ', $phoneFields).')');
515 - }
516 - }
517 -
518 - private function updateFor6102(): void
519 - {
520 - if ($this->isPreviousVersionAtLeast('6.10.2')) {
521 - return;
522 - }
523 -
524 - $this->updateQuery('ALTER TABLE #__acym_mail ADD COLUMN `links_language` VARCHAR(10) NOT NULL DEFAULT ""');
525 - }
526 -
527 - private function updateFor6104(): void
528 - {
529 - if ($this->isPreviousVersionAtLeast('6.10.4')) {
530 - return;
531 - }
532 -
533 - $columnsUser = acym_getColumns('user');
534 - if (!empty($columnsUser)) {
535 - foreach ($columnsUser as $i => $oneColumn) {
536 - $columnsUser[$i] = acym_escapeDB($oneColumn);
537 - }
538 -
539 - $customFieldsWrongNamekey = acym_loadObjectList('SELECT * FROM #__acym_field WHERE namekey IN ('.implode(', ', $columnsUser).')');
540 - $fieldClass = new FieldClass();
541 -
542 - foreach ($customFieldsWrongNamekey as $field) {
543 - $field->namekey = $fieldClass->generateNamekey($field->name);
544 - $fieldClass->save($field);
545 - }
546 - }
547 -
548 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `type` `type` VARCHAR(30) NOT NULL');
549 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `media_folder` `media_folder` VARCHAR(100) NULL');
550 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `links_language` `links_language` VARCHAR(10) NOT NULL');
551 - }
552 -
553 - private function updateFor6110(): void
554 - {
555 - if ($this->isPreviousVersionAtLeast('6.11.0')) {
556 - return;
557 - }
558 -
559 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `access` VARCHAR(50) NOT NULL DEFAULT ""');
560 - $this->updateQuery('ALTER TABLE #__acym_list ADD `access` VARCHAR(50) NOT NULL DEFAULT ""');
561 -
562 - $sourceMap = [
563 - 'wordpress_profile' => 'WordPress user profile',
564 - 'backend_management' => 'Back-end',
565 - 'frontend_management' => 'Front-end',
566 - 'auto_on_sending' => 'When sending a test',
567 - 'menu_' => 'Menu n°',
568 - 'mod_' => 'Module n°',
569 - '_frontregister' => ' registration form',
570 - 'import_' => 'Import on ',
571 - ];
572 -
573 - foreach ($sourceMap as $oldSource => $newSource) {
574 - acym_query('UPDATE `#__acym_user` SET `source` = REPLACE(`source`, '.acym_escapeDB($oldSource).', '.acym_escapeDB($newSource).')');
575 - }
576 -
577 - $this->updateQuery('ALTER TABLE #__acym_list ADD `description` TEXT NOT NULL DEFAULT ""');
578 - }
579 -
580 - private function updateFor6120(): void
581 - {
582 - if ($this->isPreviousVersionAtLeast('6.12.0')) {
583 - return;
584 - }
585 -
586 - $this->updateQuery('ALTER TABLE #__acym_user ADD `tracking` TINYINT(1) NOT NULL DEFAULT 1');
587 - $this->updateQuery('ALTER TABLE #__acym_list ADD `tracking` TINYINT(1) NOT NULL DEFAULT 1');
588 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `tracking` TINYINT(1) NOT NULL DEFAULT 1');
589 - $this->updateQuery('ALTER TABLE #__acym_plugin ADD `settings` LONGTEXT NULL');
590 - }
591 -
592 - private function updateFor6130(): void
593 - {
594 - if ($this->isPreviousVersionAtLeast('6.13.0')) {
595 - return;
596 - }
597 -
598 - $this->updateQuery('ALTER TABLE #__acym_plugin ADD `core` TINYINT(1) NOT NULL DEFAULT 0');
599 - $this->updateQuery('ALTER TABLE #__acym_plugin CHANGE `latest_version` `latest_version` VARCHAR(10) NOT NULL');
600 - }
601 -
602 - private function updateFor6140(): void
603 - {
604 - if ($this->isPreviousVersionAtLeast('6.14.0')) {
605 - return;
606 - }
607 -
608 - $this->updateQuery(
609 - 'CREATE TABLE IF NOT EXISTS `#__acym_form` (
610 - `id` INT NOT NULL AUTO_INCREMENT,
611 - `name` VARCHAR(255) NOT NULL,
612 - `creation_date` DATETIME NOT NULL,
613 - `active` TINYINT(1) NOT NULL DEFAULT 1,
614 - `type` VARCHAR(20) NOT NULL,
615 - `lists_options` LONGTEXT,
616 - `fields_options` LONGTEXT,
617 - `style_options` LONGTEXT,
618 - `button_options` LONGTEXT,
619 - `image_options` LONGTEXT,
620 - `delay` SMALLINT(10),
621 - `pages` TEXT,
622 - PRIMARY KEY (`id`)
623 - )
624 - ENGINE = InnoDB;'
625 - );
626 -
627 - if (file_exists(ACYM_ADDONS_FOLDER_PATH.'Volumes')) {
628 - $wrongAddons = acym_getFolders(ACYM_ADDONS_FOLDER_PATH.'Volumes'.DS.'workspace'.DS.'acymailing'.DS.'addons'.DS);
629 -
630 - $pluginClass = new PluginClass();
631 - foreach ($wrongAddons as $oneGoneWrong) {
632 - $errorMessage = $pluginClass->downloadAddon($oneGoneWrong, false);
633 - if (!empty($errorMessage)) {
634 - acym_enqueueMessage($errorMessage, 'error');
635 - }
636 - }
637 -
638 - acym_deleteFolder(ACYM_ADDONS_FOLDER_PATH.'Volumes');
639 - }
640 -
641 - $this->updateQuery('ALTER TABLE #__acym_user ADD `language` VARCHAR(10) NOT NULL');
642 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `language` VARCHAR(10) NOT NULL');
643 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `parent_id` INT NULL');
644 - }
645 -
646 - private function updateFor6150(): void
647 - {
648 - if ($this->isPreviousVersionAtLeast('6.15.0')) {
649 - return;
650 - }
651 -
652 - $this->updateQuery('ALTER TABLE #__acym_user_stat ADD `tracking_sale` FLOAT NULL');
653 - $this->updateQuery('ALTER TABLE #__acym_user_stat ADD `currency` VARCHAR(10) NULL');
654 - $this->updateQuery('ALTER TABLE #__acym_campaign ADD `visible` TINYINT(1) NOT NULL DEFAULT 1');
655 - $this->updateQuery('ALTER TABLE #__acym_user CHANGE `language` `language` VARCHAR(10) NOT NULL DEFAULT ""');
656 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `language` `language` VARCHAR(10) NOT NULL DEFAULT ""');
657 - $this->updateQuery('ALTER TABLE `#__acym_mail` CHANGE `preheader` `preheader` TEXT NULL');
658 - }
659 -
660 - private function updateFor6160(): void
661 - {
662 - if ($this->isPreviousVersionAtLeast('6.16.0')) {
663 - return;
664 - }
665 -
666 - $this->updateQuery('ALTER TABLE `#__acym_mail_stat` CHANGE `bounce_unique` `bounce_unique` MEDIUMINT(8) NOT NULL DEFAULT 0');
667 - $this->updateQuery('ALTER TABLE `#__acym_user_stat` CHANGE `bounce` `bounce` TINYINT(4) NOT NULL DEFAULT 0');
668 - $this->updateQuery('ALTER TABLE #__acym_plugin ADD `type` VARCHAR(20) NOT NULL DEFAULT "ADDON"');
669 - $this->updateQuery('UPDATE `#__acym_plugin` SET `type` = "ADDON" WHERE `core` = 0');
670 - $this->updateQuery('UPDATE `#__acym_plugin` SET `type` = "CORE" WHERE `core` = 1');
671 - $this->updateQuery('ALTER TABLE #__acym_plugin DROP `core`');
672 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD termspolicy_options LONGTEXT');
673 - $this->updateQuery('UPDATE `#__acym_form` SET `termspolicy_options` = "{\"termscond\":0,\"privacy\":0}" WHERE `termspolicy_options` is NULL');
674 - }
675 -
676 - private function updateFor6170(): void
677 - {
678 - if ($this->isPreviousVersionAtLeast('6.17.0')) {
679 - return;
680 - }
681 -
682 - $this->updateQuery(
683 - 'CREATE TABLE IF NOT EXISTS `#__acym_segment` (
684 - `id` INT NOT NULL AUTO_INCREMENT,
685 - `name` VARCHAR(255) NOT NULL,
686 - `creation_date` DATETIME NOT NULL,
687 - `active` TINYINT(1) NOT NULL DEFAULT 1,
688 - `filters` LONGTEXT NULL,
689 - PRIMARY KEY (`id`)
690 - )
691 - ENGINE = InnoDB;'
692 - );
693 - $automationHelper = new AutomationHelper();
694 - $automationHelper->deleteUnusedEmails();
695 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD cookie VARCHAR(30)');
696 - $this->updateQuery('UPDATE `#__acym_form` SET `cookie` = "{\"cookie_expiration\":1}" WHERE `cookie` IS NULL');
697 - }
698 -
699 - private function updateFor6180(): void
700 - {
701 - if ($this->isPreviousVersionAtLeast('6.18.0')) {
702 - return;
703 - }
704 -
705 - $this->updateQuery(
706 - 'CREATE TABLE IF NOT EXISTS `#__acym_followup` (
707 - `id` INT NOT NULL AUTO_INCREMENT,
708 - `name` VARCHAR(255) NOT NULL,
709 - `display_name` VARCHAR(255) NOT NULL,
710 - `creation_date` DATETIME NOT NULL,
711 - `trigger` VARCHAR(50),
712 - `condition` LONGTEXT,
713 - `active` TINYINT(1) NOT NULL DEFAULT 1,
714 - `send_once` TINYINT(1) NOT NULL DEFAULT 1,
715 - `list_id` INT NULL,
716 - `last_trigger` INT NULL,
717 - PRIMARY KEY (`id`),
718 - INDEX `fk_#__acym_followup_has_list`(`list_id` ASC),
719 - CONSTRAINT `fk_#__acym_followup_has_list`
720 - FOREIGN KEY (`list_id`)
721 - REFERENCES `#__acym_list`(`id`)
722 - ON DELETE NO ACTION
723 - ON UPDATE NO ACTION
724 - )
725 - ENGINE = InnoDB;'
726 - );
727 - $this->updateQuery(
728 - 'CREATE TABLE IF NOT EXISTS `#__acym_followup_has_mail` (
729 - `mail_id` INT NOT NULL,
730 - `followup_id` INT NOT NULL,
731 - `delay` INT NOT NULL,
732 - `delay_unit` INT NOT NULL,
733 - PRIMARY KEY (`mail_id`, `followup_id`),
734 - INDEX `fk_#__acym_mail_has_followup1`(`followup_id` ASC),
735 - INDEX `fk_#__acym_mail_has_followup2`(`mail_id` ASC),
736 - CONSTRAINT `fk_#__acym_mail_has_followup1`
737 - FOREIGN KEY (`mail_id`)
738 - REFERENCES `#__acym_mail`(`id`)
739 - ON DELETE NO ACTION
740 - ON UPDATE NO ACTION,
741 - CONSTRAINT `fk_#__acym_mail_has_followup2`
742 - FOREIGN KEY (`followup_id`)
743 - REFERENCES `#__acym_followup`(`id`)
744 - ON DELETE NO ACTION
745 - ON UPDATE NO ACTION
746 - )
747 - ENGINE = InnoDB;'
748 - );
749 -
750 - $this->updateQuery('ALTER TABLE `#__acym_list` ADD `type` VARCHAR(20) NOT NULL DEFAULT '.acym_escapeDB(ListClass::LIST_TYPE_STANDARD));
751 - $this->updateQuery('UPDATE `#__acym_list` SET `type` = '.acym_escapeDB(ListClass::LIST_TYPE_FRONT).' WHERE `front_management` = 1');
752 - $this->updateQuery('ALTER TABLE `#__acym_list` DROP COLUMN front_management');
753 -
754 - $this->updateQuery(
755 - 'CREATE TABLE IF NOT EXISTS `#__acym_mail_override` (
756 - `id` INT NOT NULL AUTO_INCREMENT,
757 - `mail_id` INT NOT NULL,
758 - `description` VARCHAR(255) NOT NULL,
759 - `source` VARCHAR (20) NOT NULL,
760 - `active` TINYINT(1) NOT NULL DEFAULT 1,
761 - `base_subject` TEXT NOT NULL,
762 - `base_body` TEXT NOT NULL,
763 - PRIMARY KEY(`id`),
764 - CONSTRAINT `fk_#__acym_mail_override1`
765 - FOREIGN KEY (`mail_id`)
766 - REFERENCES `#__acym_mail`(`id`)
767 - ON DELETE NO ACTION
768 - ON UPDATE NO ACTION
769 - )
770 - ENGINE = InnoDB;'
771 - );
772 - }
773 -
774 - private function updateFor6181(): void
775 - {
776 - if ($this->isPreviousVersionAtLeast('6.18.1')) {
777 - return;
778 - }
779 -
780 - $mailClass = new MailClass();
781 - $emails = acym_loadObjectList('SELECT id, access FROM `#__acym_mail` WHERE access LIKE "%,,%" OR access LIKE "%[\"%"');
782 -
783 - foreach ($emails as $email) {
784 - if (strpos($email->access, ',,') !== false) {
785 - $access = explode(',', $email->access);
786 - } else {
787 - $access = json_decode(trim($email->access, ','));
788 - }
789 - $finalAccess = [];
790 - foreach ($access as $oneAccess) {
791 - if (!empty($oneAccess)) {
792 - $finalAccess[] = $oneAccess;
793 - }
794 - }
795 - $email->access = empty($finalAccess) ? '' : $finalAccess;
796 - $mailClass->save($email);
797 - }
798 - }
799 -
800 - private function updateFor6190(): void
801 - {
802 - if ($this->isPreviousVersionAtLeast('6.19.0')) {
803 - return;
804 - }
805 -
806 - $this->updateQuery('ALTER TABLE `#__acym_mail_stat` ADD `unsubscribe_total` INT NOT NULL DEFAULT 0');
807 - $this->updateQuery('ALTER TABLE `#__acym_user_stat` ADD `unsubscribe` INT NOT NULL DEFAULT 0');
808 - $this->updateQuery('ALTER TABLE `#__acym_user_stat` ADD `device` VARCHAR(50) NULL');
809 - $this->updateQuery('ALTER TABLE `#__acym_user_stat` ADD `opened_with` VARCHAR(50) NULL');
810 -
811 - $this->updateQuery('ALTER TABLE `#__acym_mail` CHANGE `media_folder` `mail_settings` TEXT NULL');
812 - $templatesMediaFolders = acym_loadObjectList('SELECT `id`, `mail_settings` FROM `#__acym_mail` WHERE `mail_settings` IS NOT NULL');
813 - if (!empty($templatesMediaFolders)) {
814 - foreach ($templatesMediaFolders as $oneTemplate) {
815 - $settings = [
816 - 'media_folder' => $oneTemplate->mail_settings,
817 - ];
818 - $this->updateQuery('UPDATE `#__acym_mail` SET `mail_settings` = '.acym_escapeDB(json_encode($settings)).' WHERE `id` = '.intval($oneTemplate->id));
819 - }
820 - }
821 - }
822 -}