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/Patchv10.php +0 -327 11.0.1 → 11.1.1 View file →
@@ -1,327 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Classes\CampaignClass;
6 -use AcyMailing\Classes\ConfigurationClass;
7 -use AcyMailing\Controllers\ConfigurationController;
8 -use AcyMailing\Helpers\BounceHelper;
9 -
10 -trait Patchv10
11 -{
12 - private function updateFor1000(): void
13 - {
14 - if ($this->isPreviousVersionAtLeast('10.0.0')) {
15 - return;
16 - }
17 -
18 - $this->updateQuery('ALTER TABLE #__acym_queue ADD COLUMN `params` TEXT NULL');
19 -
20 - $scenarioTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario` (
21 - `id` INT NOT NULL AUTO_INCREMENT,
22 - `trigger` VARCHAR(255) NOT NULL,
23 - `name` VARCHAR(255) NOT NULL,
24 - `active` TINYINT(1) NOT NULL DEFAULT 0,
25 - `trigger_params` TEXT NULL,
26 - `trigger_once` TINYINT(1) NOT NULL DEFAULT 0,
27 - PRIMARY KEY (`id`)
28 -)
29 - ENGINE = InnoDB
30 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
31 -
32 - $scenarioStepTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_step` (
33 - `id` VARCHAR(30) NOT NULL,
34 - `previous_id` VARCHAR(30) NULL,
35 - `type` VARCHAR(30) NOT NULL,
36 - `params` TEXT NULL,
37 - `scenario_id` INT NOT NULL,
38 - `condition_valid` TINYINT(1) NULL,
39 - PRIMARY KEY (`id`),
40 - CONSTRAINT `#__fk_acym_scenario_step1`
41 - FOREIGN KEY (`scenario_id`)
42 - REFERENCES `#__acym_scenario`(`id`)
43 - ON DELETE NO ACTION
44 - ON UPDATE NO ACTION
45 -)
46 - ENGINE = InnoDB
47 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
48 -
49 - $scenarioProcessTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_process` (
50 - `id` INT NOT NULL AUTO_INCREMENT,
51 - `scenario_id` INT NOT NULL,
52 - `user_id` INT NOT NULL,
53 - `start_at` DATETIME NOT NULL,
54 - `end_at` DATETIME NULL,
55 - PRIMARY KEY (`id`),
56 - CONSTRAINT `#__fk_acym_scenario_process1`
57 - FOREIGN KEY (`scenario_id`)
58 - REFERENCES `#__acym_scenario`(`id`)
59 - ON DELETE NO ACTION
60 - ON UPDATE NO ACTION,
61 - CONSTRAINT `#__fk_acym_scenario_process2`
62 - FOREIGN KEY (`user_id`)
63 - REFERENCES `#__acym_user`(`id`)
64 - ON DELETE NO ACTION
65 - ON UPDATE NO ACTION
66 -)
67 - ENGINE = InnoDB
68 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
69 -
70 - $scenarioQueueTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_queue` (
71 - `id` INT NOT NULL AUTO_INCREMENT,
72 - `scenario_process_id` INT NOT NULL,
73 - `step_id` VARCHAR(30) NOT NULL,
74 - `execution_date` DATETIME NOT NULL,
75 - PRIMARY KEY (`id`),
76 - CONSTRAINT `#__fk_acym_scenario_queue1`
77 - FOREIGN KEY (`scenario_process_id`)
78 - REFERENCES `#__acym_scenario_process`(`id`)
79 - ON DELETE NO ACTION
80 - ON UPDATE NO ACTION
81 -)
82 - ENGINE = InnoDB
83 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
84 -
85 - $scenarioHistoryLineTable = 'CREATE TABLE IF NOT EXISTS `#__acym_scenario_history_line` (
86 - `id` INT NOT NULL AUTO_INCREMENT,
87 - `scenario_process_id` INT NOT NULL,
88 - `date` DATETIME NOT NULL,
89 - `type` VARCHAR(10) NOT NULL,
90 - `params` TEXT NULL,
91 - `result` TEXT NULL,
92 - `log` TEXT NULL,
93 - `scenario_step_id` VARCHAR(40) NULL,
94 - PRIMARY KEY (`id`),
95 - CONSTRAINT `#__fk_acym_scenario_history_line1`
96 - FOREIGN KEY (`scenario_process_id`)
97 - REFERENCES `#__acym_scenario_process`(`id`)
98 - ON DELETE NO ACTION
99 - ON UPDATE NO ACTION
100 -)
101 - ENGINE = InnoDB
102 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;';
103 -
104 - $this->updateQuery($scenarioTable);
105 - $this->updateQuery($scenarioStepTable);
106 - $this->updateQuery($scenarioProcessTable);
107 - $this->updateQuery($scenarioQueueTable);
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 - }
326 - }
327 -}