| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace AcyMailing\Helpers\Update; |
| 4 | 4 | |
| 5 | +use AcyMailing\Classes\ConfigurationClass; | |
| 5 | 6 | use AcyMailing\Classes\FormClass; |
| 6 | 7 | use AcyMailing\Classes\MailClass; |
| 7 | 8 | use AcyMailing\Classes\RuleClass; |
| 8 | 9 | |
| @@ -7,17 +8,14 @@ | ||
| 7 | 8 | use AcyMailing\Classes\RuleClass; |
| 8 | 9 | |
| 9 | 10 | trait Patchv8 |
| 10 | 11 | { |
| 11 | - private function updateFor800($config) | |
| 12 | + private function updateFor800(): void | |
| 12 | 13 | { |
| 13 | 14 | if ($this->isPreviousVersionAtLeast('8.0.0')) { |
| 14 | 15 | return; |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | - $secretKey = $config->get('smtp_secret'); | |
| 18 | - $config->save(['smtp_type' => empty($secretKey) ? 'password' : 'oauth']); | |
| 19 | - | |
| 20 | 18 | $this->updateQuery( |
| 21 | 19 | 'CREATE TABLE IF NOT EXISTS `#__acym_mailbox_action` ( |
| 22 | 20 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 23 | 21 | `name` varchar(255) DEFAULT NULL, |
| @@ -40,13 +38,14 @@ | ||
| 40 | 38 | `active` tinyint(4) NOT NULL DEFAULT 0, |
| 41 | 39 | PRIMARY KEY (`id`), |
| 42 | 40 | INDEX `index_#__acym_mailbox_action1`(`name` ASC) |
| 43 | 41 | ) |
| 44 | - ENGINE = InnoDB;' | |
| 42 | + ENGINE = InnoDB | |
| 43 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 45 | 44 | ); |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | - private function updateFor810() | |
| 47 | + private function updateFor810(): void | |
| 49 | 48 | { |
| 50 | 49 | if ($this->isPreviousVersionAtLeast('8.1.0')) { |
| 51 | 50 | return; |
| 52 | 51 | } |
| @@ -89,9 +88,9 @@ | ||
| 89 | 88 | |
| 90 | 89 | $this->updateQuery('ALTER TABLE `#__acym_user` CHANGE `key` `key` VARCHAR(40) NULL'); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | - private function updateFor811() | |
| 92 | + private function updateFor811(): void | |
| 94 | 93 | { |
| 95 | 94 | if ($this->isPreviousVersionAtLeast('8.1.1')) { |
| 96 | 95 | return; |
| 97 | 96 | } |
| @@ -107,9 +106,9 @@ | ||
| 107 | 106 | $formClass->save($oneForm); |
| 108 | 107 | } |
| 109 | 108 | } |
| 110 | 109 | |
| 111 | - private function updateFor850() | |
| 110 | + private function updateFor850(): void | |
| 112 | 111 | { |
| 113 | 112 | if ($this->isPreviousVersionAtLeast('8.5.0')) { |
| 114 | 113 | return; |
| 115 | 114 | } |
| @@ -148,9 +147,9 @@ | ||
| 148 | 147 | $groupsAuthorized[] = $group; |
| 149 | 148 | } |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | - $config->save(['acl_'.$page => implode(',', $groupsAuthorized)]); | |
| 151 | + $config->saveConfig(['acl_'.$page => implode(',', $groupsAuthorized)]); | |
| 153 | 152 | } |
| 154 | 153 | |
| 155 | 154 | $queries = file_get_contents(ACYM_BACK.'tables.sql'); |
| 156 | 155 | $tables = explode('CREATE TABLE IF NOT EXISTS ', $queries); |
| @@ -221,9 +220,9 @@ | ||
| 221 | 220 | } |
| 222 | 221 | } |
| 223 | 222 | } |
| 224 | 223 | |
| 225 | - private function updateFor860() | |
| 224 | + private function updateFor860(): void | |
| 226 | 225 | { |
| 227 | 226 | if ($this->isPreviousVersionAtLeast('8.6.0')) { |
| 228 | 227 | return; |
| 229 | 228 | } |
| @@ -274,13 +273,14 @@ | ||
| 274 | 273 | REFERENCES `#__acym_mail`(`id`) |
| 275 | 274 | ON DELETE NO ACTION |
| 276 | 275 | ON UPDATE NO ACTION |
| 277 | 276 | ) |
| 278 | - ENGINE = InnoDB;' | |
| 277 | + ENGINE = InnoDB | |
| 278 | + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;' | |
| 279 | 279 | ); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - private function updateFor862() | |
| 282 | + private function updateFor862(): void | |
| 283 | 283 | { |
| 284 | 284 | if ($this->isPreviousVersionAtLeast('8.6.2')) { |
| 285 | 285 | return; |
| 286 | 286 | } |
| @@ -297,8 +297,9 @@ | ||
| 297 | 297 | AND mail.type = '.acym_escapeDB(MailClass::TYPE_STANDARD) |
| 298 | 298 | ); |
| 299 | 299 | |
| 300 | 300 | if (!empty($mailsToClean)) { |
| 301 | + acym_arrayToInteger($mailsToClean); | |
| 301 | 302 | $this->updateQuery('DELETE FROM #__acym_mail_archive WHERE mail_id IN ('.implode(',', $mailsToClean).')'); |
| 302 | 303 | $mailClass = new MailClass(); |
| 303 | 304 | $mailClass->delete($mailsToClean); |
| 304 | 305 | } |
| @@ -303,9 +304,9 @@ | ||
| 303 | 304 | $mailClass->delete($mailsToClean); |
| 304 | 305 | } |
| 305 | 306 | } |
| 306 | 307 | |
| 307 | - private function updateFor870() | |
| 308 | + private function updateFor870(): void | |
| 308 | 309 | { |
| 309 | 310 | if ($this->isPreviousVersionAtLeast('8.7.0')) { |
| 310 | 311 | return; |
| 311 | 312 | } |
| @@ -312,9 +313,9 @@ | ||
| 312 | 313 | |
| 313 | 314 | $this->updateQuery('ALTER TABLE #__acym_plugin DROP `features`'); |
| 314 | 315 | } |
| 315 | 316 | |
| 316 | - private function updateFor872($config) | |
| 317 | + private function updateFor872(ConfigurationClass $config): void | |
| 317 | 318 | { |
| 318 | 319 | if ($this->isPreviousVersionAtLeast('8.7.2')) { |
| 319 | 320 | return; |
| 320 | 321 | } |
| @@ -322,15 +323,13 @@ | ||
| 322 | 323 | $socialIcons = json_decode($config->get('social_icons', '{}'), true); |
| 323 | 324 | if (empty($socialIcons['X'])) { |
| 324 | 325 | $socialIcons['X'] = ACYM_IMAGES.'logo/x.png'; |
| 325 | 326 | |
| 326 | - $newConfig = new \stdClass(); | |
| 327 | - $newConfig->social_icons = json_encode($socialIcons); | |
| 328 | - $config->save($newConfig); | |
| 327 | + $config->saveConfig(['social_icons' => json_encode($socialIcons)]); | |
| 329 | 328 | } |
| 330 | 329 | } |
| 331 | 330 | |
| 332 | - private function updateFor873($config) | |
| 331 | + private function updateFor873(ConfigurationClass $config): void | |
| 333 | 332 | { |
| 334 | 333 | if ($this->isPreviousVersionAtLeast('8.7.3')) { |
| 335 | 334 | return; |
| 336 | 335 | } |
| @@ -336,43 +335,40 @@ | ||
| 336 | 335 | } |
| 337 | 336 | |
| 338 | 337 | $socialIcons = json_decode($config->get('social_icons', '{}'), true); |
| 339 | 338 | |
| 340 | - if (!empty($socialIcons['X'])) { | |
| 341 | - unset($socialIcons['X']); | |
| 339 | + if (!empty($socialIcons['X']) || empty($socialIcons['x'])) { | |
| 340 | + if (!empty($socialIcons['X'])) { | |
| 341 | + unset($socialIcons['X']); | |
| 342 | + } | |
| 342 | 343 | |
| 343 | - $newConfig = new \stdClass(); | |
| 344 | - $newConfig->social_icons = json_encode($socialIcons); | |
| 345 | - $config->save($newConfig); | |
| 346 | - } | |
| 344 | + if (empty($socialIcons['x'])) { | |
| 345 | + $socialIcons['x'] = ACYM_IMAGES.'logo/x.png'; | |
| 346 | + } | |
| 347 | 347 | |
| 348 | - if (empty($socialIcons['x'])) { | |
| 349 | - $socialIcons['x'] = ACYM_IMAGES.'logo/x.png'; | |
| 350 | - | |
| 351 | - $newConfig = new \stdClass(); | |
| 352 | - $newConfig->social_icons = json_encode($socialIcons); | |
| 353 | - $config->save($newConfig); | |
| 348 | + $config->saveConfig(['social_icons' => json_encode($socialIcons)]); | |
| 354 | 349 | } |
| 355 | 350 | } |
| 356 | 351 | |
| 357 | - private function updateFor874($config) | |
| 352 | + private function updateFor874(ConfigurationClass $config): void | |
| 358 | 353 | { |
| 359 | 354 | if ($this->isPreviousVersionAtLeast('8.7.4') || ACYM_CMS !== 'joomla') { |
| 360 | 355 | return; |
| 361 | 356 | } |
| 362 | 357 | |
| 363 | - $config->save(['malicious_scan' => 1]); | |
| 358 | + $config->saveConfig(['malicious_scan' => 1]); | |
| 364 | 359 | } |
| 365 | 360 | |
| 366 | - private function updateFor881($config) | |
| 361 | + private function updateFor881(ConfigurationClass $config): void | |
| 367 | 362 | { |
| 368 | 363 | if ($this->isPreviousVersionAtLeast('8.7.0')) { |
| 369 | 364 | return; |
| 370 | 365 | } |
| 371 | 366 | |
| 367 | + // Replace backslashes by slashes in the upload folder option | |
| 372 | 368 | $uploadFolder = $config->get('uploadfolder'); |
| 373 | 369 | if (!empty($uploadFolder) && strpos($uploadFolder, '\\') !== false) { |
| 374 | 370 | $uploadFolder = str_replace('\\', '/', $uploadFolder); |
| 375 | - $config->save(['uploadfolder' => $uploadFolder]); | |
| 371 | + $config->saveConfig(['uploadfolder' => $uploadFolder]); | |
| 376 | 372 | } |
| 377 | 373 | } |
| 378 | 374 | } |