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/Dashboard/Migration.php +0 -106 10.2.2 → 11.1.1 View file →
@@ -1,106 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Dashboard;
4 -
5 -use AcyMailing\Helpers\MigrationHelper;
6 -use AcyMailing\Helpers\UpdateHelper;
7 -
8 -trait Migration
9 -{
10 - public function preMigration(): void
11 - {
12 - $elementToMigrate = acym_getVar('string', 'element', '');
13 - $helperMigration = new MigrationHelper();
14 -
15 - $result = $helperMigration->preMigration($elementToMigrate);
16 -
17 - if (!empty($result['isOk'])) {
18 - echo $result['count'];
19 - } else {
20 - $this->errorHandling($result);
21 - }
22 - exit;
23 - }
24 -
25 - public function migrate(): void
26 - {
27 - $elementToMigrate = acym_getVar('string', 'element');
28 - $helperMigration = new MigrationHelper();
29 - $functionName = 'do'.ucfirst($elementToMigrate).'Migration';
30 -
31 - $result = $helperMigration->$functionName($elementToMigrate);
32 -
33 - if (!empty($result['isOk'])) {
34 - echo json_encode($result);
35 - } else {
36 - $this->errorHandling($result);
37 - }
38 - exit;
39 - }
40 -
41 - public function migrationDone(): void
42 - {
43 - $newConfig = new \stdClass();
44 - $newConfig->migration = '1';
45 - $this->config->save($newConfig);
46 -
47 - $updateHelper = new UpdateHelper();
48 - $updateHelper->installNotifications();
49 - $updateHelper->installTemplates();
50 - $updateHelper->installOverrideEmails();
51 -
52 - $this->listing();
53 - }
54 -
55 - private function errorHandling(array $result): void
56 - {
57 - echo 'ERROR : ';
58 - if (!empty($result['errorInsert'])) {
59 - echo strtoupper(acym_translation('ACYM_INSERT_ERROR'));
60 - }
61 - if (!empty($result['errorClean'])) {
62 - echo strtoupper(acym_translation('ACYM_CLEAN_ERROR'));
63 - }
64 -
65 - if (!empty($result['errors'])) {
66 - echo '<br>';
67 -
68 - foreach ($result['errors'] as $key => $oneError) {
69 - echo '<br>'.$key.' : '.$oneError;
70 - }
71 - }
72 - }
73 -
74 - private function acym_existsAcyMailing59(): bool
75 - {
76 - $allTables = acym_getTables();
77 -
78 - if (in_array(acym_getPrefix().'acymailing_config', $allTables)) {
79 - $queryVersion = 'SELECT `value` FROM #__acymailing_config WHERE `namekey` LIKE "version"';
80 -
81 - $version = acym_loadResult($queryVersion);
82 -
83 - if (version_compare($version, '5.9.0') >= 0) {
84 - return true;
85 - }
86 - }
87 -
88 - return false;
89 - }
90 -
91 - public function migration(): bool
92 - {
93 - if ($this->config->get('migration') == 0 && acym_existsAcyMailing59()) {
94 - acym_setVar('layout', 'migrate');
95 - parent::display();
96 -
97 - return true;
98 - }
99 -
100 - $newConfig = new \stdClass();
101 - $newConfig->migration = '1';
102 - $this->config->save($newConfig);
103 -
104 - return false;
105 - }
106 -}