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