PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
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/Patchv10.php +232 -5 10.1.4 → 11.1.0 View file →
@@ -1,8 +1,13 @@
1 1 <?php
2 2
3 3 namespace AcyMailing\Helpers\Update;
4 4
5 +use AcyMailing\Classes\CampaignClass;
6 +use AcyMailing\Classes\ConfigurationClass;
7 +use AcyMailing\Controllers\ConfigurationController;
8 +use AcyMailing\Helpers\BounceHelper;
9 +
5 10 trait Patchv10
6 11 {
7 12 private function updateFor1000(): void
8 13 {
@@ -20,9 +25,10 @@
20 25 `trigger_params` TEXT NULL,
21 26 `trigger_once` TINYINT(1) NOT NULL DEFAULT 0,
22 27 PRIMARY KEY (`id`)
23 28 )
24 - ENGINE = InnoDB;';
29 + ENGINE = InnoDB
30 + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
25 31
26 32 $scenarioStepTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_step` (
27 33 `id` VARCHAR(30) NOT NULL,
28 34 `previous_id` VARCHAR(30) NULL,
@@ -36,9 +42,10 @@
36 42 REFERENCES `#__acym_scenario`(`id`)
37 43 ON DELETE NO ACTION
38 44 ON UPDATE NO ACTION
39 45 )
40 - ENGINE = InnoDB;';
46 + ENGINE = InnoDB
47 + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
41 48
42 49 $scenarioProcessTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_process` (
43 50 `id` INT NOT NULL AUTO_INCREMENT,
44 51 `scenario_id` INT NOT NULL,
@@ -56,9 +63,10 @@
56 63 REFERENCES `#__acym_user`(`id`)
57 64 ON DELETE NO ACTION
58 65 ON UPDATE NO ACTION
59 66 )
60 - ENGINE = InnoDB;';
67 + ENGINE = InnoDB
68 + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
61 69
62 70 $scenarioQueueTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_queue` (
63 71 `id` INT NOT NULL AUTO_INCREMENT,
64 72 `scenario_process_id` INT NOT NULL,
@@ -70,9 +78,10 @@
70 78 REFERENCES `#__acym_scenario_process`(`id`)
71 79 ON DELETE NO ACTION
72 80 ON UPDATE NO ACTION
73 81 )
74 - ENGINE = InnoDB;';
82 + ENGINE = InnoDB
83 + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
75 84
76 85 $scenarioHistoryLineTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_history_line` (
77 86 `id` INT NOT NULL AUTO_INCREMENT,
78 87 `scenario_process_id` INT NOT NULL,
@@ -88,9 +97,10 @@
88 97 REFERENCES `#__acym_scenario_process`(`id`)
89 98 ON DELETE NO ACTION
90 99 ON UPDATE NO ACTION
91 100 )
92 - ENGINE = InnoDB;';
101 + ENGINE = InnoDB
102 + /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
93 103
94 104 $this->updateQuery($scenarioTable);
95 105 $this->updateQuery($scenarioStepTable);
96 106 $this->updateQuery($scenarioProcessTable);
@@ -95,6 +105,223 @@
95 105 $this->updateQuery($scenarioStepTable);
96 106 $this->updateQuery($scenarioProcessTable);
97 107 $this->updateQuery($scenarioQueueTable);
98 108 $this->updateQuery($scenarioHistoryLineTable);
109 + }
110 +
111 + private function updateFor1020(ConfigurationClass $config): void
112 + {
113 + if ($this->isPreviousVersionAtLeast('10.2.0')) {
114 + return;
115 + }
116 +
117 + $smtpHost = strtolower($config->get('smtp_host'));
118 + if (in_array($smtpHost, ['smtp.gmail.com', 'smtp-mail.outlook.com', 'smtp.office365.com'])) {
119 + $sendingMethod = $config->get('mailer_method');
120 + $clientId = $config->get('smtp_clientId');
121 + $clientSecret = $config->get('smtp_secret');
122 + $redirectUrl = $config->get('smtp_redirectUrl');
123 + $accessToken = str_replace('Bearer ', '', $config->get('smtp_token'));
124 + $accessTokenExpiration = $config->get('smtp_token_expireIn');
125 + $refreshToken = $config->get('smtp_refresh_token');
126 +
127 + if ($smtpHost === 'smtp.gmail.com') {
128 + $newConfig = [
129 + 'mailer_method' => $sendingMethod === 'smtp' ? 'google' : $sendingMethod,
130 + 'google_client_id' => $clientId,
131 + 'google_client_secret' => $clientSecret,
132 + 'google_redirect_url' => $redirectUrl,
133 + 'google_access_token' => $accessToken,
134 + 'google_access_token_expiration' => $accessTokenExpiration,
135 + 'google_refresh_token' => $refreshToken,
136 + 'google_refresh_token_expiration' => 0,
137 + ];
138 + } else {
139 + $newConfig = [
140 + 'mailer_method' => $sendingMethod === 'smtp' ? 'outlook' : $sendingMethod,
141 + 'outlook_tenant' => $config->get('smtp_tenant'),
142 + 'outlook_client_id' => $clientId,
143 + 'outlook_client_secret' => $clientSecret,
144 + 'outlook_redirect_url' => $redirectUrl,
145 + 'outlook_access_token' => $accessToken,
146 + 'outlook_access_token_expiration' => $accessTokenExpiration,
147 + 'outlook_refresh_token' => $refreshToken,
148 + 'outlook_refresh_token_expiration' => 0,
149 + ];
150 + }
151 +
152 + if (!empty($newConfig)) {
153 + $config->saveConfig($newConfig);
154 + }
155 + }
156 +
157 + $bounceHost = strtolower($config->get('bounce_server'));
158 + if (in_array($bounceHost, BounceHelper::HOSTS_NEEDING_OAUTH)) {
159 + $config->saveConfig(
160 + [
161 + 'bounce_server' => $bounceHost,
162 + 'bounce_access_token' => str_replace('Bearer ', '', $config->get('bounce_token')),
163 + 'bounce_access_token_expiration' => $config->get('bounce_token_expireIn'),
164 + 'bounce_refresh_token_expiration' => 0,
165 + 'bounce_port' => 993,
166 + 'bounce_connection' => 'imap',
167 + 'bounce_secured' => 'ssl',
168 + 'bounce_certif' => 1,
169 + ]
170 + );
171 + }
172 +
173 + $this->updateQuery('ALTER TABLE #__acym_list ADD COLUMN `subscribers` INT DEFAULT 0');
174 + $this->updateQuery('ALTER TABLE #__acym_list ADD COLUMN `unsubscribed_users` INT DEFAULT 0');
175 + $this->updateQuery('ALTER TABLE #__acym_list ADD COLUMN `new_sub` INT DEFAULT 0');
176 + $this->updateQuery('ALTER TABLE #__acym_list ADD COLUMN `new_unsub` INT DEFAULT 0');
177 + }
178 +
179 + private function updateFor1050(): void
180 + {
181 + if ($this->isPreviousVersionAtLeast('10.5.0')) {
182 + return;
183 + }
184 +
185 + $this->updateQuery('ALTER TABLE #__acym_automation CHANGE `active` `active` TINYINT(3) NOT NULL DEFAULT 0');
186 + }
187 +
188 + private function updateFor1060(): void
189 + {
190 + if ($this->isPreviousVersionAtLeast('10.6.0')) {
191 + return;
192 + }
193 +
194 + $this->updateQuery('ALTER TABLE #__acym_scenario_process ADD COLUMN `unsubscribed` TINYINT(1) NOT NULL DEFAULT 0');
195 + }
196 +
197 + private function updateFor1062(): void
198 + {
199 + if ($this->isPreviousVersionAtLeast('10.6.2')) {
200 + return;
201 + }
202 +
203 + $this->updateQuery('ALTER TABLE #__acym_list CHANGE `access` `access` VARCHAR(150) NOT NULL DEFAULT ""');
204 + }
205 +
206 + private function updateFor1065(): void
207 + {
208 + if ($this->isPreviousVersionAtLeast('10.6.5')) {
209 + return;
210 + }
211 +
212 + $campaignClass = new CampaignClass();
213 + $autoCampaigns = $campaignClass->getCampaignsByTypes([CampaignClass::SENDING_TYPE_AUTO], true);
214 + $campaignIds = [];
215 +
216 + foreach ($autoCampaigns as $autoCampaign) {
217 + if (empty($autoCampaign->sending_params)) {
218 + $autoCampaign->active = 0;
219 + $campaignClass->save($autoCampaign);
220 + $campaignIds[] = $autoCampaign->id;
221 + }
222 + }
223 +
224 + if (!empty($campaignIds)) {
225 + $campaignIdsText = implode(', ', $campaignIds);
226 +
227 + $message = acym_translationSprintf('ACYM_ERROR_WHILE_RECOVERING_TRIGGERS_NOTIF_X', $campaignIdsText);
228 + $message .= ' <a id="acym__queue__configure-cron" href="'.acym_completeLink('campaigns&task=campaigns_auto').'">'.acym_translation(
229 + 'ACYM_GOTO_CAMPAIGNS_AUTO'
230 + ).'</a>';
231 + $message .= '<p class="acym__do__not__remindme" title="auto_campaigns_triggers_reminder">'.acym_translation('ACYM_DO_NOT_REMIND_ME').'</p>';
232 +
233 + $notification = [
234 + 'name' => 'auto_campaigns_triggers_reminder',
235 + 'removable' => 1,
236 + ];
237 + acym_enqueueMessage($message, 'warning', true, [$notification]);
238 + }
239 + }
240 +
241 + private function updateFor1070(): void
242 + {
243 + if ($this->isPreviousVersionAtLeast('10.7.0')) {
244 + return;
245 + }
246 +
247 + $this->updateQuery('ALTER TABLE #__acym_automation ADD COLUMN `ordering` SMALLINT(6) NOT NULL DEFAULT 0');
248 + $this->updateQuery('ALTER TABLE #__acym_scenario ADD COLUMN `ordering` SMALLINT(6) NOT NULL DEFAULT 0');
249 + }
250 +
251 + private function updateFor1082(): void
252 + {
253 + if ($this->isPreviousVersionAtLeast('10.8.2')) {
254 + return;
255 + }
256 +
257 + global $acymCmsUserVars;
258 +
259 + $this->updateQuery(
260 + 'UPDATE `#__acym_user` AS `acyuser`
261 + JOIN '.$acymCmsUserVars->table.' AS `user`
262 + ON CONVERT(`user`.'.$acymCmsUserVars->email.' USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(`acyuser`.`email` USING utf8mb4) COLLATE utf8mb4_unicode_ci
263 + SET `acyuser`.`cms_id` = `user`.'.$acymCmsUserVars->id.'
264 + WHERE `acyuser`.`cms_id` > 0
265 + AND `acyuser`.`cms_id` != `user`.'.$acymCmsUserVars->id
266 + );
267 +
268 + $this->updateQuery(
269 + 'UPDATE `#__acym_user` AS `acyuser`
270 + LEFT JOIN '.$acymCmsUserVars->table.' AS `user`
271 + ON CONVERT(`user`.'.$acymCmsUserVars->email.' USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(`acyuser`.`email` USING utf8mb4) COLLATE utf8mb4_unicode_ci
272 + SET `acyuser`.`cms_id` = 0
273 + WHERE `acyuser`.`cms_id` > 0
274 + AND `user`.'.$acymCmsUserVars->id.' IS NULL'
275 + );
276 + }
277 +
278 + private function updateFor1090(ConfigurationClass $config): void
279 + {
280 + if ($this->isPreviousVersionAtLeast('10.9.0')) {
281 + return;
282 + }
283 +
284 + $frequency = (int)$config->get('cron_frequency');
285 +
286 + if (
287 + acym_level(ACYM_ESSENTIAL)
288 + && $config->get('queue_type') !== 'manual'
289 + && !empty($frequency)
290 + && $frequency < 900
291 + && acym_isLicenseValidWeekly()
292 + ) {
293 + $taskId = acym_scheduleTask(
294 + [
295 + 'title' => 'AcyMailing – Automated tasks',
296 + 'type' => 'plg_task_requests_task_get',
297 + 'frequencyInMinutes' => $frequency / 60,
298 + 'name' => ConfigurationController::CRON_TASK_NAME,
299 + 'taskFrequency' => 'every_minute',
300 + 'config' => [
301 + 'cron_security' => $config->get('cron_security'),
302 + 'cron_key' => $config->get('cron_key'),
303 + ],
304 + ]
305 + );
306 +
307 + if (!empty($taskId) && ACYM_CMS === 'joomla') {
308 + $config->saveConfig(['scheduled_task_id' => $taskId]);
309 + }
310 + }
311 +
312 + $this->updateQuery('ALTER TABLE `#__acym_user` ADD COLUMN `deactivation_date` DATETIME DEFAULT NULL');
313 +
314 + $aclPages = acym_getPagesForAcl();
315 +
316 + $configToSave = [];
317 + foreach ($aclPages as $page => $title) {
318 + if ($config->get('acl_'.$page) === 'all') {
319 + $configToSave['acl_'.$page] = ACYM_ADMIN_GROUP;
320 + }
321 + }
322 +
323 + if (!empty($configToSave)) {
324 + $config->saveConfig($configToSave);
325 + }
99 326 }
100 327 }