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/Patchv8.php +0 -374 11.0.2 → 11.1.1 View file →
@@ -1,374 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Classes\ConfigurationClass;
6 -use AcyMailing\Classes\FormClass;
7 -use AcyMailing\Classes\MailClass;
8 -use AcyMailing\Classes\RuleClass;
9 -
10 -trait Patchv8
11 -{
12 - private function updateFor800(): void
13 - {
14 - if ($this->isPreviousVersionAtLeast('8.0.0')) {
15 - return;
16 - }
17 -
18 - $this->updateQuery(
19 - 'CREATE TABLE IF NOT EXISTS `#__acym_mailbox_action` (
20 - `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
21 - `name` varchar(255) DEFAULT NULL,
22 - `frequency` int(10) UNSIGNED NOT NULL DEFAULT 0,
23 - `nextdate` int(10) UNSIGNED NOT NULL DEFAULT 0,
24 - `description` text DEFAULT NULL,
25 - `server` varchar(255) NULL,
26 - `port` varchar(50) NULL,
27 - `connection_method` ENUM(\'imap\', \'pop3\', \'pear\') NULL,
28 - `secure_method` ENUM(\'ssl\', \'tls\') NULL,
29 - `self_signed` tinyint(4) NULL,
30 - `username` varchar(255) NULL,
31 - `password` varchar(50) NULL,
32 - `conditions` text DEFAULT NULL,
33 - `actions` text DEFAULT NULL,
34 - `report` text DEFAULT NULL,
35 - `delete_wrong_emails` tinyint(4) NOT NULL DEFAULT 0,
36 - `senderfrom` tinyint(4) NOT NULL DEFAULT 0,
37 - `senderto` tinyint(4) NOT NULL DEFAULT 0,
38 - `active` tinyint(4) NOT NULL DEFAULT 0,
39 - PRIMARY KEY (`id`),
40 - INDEX `index_#__acym_mailbox_action1`(`name` ASC)
41 - )
42 - ENGINE = InnoDB
43 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;'
44 - );
45 - }
46 -
47 - private function updateFor810(): void
48 - {
49 - if ($this->isPreviousVersionAtLeast('8.1.0')) {
50 - return;
51 - }
52 -
53 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `settings` TEXT');
54 - $this->updateQuery('ALTER TABLE `#__acym_form` ADD `display_languages` VARCHAR(255)');
55 -
56 - $formClass = new FormClass();
57 - $forms = $formClass->getAll();
58 -
59 - foreach ($forms as $oneForm) {
60 - $oneForm->settings = [];
61 - foreach ($oneForm as $key => $value) {
62 - $optionsPos = strpos($key, '_options');
63 - if (empty($value) || ($key !== 'cookie' && $optionsPos === false)) {
64 - continue;
65 - }
66 -
67 - $category = $key === 'cookie' ? 'cookie' : substr($key, 0, $optionsPos);
68 - $oneForm->settings[$category] = json_decode($value, true);
69 - }
70 -
71 - $oneForm->settings = json_encode($oneForm->settings);
72 - $formClass->save($oneForm);
73 - }
74 -
75 - $this->updateQuery(
76 - 'ALTER TABLE `#__acym_form`
77 - DROP `lists_options`,
78 - DROP `fields_options`,
79 - DROP `style_options`,
80 - DROP `button_options`,
81 - DROP `image_options`,
82 - DROP `termspolicy_options`,
83 - DROP `cookie`,
84 - DROP `redirection_options`,
85 - DROP `display_options`,
86 - DROP `message_options`'
87 - );
88 -
89 - $this->updateQuery('ALTER TABLE `#__acym_user` CHANGE `key` `key` VARCHAR(40) NULL');
90 - }
91 -
92 - private function updateFor811(): void
93 - {
94 - if ($this->isPreviousVersionAtLeast('8.1.1')) {
95 - return;
96 - }
97 -
98 - $formClass = new FormClass();
99 - $forms = $formClass->getAll();
100 -
101 - foreach ($forms as $oneForm) {
102 - if (!empty($oneForm->display_languages)) {
103 - continue;
104 - }
105 - $oneForm->display_languages = '["all"]';
106 - $formClass->save($oneForm);
107 - }
108 - }
109 -
110 - private function updateFor850(): void
111 - {
112 - if ($this->isPreviousVersionAtLeast('8.5.0')) {
113 - return;
114 - }
115 -
116 - $aclPages = [
117 - 'forms',
118 - 'users',
119 - 'fields',
120 - 'lists',
121 - 'segments',
122 - 'campaigns',
123 - 'mails',
124 - 'override',
125 - 'automation',
126 - 'queue',
127 - 'plugins',
128 - 'bounces',
129 - 'stats',
130 - 'configuration',
131 - ];
132 -
133 - $config = acym_config();
134 - $groups = array_keys(acym_getGroups());
135 -
136 - foreach ($aclPages as $page) {
137 - $aclConfig = $config->get('acl_'.$page, 'all');
138 -
139 - if ($aclConfig === 'all') {
140 - continue;
141 - }
142 -
143 - $groupsAuthorized = [];
144 -
145 - foreach ($groups as $group) {
146 - if ($config->get('acl_'.$page.'_'.$group, 1) == 1) {
147 - $groupsAuthorized[] = $group;
148 - }
149 - }
150 -
151 - $config->saveConfig(['acl_'.$page => implode(',', $groupsAuthorized)]);
152 - }
153 -
154 - $queries = file_get_contents(ACYM_BACK.'tables.sql');
155 - $tables = explode('CREATE TABLE IF NOT EXISTS ', $queries);
156 - $tableNames = [];
157 - $indexes = [];
158 - $constraints = [];
159 -
160 - foreach ($tables as $oneTable) {
161 - if (strpos($oneTable, '`#__') !== 0) {
162 - continue;
163 - }
164 - $tableName = substr($oneTable, 1, strpos($oneTable, '`', 1) - 1);
165 - $tableNames[] = $tableName;
166 -
167 - $fields = explode("\n", $oneTable);
168 - foreach ($fields as $key => $oneField) {
169 - $oneField = rtrim(trim($oneField), ',');
170 - if (strpos($oneField, 'INDEX') === 0) {
171 - $firstBackquotePos = strpos($oneField, '`');
172 - $indexName = substr($oneField, $firstBackquotePos + 1, strpos($oneField, '`', $firstBackquotePos + 1) - $firstBackquotePos - 1);
173 -
174 - $indexes[$tableName][$indexName] = $oneField;
175 - } elseif (strpos($oneField, 'FOREIGN KEY') !== false) {
176 - preg_match('/(#__fk.*)\`/Uis', $fields[$key - 1], $matchesConstraints);
177 - preg_match('/(#__.*)\`\(`(.*)`\)/Uis', $fields[$key + 1], $matchesTable);
178 - preg_match('/\`(.*)\`/Uis', $oneField, $matchesColumn);
179 - if (!empty($matchesConstraints) && !empty($matchesTable) && !empty($matchesColumn)) {
180 - if (empty($constraints[$tableName])) $constraints[$tableName] = [];
181 - $constraints[$tableName][$matchesConstraints[1]] = [
182 - 'table' => $matchesTable[1],
183 - 'column' => $matchesColumn[1],
184 - 'table_column' => $matchesTable[2],
185 - ];
186 - }
187 - }
188 - }
189 - }
190 -
191 - foreach ($tableNames as $tableName) {
192 - if (!empty($indexes[$tableName])) {
193 - foreach ($indexes[$tableName] as $newName => $query) {
194 - $oldName = str_replace('#__index_', 'index_#__', $newName);
195 - preg_match('#\(.*\)#U', $query, $matches);
196 - try {
197 - acym_query('ALTER TABLE `'.$tableName.'` DROP INDEX `'.$oldName.'`, ADD INDEX `'.$newName.'`'.$matches[0]);
198 - } catch (\Exception $exception) {
199 - if (function_exists('acym_logError')) {
200 - acym_logError('Error while renaming index '.$oldName.', with the error '.$exception->getMessage());
201 - }
202 - }
203 - }
204 - }
205 -
206 - if (!empty($constraints[$tableName])) {
207 - acym_query('SET FOREIGN_KEY_CHECKS=0;');
208 - foreach ($constraints[$tableName] as $newName => $constraintInfo) {
209 - $oldName = str_replace('#__fk_', 'fk_#__', $newName);
210 - $query = 'ALTER TABLE '.$tableName.' DROP FOREIGN KEY `'.$oldName.'`,ADD CONSTRAINT `'.$newName.'` FOREIGN KEY (`'.$constraintInfo['column'].'`) REFERENCES `'.$constraintInfo['table'].'` (`'.$constraintInfo['table_column'].'`) ON DELETE NO ACTION ON UPDATE NO ACTION;';
211 - try {
212 - acym_query($query);
213 - } catch (\Exception $exception) {
214 - if (function_exists('acym_logError')) {
215 - acym_logError('Error while renaming foreign key '.$oldName.', with the error '.$exception->getMessage());
216 - }
217 - }
218 - }
219 - acym_query('SET FOREIGN_KEY_CHECKS=1;');
220 - }
221 - }
222 - }
223 -
224 - private function updateFor860(): void
225 - {
226 - if ($this->isPreviousVersionAtLeast('8.6.0')) {
227 - return;
228 - }
229 -
230 - $ruleClass = new RuleClass();
231 -
232 - $rule = new \stdClass();
233 - $rule->name = 'ACYM_SUPPRESSION_LIST';
234 - $rule->ordering = 2;
235 - $rule->regex = 'suppression list';
236 - $rule->executed_on = '["body"]';
237 - $rule->action_message = '["delete_message"]';
238 - $rule->action_user = '["unsubscribe_user","block_user","empty_queue_user"]';
239 - $rule->active = 1;
240 - $rule->increment_stats = 1;
241 - $rule->execute_action_after = 0;
242 - $ruleClass->save($rule);
243 -
244 - $rule = new \stdClass();
245 - $rule->name = 'ACYM_REJECTED';
246 - $rule->ordering = 9;
247 - $rule->regex = 'rejected *your *message|email *provider *rejected *it';
248 - $rule->executed_on = '["body"]';
249 - $rule->action_message = '["delete_message"]';
250 - $rule->action_user = '[]';
251 - $rule->active = 1;
252 - $rule->increment_stats = 1;
253 - $rule->execute_action_after = 0;
254 - $ruleClass->save($rule);
255 -
256 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_sent_date` DATETIME NULL');
257 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_open_date` DATETIME NULL');
258 - $this->updateQuery('ALTER TABLE #__acym_user ADD COLUMN `last_click_date` DATETIME NULL');
259 -
260 - $this->updateQuery(
261 - 'CREATE TABLE IF NOT EXISTS `#__acym_mail_archive` (
262 - `id` INT NOT NULL AUTO_INCREMENT,
263 - `mail_id` INT NOT NULL,
264 - `date` INT(10) UNSIGNED NOT NULL,
265 - `body` LONGTEXT NOT NULL,
266 - `subject` VARCHAR(255) NULL,
267 - `settings` TEXT NULL,
268 - `stylesheet` TEXT NULL,
269 - `attachments` TEXT NULL,
270 - PRIMARY KEY (`id`),
271 - CONSTRAINT `#__fk_acym_mail_archive1`
272 - FOREIGN KEY (`mail_id`)
273 - REFERENCES `#__acym_mail`(`id`)
274 - ON DELETE NO ACTION
275 - ON UPDATE NO ACTION
276 - )
277 - ENGINE = InnoDB
278 - /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci*/;'
279 - );
280 - }
281 -
282 - private function updateFor862(): void
283 - {
284 - if ($this->isPreviousVersionAtLeast('8.6.2')) {
285 - return;
286 - }
287 -
288 - $this->updateQuery('DELETE FROM #__acym_campaign WHERE mail_id IS NULL');
289 -
290 - $mailsToClean = acym_loadResultArray(
291 - 'SELECT mail.id
292 - FROM `#__acym_mail` AS mail
293 - LEFT JOIN #__acym_campaign AS campaign
294 - ON mail.id = campaign.mail_id
295 - WHERE campaign.mail_id IS NULL
296 - AND mail.parent_id IS NULL
297 - AND mail.type = '.acym_escapeDB(MailClass::TYPE_STANDARD)
298 - );
299 -
300 - if (!empty($mailsToClean)) {
301 - acym_arrayToInteger($mailsToClean);
302 - $this->updateQuery('DELETE FROM #__acym_mail_archive WHERE mail_id IN ('.implode(',', $mailsToClean).')');
303 - $mailClass = new MailClass();
304 - $mailClass->delete($mailsToClean);
305 - }
306 - }
307 -
308 - private function updateFor870(): void
309 - {
310 - if ($this->isPreviousVersionAtLeast('8.7.0')) {
311 - return;
312 - }
313 -
314 - $this->updateQuery('ALTER TABLE #__acym_plugin DROP `features`');
315 - }
316 -
317 - private function updateFor872(ConfigurationClass $config): void
318 - {
319 - if ($this->isPreviousVersionAtLeast('8.7.2')) {
320 - return;
321 - }
322 -
323 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
324 - if (empty($socialIcons['X'])) {
325 - $socialIcons['X'] = ACYM_IMAGES.'logo/x.png';
326 -
327 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
328 - }
329 - }
330 -
331 - private function updateFor873(ConfigurationClass $config): void
332 - {
333 - if ($this->isPreviousVersionAtLeast('8.7.3')) {
334 - return;
335 - }
336 -
337 - $socialIcons = json_decode($config->get('social_icons', '{}'), true);
338 -
339 - if (!empty($socialIcons['X']) || empty($socialIcons['x'])) {
340 - if (!empty($socialIcons['X'])) {
341 - unset($socialIcons['X']);
342 - }
343 -
344 - if (empty($socialIcons['x'])) {
345 - $socialIcons['x'] = ACYM_IMAGES.'logo/x.png';
346 - }
347 -
348 - $config->saveConfig(['social_icons' => json_encode($socialIcons)]);
349 - }
350 - }
351 -
352 - private function updateFor874(ConfigurationClass $config): void
353 - {
354 - if ($this->isPreviousVersionAtLeast('8.7.4') || ACYM_CMS !== 'joomla') {
355 - return;
356 - }
357 -
358 - $config->saveConfig(['malicious_scan' => 1]);
359 - }
360 -
361 - private function updateFor881(ConfigurationClass $config): void
362 - {
363 - if ($this->isPreviousVersionAtLeast('8.7.0')) {
364 - return;
365 - }
366 -
367 - // Replace backslashes by slashes in the upload folder option
368 - $uploadFolder = $config->get('uploadfolder');
369 - if (!empty($uploadFolder) && strpos($uploadFolder, '\\') !== false) {
370 - $uploadFolder = str_replace('\\', '/', $uploadFolder);
371 - $config->saveConfig(['uploadfolder' => $uploadFolder]);
372 - }
373 - }
374 -}