| @@ -40,8 +40,9 @@ | ||
| 40 | 40 | $this->updateQuery('ALTER TABLE #__acym_rule CHANGE `id` `id` INT NOT NULL AUTO_INCREMENT'); |
| 41 | 41 | $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `increment_stats` TINYINT(3) NOT NULL'); |
| 42 | 42 | $this->updateQuery('ALTER TABLE #__acym_rule ADD COLUMN `execute_action_after` INT NOT NULL'); |
| 43 | 43 | |
| 44 | + // Use translation keys for name and email fields | |
| 44 | 45 | $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_NAME" WHERE `id` = 1 AND `name` = "Name"'); |
| 45 | 46 | $this->updateQuery('UPDATE #__acym_field SET `name` = "ACYM_EMAIL" WHERE `id` = 2 AND `name` = "Email"'); |
| 46 | 47 | $this->updateQuery('UPDATE #__acym_field SET `backend_profile` = 1, `backend_listing` = 1 WHERE `id` IN (1, 2)'); |
| 47 | 48 | |
| @@ -69,9 +70,10 @@ | ||
| 69 | 70 | `report` TEXT NULL, |
| 70 | 71 | `tree` LONGTEXT NULL, |
| 71 | 72 | PRIMARY KEY (`id`) |
| 72 | 73 | ) |
| 73 | - ENGINE = InnoDB;' | |
| 74 | + ENGINE = InnoDB | |
| 75 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 74 | 76 | ); |
| 75 | 77 | $this->updateQuery( |
| 76 | 78 | 'CREATE TABLE IF NOT EXISTS `#__acym_step` ( |
| 77 | 79 | `id` INT NOT NULL AUTO_INCREMENT, |
| @@ -86,9 +88,10 @@ | ||
| 86 | 88 | REFERENCES `#__acym_automation` (`id`) |
| 87 | 89 | ON DELETE NO ACTION |
| 88 | 90 | ON UPDATE NO ACTION |
| 89 | 91 | ) |
| 90 | - ENGINE = InnoDB;' | |
| 92 | + ENGINE = InnoDB | |
| 93 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 91 | 94 | ); |
| 92 | 95 | $this->updateQuery( |
| 93 | 96 | 'CREATE TABLE IF NOT EXISTS `#__acym_condition` ( |
| 94 | 97 | `id` INT NOT NULL AUTO_INCREMENT, |
| @@ -100,9 +103,10 @@ | ||
| 100 | 103 | REFERENCES `#__acym_step` (`id`) |
| 101 | 104 | ON DELETE NO ACTION |
| 102 | 105 | ON UPDATE NO ACTION |
| 103 | 106 | ) |
| 104 | - ENGINE =InnoDB;' | |
| 107 | + ENGINE =InnoDB | |
| 108 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 105 | 109 | ); |
| 106 | 110 | $this->updateQuery( |
| 107 | 111 | 'CREATE TABLE IF NOT EXISTS `#__acym_action` ( |
| 108 | 112 | `id` INT NOT NULL AUTO_INCREMENT, |
| @@ -116,9 +120,10 @@ | ||
| 116 | 120 | REFERENCES `#__acym_condition` (`id`) |
| 117 | 121 | ON DELETE NO ACTION |
| 118 | 122 | ON UPDATE NO ACTION |
| 119 | 123 | ) |
| 120 | - ENGINE =InnoDB;' | |
| 124 | + ENGINE =InnoDB | |
| 125 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 121 | 126 | ); |
| 122 | 127 | |
| 123 | 128 | $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `automation` VARCHAR(50) NOT NULL'); |
| 124 | 129 | |
| @@ -215,8 +220,9 @@ | ||
| 215 | 220 | } |
| 216 | 221 | |
| 217 | 222 | $this->updateQuery('ALTER TABLE #__acym_mail ADD `preheader` VARCHAR(255) NULL'); |
| 218 | 223 | |
| 224 | + // Fix bounce rule "blocked by recipient filters | |
| 219 | 225 | $wrongRuleAddresses = acym_loadObjectList('SELECT `id`, `action_message` FROM `#__acym_rule` WHERE `action_message` LIKE "%\"forward_to\":\"\'%"'); |
| 220 | 226 | if (!empty($wrongRuleAddresses)) { |
| 221 | 227 | foreach ($wrongRuleAddresses as $oneRule) { |
| 222 | 228 | $actions = json_decode($oneRule->action_message, true); |
| @@ -224,18 +230,17 @@ | ||
| 224 | 230 | $this->updateQuery('UPDATE `#__acym_rule` SET `action_message` = '.acym_escapeDB(json_encode($actions)).' WHERE `id` = '.intval($oneRule->id)); |
| 225 | 231 | } |
| 226 | 232 | } |
| 227 | 233 | |
| 234 | + // We remove the google+ option from the saved config | |
| 228 | 235 | $socialIcons = json_decode($config->get('social_icons', '{}'), true); |
| 229 | 236 | if (!empty($socialIcons['google'])) { |
| 230 | 237 | unset($socialIcons['google']); |
| 231 | 238 | |
| 232 | - $newConfig = new \stdClass(); | |
| 233 | - $newConfig->social_icons = json_encode($socialIcons); | |
| 234 | - $config->save($newConfig); | |
| 239 | + $config->saveConfig(['social_icons' => json_encode($socialIcons)]); | |
| 235 | 240 | } |
| 236 | 241 | |
| 237 | - | |
| 242 | + // Then remove the google+ button from the emails containing it | |
| 238 | 243 | $mailsWithGoogle = acym_loadObjectList('SELECT `id`, `body` FROM `#__acym_mail` WHERE `body` LIKE "%googleplus%"'); |
| 239 | 244 | foreach ($mailsWithGoogle as $oneMail) { |
| 240 | 245 | $body = preg_replace('#<a [^>]*googleplus[^>]*>[^<]*<img [^>]*>[^<]*</a>#Uis', '', $oneMail->body); |
| 241 | 246 | if (empty($body)) continue; |
| @@ -242,11 +247,13 @@ | ||
| 242 | 247 | |
| 243 | 248 | $this->updateQuery('UPDATE `#__acym_mail` SET `body` = '.acym_escapeDB($body).' WHERE `id` = '.intval($oneMail->id)); |
| 244 | 249 | } |
| 245 | 250 | |
| 251 | + // Add fields for confirmation | |
| 246 | 252 | $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_date` DATETIME DEFAULT NULL'); |
| 247 | 253 | $this->updateQuery('ALTER TABLE #__acym_user ADD `confirmation_ip` VARCHAR(16) DEFAULT NULL'); |
| 248 | 254 | |
| 255 | + //Handle Emoji support | |
| 249 | 256 | $mails = acym_loadObjectList('SELECT subject, id FROM #__acym_mail'); |
| 250 | 257 | $mailClass = new MailClass(); |
| 251 | 258 | $mails = $mailClass->encode($mails); |
| 252 | 259 | |
| @@ -260,8 +267,9 @@ | ||
| 260 | 267 | if ($this->isPreviousVersionAtLeast('6.1.6')) { |
| 261 | 268 | return; |
| 262 | 269 | } |
| 263 | 270 | |
| 271 | + // Handle emojis in body, name, preheader and autosave | |
| 264 | 272 | $mails = acym_loadObjectList('SELECT `id`, `name`, `body`, `autosave`, `preheader` FROM #__acym_mail'); |
| 265 | 273 | $mailClass = new MailClass(); |
| 266 | 274 | $mails = $mailClass->encode($mails); |
| 267 | 275 | |
| @@ -301,10 +309,12 @@ | ||
| 301 | 309 | if ($this->isPreviousVersionAtLeast('6.2.2')) { |
| 302 | 310 | return; |
| 303 | 311 | } |
| 304 | 312 | |
| 313 | + // Get the allowed extensions | |
| 305 | 314 | $allowedExtensions = explode(',', $config->get('allowed_files')); |
| 306 | 315 | if (!empty($allowedExtensions)) { |
| 316 | + // Get the files in the upload folder | |
| 307 | 317 | $uploadFolder = trim(acym_cleanPath(html_entity_decode(ACYM_UPLOAD_FOLDER)), DS.' ').DS; |
| 308 | 318 | $uploadPath = acym_cleanPath(ACYM_ROOT.$uploadFolder.'userfiles'.DS); |
| 309 | 319 | |
| 310 | 320 | if (file_exists($uploadPath)) { |
| @@ -309,8 +319,9 @@ | ||
| 309 | 319 | |
| 310 | 320 | if (file_exists($uploadPath)) { |
| 311 | 321 | $files = acym_getFiles($uploadPath); |
| 312 | 322 | if (!empty($files)) { |
| 323 | + // Delete unallowed files | |
| 313 | 324 | foreach ($files as $fileName) { |
| 314 | 325 | if (!preg_match('#\.('.implode('|', $allowedExtensions).')$#Ui', $fileName)) { |
| 315 | 326 | acym_deleteFile($uploadPath.DS.$fileName); |
| 316 | 327 | } |
| @@ -325,8 +336,9 @@ | ||
| 325 | 336 | if ($this->isPreviousVersionAtLeast('6.4.0')) { |
| 326 | 337 | return; |
| 327 | 338 | } |
| 328 | 339 | |
| 340 | + //we add new columns | |
| 329 | 341 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `sending_type` VARCHAR(16) DEFAULT NULL'); |
| 330 | 342 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `sending_params` TEXT DEFAULT NULL'); |
| 331 | 343 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `parent_id` INT DEFAULT NULL'); |
| 332 | 344 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `last_trigger` INT DEFAULT NULL'); |
| @@ -331,12 +343,15 @@ | ||
| 331 | 343 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `parent_id` INT DEFAULT NULL'); |
| 332 | 344 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `last_trigger` INT DEFAULT NULL'); |
| 333 | 345 | $this->updateQuery('ALTER TABLE #__acym_campaign ADD `next_trigger` INT DEFAULT NULL'); |
| 334 | 346 | |
| 347 | + //we fill the column sending_type | |
| 335 | 348 | $this->updateQuery('UPDATE #__acym_campaign SET `sending_type` = "now" WHERE `scheduled` = 0'); |
| 336 | 349 | $this->updateQuery('UPDATE #__acym_campaign SET `sending_type` = "scheduled" WHERE `scheduled` = 1'); |
| 350 | + //I do this because if we do that 'ALTER TABLE #__acym_campaign ADD `sending_params` TEXT DEFAULT "[]"' I have a sql error can't set default value for column sending_params in joomla | |
| 337 | 351 | $this->updateQuery('UPDATE #__acym_campaign SET `sending_params` = "[]"'); |
| 338 | 352 | |
| 353 | + //we delete the column scheduled | |
| 339 | 354 | $this->updateQuery('ALTER TABLE #__acym_campaign DROP `scheduled`'); |
| 340 | 355 | } |
| 341 | 356 | |
| 342 | 357 | private function updateFor650(): void |
| @@ -359,9 +374,10 @@ | ||
| 359 | 374 | `description` LONGTEXT NOT NULL, |
| 360 | 375 | `latest_version` VARCHAR (255) NOT NULL, |
| 361 | 376 | PRIMARY KEY (`id`) |
| 362 | 377 | ) |
| 363 | - ENGINE = InnoDB;' | |
| 378 | + ENGINE = InnoDB | |
| 379 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 364 | 380 | ); |
| 365 | 381 | |
| 366 | 382 | $pluginsBefore650 = [ |
| 367 | 383 | 'joomla' => [ |
| @@ -407,8 +423,9 @@ | ||
| 407 | 423 | |
| 408 | 424 | $mailClass = new MailClass(); |
| 409 | 425 | $firstEmail = $mailClass->getOneByName(acym_translation(UpdateHelper::FIRST_EMAIL_NAME_KEY)); |
| 410 | 426 | if (!empty($firstEmail)) { |
| 427 | + // If the user installed AcyMailing but didn't save the first template, we just complete the <em> | |
| 411 | 428 | $firstEmail->body = preg_replace( |
| 412 | 429 | '#(<em class="acym_remove_dynamic acymicon-close">)(</em>)#Uis', |
| 413 | 430 | '$1‍$2', |
| 414 | 431 | $firstEmail->body |
| @@ -414,11 +431,13 @@ | ||
| 414 | 431 | $firstEmail->body |
| 415 | 432 | ); |
| 416 | 433 | |
| 417 | 434 | |
| 435 | + // If he saved the first template, it has completely removed the dtext closing <em> | |
| 418 | 436 | |
| 419 | 437 | $closing = '<em class="acym_remove_dynamic acymicon-close">‍</em>'; |
| 420 | 438 | |
| 439 | + // 1 - the view it online | |
| 421 | 440 | $firstEmail->body = preg_replace( |
| 422 | 441 | '#(<span[^>]+data\-dynamic="{readonline}.+<span class="acym_online">[^<]+</span>[^<]*</a>[^<]*)(</span>)#Uis', |
| 423 | 442 | '$1'.$closing.'$2', |
| 424 | 443 | $firstEmail->body |
| @@ -423,8 +442,9 @@ | ||
| 423 | 442 | '$1'.$closing.'$2', |
| 424 | 443 | $firstEmail->body |
| 425 | 444 | ); |
| 426 | 445 | |
| 446 | + // 2 - the user first name | |
| 427 | 447 | $firstEmail->body = preg_replace( |
| 428 | 448 | '#(<span[^>]+data\-dynamic="{subscriber:name[^>]+>[^<]+)(</span>)#Uis', |
| 429 | 449 | '$1'.$closing.'$2', |
| 430 | 450 | $firstEmail->body |
| @@ -429,8 +449,9 @@ | ||
| 429 | 449 | '$1'.$closing.'$2', |
| 430 | 450 | $firstEmail->body |
| 431 | 451 | ); |
| 432 | 452 | |
| 453 | + // 3 - the unsubscribe link | |
| 433 | 454 | $firstEmail->body = preg_replace( |
| 434 | 455 | '#(<span[^>]+data\-dynamic="{unsubscribe}.+<span class="acym_unsubscribe">[^<]+</span>[^<]*</a>[^<]*)(</span>)#Uis', |
| 435 | 456 | '$1'.$closing.'$2', |
| 436 | 457 | $firstEmail->body |
| @@ -451,10 +472,12 @@ | ||
| 451 | 472 | |
| 452 | 473 | $installedAddons = acym_loadResultArray('SELECT folder_name FROM #__acym_plugin'); |
| 453 | 474 | |
| 454 | 475 | foreach ($joomlaPluginsBefore650 as $folderName) { |
| 476 | + // The add-on is installed, there's nothing to do | |
| 455 | 477 | if (in_array($folderName, $installedAddons) || !file_exists(ACYM_ADDONS_FOLDER_PATH.$folderName)) continue; |
| 456 | 478 | |
| 479 | + // The add-on is installed but not in the DB, this is an old version that hasn't been removed | |
| 457 | 480 | acym_deleteFolder(ACYM_ADDONS_FOLDER_PATH.$folderName); |
| 458 | 481 | } |
| 459 | 482 | } |
| 460 | 483 | |
| @@ -513,8 +536,9 @@ | ||
| 513 | 536 | $this->updateQuery('DELETE FROM #__acym_user_has_field WHERE `value` = ""'); |
| 514 | 537 | |
| 515 | 538 | $phoneFields = acym_loadResultArray('SELECT `id` FROM #__acym_field WHERE `type` = "phone"'); |
| 516 | 539 | if (!empty($phoneFields)) { |
| 540 | + acym_arrayToInteger($phoneFields); | |
| 517 | 541 | $this->updateQuery('DELETE FROM #__acym_user_has_field WHERE `value` LIKE "%," AND `field_id` IN ('.implode(', ', $phoneFields).')'); |
| 518 | 542 | } |
| 519 | 543 | } |
| 520 | 544 | |
| @@ -623,17 +647,22 @@ | ||
| 623 | 647 | `delay` SMALLINT(10), |
| 624 | 648 | `pages` TEXT, |
| 625 | 649 | PRIMARY KEY (`id`) |
| 626 | 650 | ) |
| 627 | - ENGINE = InnoDB;' | |
| 651 | + ENGINE = InnoDB | |
| 652 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 628 | 653 | ); |
| 629 | 654 | |
| 655 | + // In a release, all the content insertion addons had the structure Volumes/workspace/acymailing/addons/folder_name/plugin.php instead of just folder_name/plugin.php | |
| 630 | 656 | if (file_exists(ACYM_ADDONS_FOLDER_PATH.'Volumes')) { |
| 631 | 657 | $wrongAddons = acym_getFolders(ACYM_ADDONS_FOLDER_PATH.'Volumes'.DS.'workspace'.DS.'acymailing'.DS.'addons'.DS); |
| 632 | 658 | |
| 633 | 659 | $pluginClass = new PluginClass(); |
| 634 | 660 | foreach ($wrongAddons as $oneGoneWrong) { |
| 635 | - $pluginClass->downloadAddon($oneGoneWrong, false); | |
| 661 | + $errorMessage = $pluginClass->downloadAddon($oneGoneWrong, false); | |
| 662 | + if (!empty($errorMessage)) { | |
| 663 | + acym_enqueueMessage($errorMessage, 'error'); | |
| 664 | + } | |
| 636 | 665 | } |
| 637 | 666 | |
| 638 | 667 | acym_deleteFolder(ACYM_ADDONS_FOLDER_PATH.'Volumes'); |
| 639 | 668 | } |
| @@ -687,9 +716,10 @@ | ||
| 687 | 716 | `active` TINYINT(1) NOT NULL DEFAULT 1, |
| 688 | 717 | `filters` LONGTEXT NULL, |
| 689 | 718 | PRIMARY KEY (`id`) |
| 690 | 719 | ) |
| 691 | - ENGINE = InnoDB;' | |
| 720 | + ENGINE = InnoDB | |
| 721 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 692 | 722 | ); |
| 693 | 723 | $automationHelper = new AutomationHelper(); |
| 694 | 724 | $automationHelper->deleteUnusedEmails(); |
| 695 | 725 | $this->updateQuery('ALTER TABLE `#__acym_form` ADD cookie VARCHAR(30)'); |
| @@ -721,9 +751,10 @@ | ||
| 721 | 751 | REFERENCES `#__acym_list`(`id`) |
| 722 | 752 | ON DELETE NO ACTION |
| 723 | 753 | ON UPDATE NO ACTION |
| 724 | 754 | ) |
| 725 | - ENGINE = InnoDB;' | |
| 755 | + ENGINE = InnoDB | |
| 756 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 726 | 757 | ); |
| 727 | 758 | $this->updateQuery( |
| 728 | 759 | 'CREATE TABLE IF NOT EXISTS `#__acym_followup_has_mail` ( |
| 729 | 760 | `mail_id` INT NOT NULL, |
| @@ -743,9 +774,10 @@ | ||
| 743 | 774 | REFERENCES `#__acym_followup`(`id`) |
| 744 | 775 | ON DELETE NO ACTION |
| 745 | 776 | ON UPDATE NO ACTION |
| 746 | 777 | ) |
| 747 | - ENGINE = InnoDB;' | |
| 778 | + ENGINE = InnoDB | |
| 779 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 748 | 780 | ); |
| 749 | 781 | |
| 750 | 782 | $this->updateQuery('ALTER TABLE `#__acym_list` ADD `type` VARCHAR(20) NOT NULL DEFAULT '.acym_escapeDB(ListClass::LIST_TYPE_STANDARD)); |
| 751 | 783 | $this->updateQuery('UPDATE `#__acym_list` SET `type` = '.acym_escapeDB(ListClass::LIST_TYPE_FRONT).' WHERE `front_management` = 1'); |
| @@ -766,9 +798,10 @@ | ||
| 766 | 798 | REFERENCES `#__acym_mail`(`id`) |
| 767 | 799 | ON DELETE NO ACTION |
| 768 | 800 | ON UPDATE NO ACTION |
| 769 | 801 | ) |
| 770 | - ENGINE = InnoDB;' | |
| 802 | + ENGINE = InnoDB | |
| 803 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 771 | 804 | ); |
| 772 | 805 | } |
| 773 | 806 | |
| 774 | 807 | private function updateFor6181(): void |