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/Patchv7.php +0 -463 10.10.2 → 11.1.1 View file →
@@ -1,463 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Classes\ActionClass;
6 -use AcyMailing\Classes\AutomationClass;
7 -use AcyMailing\Classes\CampaignClass;
8 -use AcyMailing\Classes\ConditionClass;
9 -use AcyMailing\Classes\ConfigurationClass;
10 -use AcyMailing\Classes\FieldClass;
11 -use AcyMailing\Classes\FormClass;
12 -use AcyMailing\Classes\MailClass;
13 -use AcyMailing\Classes\MailStatClass;
14 -use AcyMailing\Classes\RuleClass;
15 -use AcyMailing\Classes\SegmentClass;
16 -use AcyMailing\Controllers\ConfigurationController;
17 -
18 -trait Patchv7
19 -{
20 - private function updateFor700(ConfigurationClass $config): void
21 - {
22 - if ($this->isPreviousVersionAtLeast('7.0.0')) {
23 - return;
24 - }
25 -
26 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
27 - $socialMedias = acym_getSocialMedias();
28 - foreach ($socialIcons as $oneSocial => $imagePath) {
29 - if (!in_array($oneSocial, $socialMedias)) {
30 - unset($socialIcons[$oneSocial]);
31 - }
32 - }
33 -
34 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
35 -
36 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `redirection_options` TEXT');
37 - $formClass = new FormClass();
38 - $forms = $formClass->getAll();
39 - if (!empty($forms)) {
40 - foreach ($forms as $oneForm) {
41 - $oneForm->redirection_options = json_encode(['after_subscription' => '', 'confirmation_message' => '']);
42 - $formClass->save($oneForm);
43 - }
44 - }
45 -
46 - if (!empty($config->get('active_cron', 0))) {
47 - $licenseKey = $config->get('license_key', '');
48 - if (!empty($licenseKey)) {
49 - $configurationController = new ConfigurationController();
50 - $configurationController->modifyCron('activateCron', $licenseKey);
51 - }
52 - }
53 -
54 - $segmentClass = new SegmentClass();
55 - $segmentClass->updateSegments();
56 - }
57 -
58 - private function updateFor710(): void
59 - {
60 - if ($this->isPreviousVersionAtLeast('7.1.0')) {
61 - return;
62 - }
63 -
64 - $this->updateQuery(
65 - 'UPDATE #__acym_mail
66 - SET `type` = '.acym_escapeDB(MailClass::TYPE_TEMPLATE).'
67 - WHERE `template` = 1
68 - AND `type` = '.acym_escapeDB(MailClass::TYPE_STANDARD)
69 - );
70 -
71 - $this->updateQuery('ALTER TABLE #__acym_mail DROP `template`');
72 -
73 - $fieldClass = new FieldClass();
74 - $fieldClass->insertLanguageField();
75 - }
76 -
77 - private function updateFor720(ConfigurationClass $config): void
78 - {
79 - if ($this->isPreviousVersionAtLeast('7.2.0')) {
80 - return;
81 - }
82 -
83 - $config->saveConfig(['built_by_update' => 1]);
84 - $config->saveConfig(['display_built_by' => 0]);
85 - $this->updateQuery('ALTER TABLE #__acym_user CHANGE `language` `language` VARCHAR(20) NOT NULL DEFAULT ""');
86 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `language` `language` VARCHAR(20) NOT NULL DEFAULT ""');
87 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `links_language` `links_language` VARCHAR(20) NOT NULL DEFAULT ""');
88 -
89 - $this->updateQuery('ALTER TABLE #__acym_list ADD `translation` LONGTEXT NULL');
90 - $this->updateQuery('ALTER TABLE #__acym_field ADD `translation` LONGTEXT NULL');
91 - $this->updateQuery('ALTER TABLE #__acym_mail ADD `translation` TEXT NULL');
92 - }
93 -
94 - private function updateFor721(): void
95 - {
96 - if ($this->isPreviousVersionAtLeast('7.2.1')) {
97 - return;
98 - }
99 -
100 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `translation` `translation` TEXT NULL');
101 - }
102 -
103 - private function updateFor740(ConfigurationClass $config): void
104 - {
105 - if ($this->isPreviousVersionAtLeast('7.4.0')) {
106 - return;
107 - }
108 -
109 - $actionClass = new ActionClass();
110 - $actions = $actionClass->getAll();
111 - foreach ($actions as $action) {
112 - if (strpos($action->filters, 'hikareminder')) {
113 - $action->filters = preg_replace_callback(
114 - '/"hikareminder":{"days":"(\d+)"/',
115 - [$this, 'replaceHikaReminder'],
116 - $action->filters
117 - );
118 - $actionClass->save($action);
119 - }
120 - }
121 -
122 - $conditionClass = new ConditionClass();
123 - $conditions = $conditionClass->getAll();
124 - foreach ($conditions as $condition) {
125 - if (strpos($condition->conditions, 'hikareminder')) {
126 - $condition->conditions = preg_replace_callback(
127 - '/"hikareminder":{"days":"(\d+)"/',
128 - [$this, 'replaceHikaReminder'],
129 - $condition->conditions
130 - );
131 - $conditionClass->save($condition);
132 - }
133 - }
134 -
135 - $segmentClass = new SegmentClass();
136 - $segments = $segmentClass->getAll();
137 - foreach ($segments as $segment) {
138 - if (strpos($segment->filters, 'hikareminder')) {
139 - $segment->filters = preg_replace_callback(
140 - '/"hikareminder":{"days":"(\d+)"/',
141 - [$this, 'replaceHikaReminder'],
142 - $segment->filters
143 - );
144 - $segmentClass->save($segment);
145 - }
146 - }
147 -
148 - $campaignClass = new CampaignClass();
149 - $campaigns = $campaignClass->getAll();
150 - foreach ($campaigns as $campaign) {
151 - $campaign->sending_params = json_encode($campaign->sending_params);
152 - if (strpos($campaign->sending_params, 'hikareminder')) {
153 - $campaign->sending_params = preg_replace_callback(
154 - '/"hikareminder":{"days":"(\d+)"/',
155 - [$this, 'replaceHikaReminder'],
156 - $campaign->sending_params
157 - );
158 - $campaign->sending_params = json_decode($campaign->sending_params);
159 - $campaignClass->save($campaign);
160 - }
161 - }
162 -
163 - $rule = new \stdClass();
164 - $rule->name = 'ACYM_LIST_UNSUBSCRIBE_HANDLING';
165 - $rule->ordering = 1;
166 - $rule->regex = 'Please unsubscribe user ID \\d+';
167 - $rule->executed_on = '["body"]';
168 - $rule->action_message = '["delete_message"]';
169 - $rule->action_user = '["unsubscribe_user"]';
170 - $rule->active = 1;
171 - $rule->increment_stats = 0;
172 - $rule->execute_action_after = 0;
173 -
174 - $ruleClass = new RuleClass();
175 - $ruleClass->save($rule);
176 -
177 - $captchaOption = $config->get('captcha', 0);
178 - $config->saveConfig([
179 - 'captcha' => intval($captchaOption) === 1 ? 'acym_ireCaptcha' : 'none',
180 - ]);
181 -
182 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `from_name` `from_name` VARCHAR(100) NULL');
183 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `from_email` `from_email` VARCHAR(100) NULL');
184 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `reply_to_name` `reply_to_name` VARCHAR(100) NULL');
185 - $this->updateQuery('ALTER TABLE #__acym_mail CHANGE `reply_to_email` `reply_to_email` VARCHAR(100) NULL');
186 - }
187 -
188 - private function updateFor750(ConfigurationClass $config): void
189 - {
190 - if ($this->isPreviousVersionAtLeast('7.5.0')) {
191 - return;
192 - }
193 -
194 - $languageFieldId = $config->get(FieldClass::LANGUAGE_FIELD_ID_KEY, 0);
195 - if (!empty($languageFieldId)) {
196 - $this->updateQuery('UPDATE `#__acym_field` SET `namekey` = "acym_language" WHERE `id` = '.intval($languageFieldId));
197 - }
198 -
199 - $news = $config->get('last_news', '');
200 - if (!empty($news)) {
201 - $config->saveConfig(
202 - [
203 - 'last_news' => base64_encode($news),
204 - ],
205 - false
206 - );
207 - }
208 -
209 - $this->updateQuery('ALTER TABLE `#__acym_user_has_list` ADD INDEX `index_#__acym_user_has_list3` (`subscription_date` ASC)');
210 - $this->updateQuery('ALTER TABLE `#__acym_user_has_list` ADD INDEX `index_#__acym_user_has_list4` (`unsubscribe_date` ASC)');
211 - $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD `tracking_sale` FLOAT NULL');
212 - $this->updateQuery('ALTER TABLE #__acym_mail_stat ADD `currency` VARCHAR(5) NULL');
213 -
214 - $mailStatsClass = new MailStatClass();
215 - $mailStatsClass->migrateTrackingSale();
216 - }
217 -
218 - private function updateFor755(): void
219 - {
220 - if ($this->isPreviousVersionAtLeast('7.5.5')) {
221 - return;
222 - }
223 -
224 - $actionClass = new ActionClass();
225 - $automationClass = new AutomationClass();
226 - $adminAutomations = $automationClass->getAutomationsAdmin();
227 -
228 - if (empty($adminAutomations)) {
229 - return;
230 - }
231 -
232 - $mailClass = new MailClass();
233 - foreach ($adminAutomations as $oneAutomation) {
234 - $actions = $actionClass->getActionsByAutomationId($oneAutomation->id);
235 - foreach ($actions as $oneAction) {
236 - $oneAction->actions = json_decode($oneAction->actions, true);
237 - foreach ($oneAction->actions as $action) {
238 - if (empty($action['acy_add_queue']['mail_id'])) continue;
239 -
240 - $mail = $mailClass->getOneById($action['acy_add_queue']['mail_id']);
241 - $mail->body = str_replace('{subtag:', '{subscriber:', $mail->body);
242 -
243 - $mailClass->save($mail);
244 - }
245 - }
246 - }
247 - }
248 -
249 - private function updateFor759(): void
250 - {
251 - if ($this->isPreviousVersionAtLeast('7.5.9')) {
252 - return;
253 - }
254 -
255 - $fieldClass = new FieldClass();
256 - $fields = $fieldClass->getAll();
257 - foreach ($fields as $field) {
258 - if (empty($field->option)) continue;
259 -
260 - $field->option = json_decode($field->option, true);
261 - $options = array_keys($field->option);
262 - if (in_array('editable_user_creation', $options) || in_array('editable_user_modification', $options)) {
263 - unset($field->option['editable_user_creation']);
264 - unset($field->option['editable_user_modification']);
265 -
266 - $field->option = json_encode($field->option);
267 - $fieldClass->save($field);
268 - }
269 - }
270 - }
271 -
272 - private function updateFor7510(): void
273 - {
274 - if ($this->isPreviousVersionAtLeast('7.5.10') || ACYM_CMS !== 'joomla') {
275 - return;
276 - }
277 -
278 - $dynamicsToDelete = [
279 - 'gravityforms',
280 - 'page',
281 - 'post',
282 - 'theeventscalendar',
283 - 'ultimatemember',
284 - 'woocommerce',
285 - 'jomsocial',
286 - ];
287 -
288 - foreach ($dynamicsToDelete as $dynamicFolder) {
289 - if (file_exists(ACYM_BACK.'dynamics'.DS.$dynamicFolder)) {
290 - acym_deleteFolder(ACYM_BACK.'dynamics'.DS.$dynamicFolder);
291 - }
292 - }
293 - }
294 -
295 - private function updateFor760(): void
296 - {
297 - if ($this->isPreviousVersionAtLeast('7.6.0')) {
298 - return;
299 - }
300 -
301 - $this->updateQuery('ALTER TABLE #__acym_user CHANGE `key` `key` VARCHAR(30) NULL');
302 - $this->updateQuery('ALTER TABLE #__acym_mail DROP `library`');
303 - $this->updateQuery('ALTER TABLE #__acym_user_has_list ADD `unsubscribe_reason` TEXT NULL');
304 - }
305 -
306 - private function updateFor761(): void
307 - {
308 - if ($this->isPreviousVersionAtLeast('7.6.1')) {
309 - return;
310 - }
311 -
312 - $this->updateQuery('ALTER TABLE #__acym_user_has_list DROP COLUMN `unsubscribe_reason`');
313 - $this->updateQuery('ALTER TABLE #__acym_history ADD `unsubscribe_reason` TEXT NULL');
314 -
315 - $fieldClass = new FieldClass();
316 - $dateCustomFields = $fieldClass->getFieldsByType(['date']);
317 -
318 - foreach ($dateCustomFields as $oneField) {
319 - $oneField->option = json_decode($oneField->option);
320 -
321 - $formatToDisplay = explode('%', $oneField->option->format);
322 - unset($formatToDisplay[0]);
323 -
324 - $values = $fieldClass->getFieldsValueByFieldId($oneField->id);
325 - foreach ($values as $oneValue) {
326 - $userDate = explode('/', $oneValue->value);
327 - $year = '0000';
328 - $month = '00';
329 - $day = '00';
330 - $i = 0;
331 - foreach ($formatToDisplay as $one) {
332 - if (!isset($userDate[$i])) continue 2;
333 -
334 - if ($one === 'd') {
335 - $day = $userDate[$i];
336 - }
337 - if ($one === 'm') {
338 - $month = $userDate[$i];
339 - }
340 - if ($one === 'y') {
341 - $year = $userDate[$i];
342 - }
343 - $i++;
344 - }
345 -
346 - acym_query(
347 - 'UPDATE #__acym_user_has_field
348 - SET `value` = '.acym_escapeDB($year.'-'.$month.'-'.$day).'
349 - WHERE `field_id` = '.intval($oneValue->field_id).' AND `user_id` = '.intval($oneValue->user_id)
350 - );
351 - }
352 - }
353 -
354 - $this->updateQuery('ALTER TABLE #__acym_user CHANGE `automation` `automation` VARCHAR(50) NOT NULL DEFAULT ""');
355 - }
356 -
357 - private function updateFor762(): void
358 - {
359 - if ($this->isPreviousVersionAtLeast('7.6.2')) {
360 - return;
361 - }
362 -
363 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `message_options` TEXT');
364 - $this->updateQuery('ALTER TABLE `#__acym_history` CHANGE `ip` `ip` VARCHAR(50)');
365 - $this->updateQuery('ALTER TABLE `#__acym_user` CHANGE `confirmation_ip` `confirmation_ip` VARCHAR(50)');
366 - }
367 -
368 - private function updateFor776(): void
369 - {
370 - if ($this->isPreviousVersionAtLeast('7.7.6')) {
371 - return;
372 - }
373 -
374 - $this->updateQuery('ALTER TABLE `#__acym_list` ADD `display_name` VARCHAR(255) NULL');
375 - }
376 -
377 - private function updateFor781(): void
378 - {
379 - if ($this->isPreviousVersionAtLeast('7.8.1')) {
380 - return;
381 - }
382 -
383 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `display_options` TEXT');
384 - $popupDelays = acym_loadObjectList('SELECT id, delay FROM #__acym_form WHERE `type` = "popup"', 'id');
385 - if (!empty($popupDelays)) {
386 - foreach ($popupDelays as $formId => $formDelay) {
387 - $newData = json_encode(['delay' => (int)$formDelay->delay, 'scroll' => 0]);
388 - $this->updateQuery('UPDATE `#__acym_form` SET display_options = '.acym_escapeDB($newData).' WHERE id = '.(int)$formId);
389 - }
390 - }
391 - $this->updateQuery('ALTER TABLE `#__acym_form` DROP `delay`');
392 -
393 - $this->updateQuery(
394 - 'CREATE TABLE IF NOT EXISTS `#__acym_custom_zone` (
395 - `id` INT NOT NULL AUTO_INCREMENT,
396 - `name` VARCHAR(255) NOT NULL,
397 - `content` TEXT NOT NULL,
398 - PRIMARY KEY (`id`)
399 - )'
400 - );
401 - }
402 -
403 - private function updateFor792(): void
404 - {
405 - if ($this->isPreviousVersionAtLeast('7.9.2')) {
406 - return;
407 - }
408 -
409 - $zones = acym_loadObjectList('SELECT `id`, `content` FROM #__acym_custom_zone');
410 - if (!empty($zones)) {
411 - foreach ($zones as $oneZone) {
412 - $oneZone->content = base64_encode(acym_utf8Decode($oneZone->content));
413 - $this->updateQuery('UPDATE `#__acym_custom_zone` SET `content` = '.acym_escapeDB($oneZone->content).' WHERE `id` = '.intval($oneZone->id));
414 - }
415 - }
416 - }
417 -
418 - private function updateFor793(): void
419 - {
420 - if ($this->isPreviousVersionAtLeast('7.9.3')) {
421 - return;
422 - }
423 -
424 - $automationClass = new AutomationClass();
425 - $automations = $automationClass->getAll();
426 - if (!empty($automations)) {
427 - foreach ($automations as $oneAutomation) {
428 - $translated = acym_translation($oneAutomation->name);
429 - if ($translated === $oneAutomation->name) continue;
430 -
431 - $oneAutomation->name = $translated;
432 - $oneAutomation->description = acym_translation($oneAutomation->description);
433 - $automationClass->save($oneAutomation);
434 - }
435 - }
436 - }
437 -
438 - private function updateFor794(): void
439 - {
440 - if ($this->isPreviousVersionAtLeast('7.9.4')) {
441 - return;
442 - }
443 -
444 - $this->updateQuery('ALTER TABLE `#__acym_custom_zone` ADD `image` VARCHAR(255) NULL');
445 - }
446 -
447 - private function updateFor796(): void
448 - {
449 - if ($this->isPreviousVersionAtLeast('7.9.6') || !file_exists(ACYM_ADDONS_FOLDER_PATH.'couryeah')) {
450 - return;
451 - }
452 -
453 - unlink(ACYM_ADDONS_FOLDER_PATH.'couryeah');
454 - $this->updateQuery('UPDATE #__acym_configuration SET `name` = "acymailer_domains" WHERE `name` = "couryeah_domains"');
455 - }
456 -
457 - private function replaceHikaReminder(array $matches): string
458 - {
459 - $val = (int)$matches[1] * 86400;
460 -
461 - return '"hikareminder":{"days":"'.$val.'"';
462 - }
463 -}