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/Configuration.php +177 -0 10.1.0 → 11.1.0 View file →
@@ -1,0 +1,177 @@
1 +<?php
2 +
3 +namespace AcyMailing\Helpers\Update;
4 +
5 +use AcyMailing\Helpers\CronHelper;
6 +
7 +trait Configuration
8 +{
9 + public function addPref(): bool
10 + {
11 + $this->level = ucfirst($this->level);
12 +
13 + $allPref = acym_getDefaultConfigValues();
14 +
15 + $allPref['level'] = $this->level;
16 + $allPref['version'] = $this->version;
17 +
18 + $allPref['from_name'] = acym_getCMSConfig('fromname');
19 + $allPref['from_email'] = acym_getCMSConfig('mailfrom');
20 + $allPref['bounce_email'] = acym_getCMSConfig('mailfrom');
21 + $cmsMailer = acym_getCMSConfig('mailer', 'phpmail');
22 + $allPref['mailer_method'] = $cmsMailer === 'mail' ? 'phpmail' : $cmsMailer;
23 + $allPref['sendmail_path'] = acym_getCMSConfig('sendmail');
24 + $allPref['smtp_port'] = acym_getCMSConfig('smtpport');
25 + $allPref['smtp_secured'] = acym_getCMSConfig('smtpsecure');
26 + $allPref['smtp_auth'] = acym_getCMSConfig('smtpauth');
27 + $allPref['smtp_username'] = acym_getCMSConfig('smtpuser');
28 + $allPref['smtp_password'] = acym_getCMSConfig('smtppass');
29 +
30 + $allPref['replyto_name'] = $allPref['from_name'];
31 + $allPref['replyto_email'] = $allPref['from_email'];
32 + $allPref['cron_sendto'] = $allPref['from_email'];
33 +
34 + $allPref['add_names'] = '1';
35 + $allPref['encoding_format'] = '8bit';
36 + $allPref['charset'] = 'UTF-8';
37 + $allPref['embed_images'] = '0';
38 + $allPref['embed_files'] = '0';
39 + $allPref['editor'] = 'codemirror';
40 + $allPref['multiple_part'] = '1';
41 +
42 + $smtpinfos = explode(':', acym_getCMSConfig('smtphost', ''));
43 + $allPref['smtp_host'] = $smtpinfos[0];
44 + if (isset($smtpinfos[1])) {
45 + $allPref['smtp_port'] = $smtpinfos[1];
46 + }
47 + if (!in_array($allPref['smtp_secured'], ['tls', 'ssl'])) {
48 + $allPref['smtp_secured'] = '';
49 + }
50 +
51 + $allPref['social_icons'] = json_encode(
52 + [
53 + 'facebook' => ACYM_IMAGES.'logo/facebook.png',
54 + 'twitter' => ACYM_IMAGES.'logo/twitter.png',
55 + 'x' => ACYM_IMAGES.'logo/x.png',
56 + 'instagram' => ACYM_IMAGES.'logo/instagram.png',
57 + 'linkedin' => ACYM_IMAGES.'logo/linkedin.png',
58 + 'pinterest' => ACYM_IMAGES.'logo/pinterest.png',
59 + 'vimeo' => ACYM_IMAGES.'logo/vimeo.png',
60 + 'wordpress' => ACYM_IMAGES.'logo/wordpress.png',
61 + 'youtube' => ACYM_IMAGES.'logo/youtube.png',
62 + 'telegram' => ACYM_IMAGES.'logo/telegram.png',
63 + ]
64 + );
65 +
66 + $allPref['queue_nbmail'] = '40';
67 + $allPref['queue_nbmail_auto'] = '70';
68 + $allPref['queue_type'] = 'auto';
69 + $allPref['queue_try'] = '3';
70 + $allPref['queue_pause'] = '30';
71 + $allPref['allow_visitor'] = '1';
72 + $allPref['require_confirmation'] = '1';
73 + $allPref['priority_newsletter'] = '3';
74 + $allPref['allowed_files'] = 'zip,doc,docx,pdf,xls,txt,gzip,rar,jpg,jpeg,gif,xlsx,pps,csv,bmp,ico,odg,odp,ods,odt,png,ppt,swf,xcf,mp3,wma';
75 + $allPref['confirm_redirect'] = '';
76 + $allPref['subscription_message'] = '1';
77 + $allPref['cron_next'] = '1251990901';
78 + $allPref['confirmation_message'] = '1';
79 + $allPref['welcome_message'] = '1';
80 + $allPref['unsub_message'] = '1';
81 + $allPref['cron_last'] = '0';
82 + $allPref['cron_fromip'] = '';
83 + $allPref['cron_report'] = '';
84 + $allPref['cron_frequency'] = '900';
85 + $allPref['cron_sendreport'] = CronHelper::SEND_REPORT_ONLY_ON_ERROR;
86 + $allPref['cron_savereport'] = CronHelper::SEND_REPORT_ONLY_ON_ACTION;
87 + $allPref['direct_queue_statistics'] = 0;
88 + $allPref['uploadfolder'] = str_replace('\\', '/', ACYM_UPLOAD_FOLDER);
89 + $allPref['last_import'] = '';
90 + $allPref['security_key'] = acym_generateKey(30);
91 + $allPref['api_key'] = acym_generateKey(30);
92 + $allPref['cron_security'] = 1;
93 + $allPref['cron_key'] = acym_generateKey(30);
94 + $allPref['export_excelsecurity'] = 1;
95 + $allPref['gdpr_export'] = 0;
96 + $allPref['gdpr_delete'] = 0;
97 + $allPref['dont_track_by_default'] = 0;
98 + $allPref['user_tracking_control'] = 0;
99 + $allPref['trackingsystem'] = 'acymailing';
100 + $allPref['trackingsystemexternalwebsite'] = 1;
101 + $allPref['generate_name'] = 1;
102 + $allPref['allow_modif'] = 'data';
103 + $allPref['from_as_replyto'] = '1';
104 + $allPref['bounceVersion'] = self::BOUNCE_VERSION;
105 + $allPref['numberThumbnail'] = 2;
106 + $allPref['daily_hour'] = '12';
107 + $allPref['daily_minute'] = '00';
108 + $allPref['regacy'] = 1;
109 + $allPref['regacy_delete'] = 1;
110 + $allPref['regacy_forceconf'] = 0;
111 + $allPref['remindme'] = '[]';
112 + $allPref['notifications'] = '{}';
113 + $allPref['unsubscribe_page'] = 1;
114 + $allPref['delete_stats_enabled'] = 1;
115 + $allPref['delete_stats'] = 86400 * 360;
116 + $allPref['delete_archive_history_after'] = 86400 * 90;
117 +
118 + $allPref['install_date'] = time();
119 + $allPref['license_key'] = '';
120 + $allPref['active_cron'] = 0;
121 + $allPref['multilingual'] = 0;
122 +
123 + $allPref['walk_through'] = '1';
124 + $allPref['migration'] = '0';
125 + $allPref['installcomplete'] = '0';
126 +
127 + $allPref['Starter'] = ACYM_STARTER;
128 + $allPref['Essential'] = ACYM_ESSENTIAL;
129 + $allPref['Enterprise'] = ACYM_ENTERPRISE;
130 + $allPref['previous_version'] = '11.1.0';
131 +
132 + $allPref['display_built_by'] = acym_level(ACYM_ESSENTIAL) ? 0 : 1;
133 + $allPref['php_overrides'] = 0;
134 +
135 + $query = 'INSERT IGNORE INTO `#__acym_configuration` (`name`,`value`) VALUES ';
136 + foreach ($allPref as $namekey => $value) {
137 + $query .= '('.acym_escapeDB($namekey).','.acym_escapeDB($value).'),';
138 + }
139 + $query = rtrim($query, ',');
140 +
141 + return $this->updateQuery($query, 'display');
142 + }
143 +
144 + public function updatePref(): bool
145 + {
146 + try {
147 + $results = acym_loadObjectList('SELECT `name`, `value` FROM `#__acym_configuration` WHERE `name` IN ("version", "level") LIMIT 2', 'name');
148 + } catch (\Exception $e) {
149 + $results = null;
150 + }
151 +
152 + if ($results === null) {
153 + acym_display(isset($e) ? $e->getMessage() : substr(acym_stripTags(acym_getDBError()), 0, 200).'...', 'error');
154 +
155 + return false;
156 + }
157 +
158 + if (!empty($results['version'])) {
159 + $this->firstInstallation = false;
160 + }
161 +
162 + if ($results['version']->value === $this->version && $results['level']->value === $this->level) {
163 + return true;
164 + }
165 +
166 + $this->isUpdating = true;
167 + $this->previousVersion = $results['version']->value;
168 +
169 + //We update the version properly as it's a new one which is now used.
170 + $query = 'REPLACE INTO `#__acym_configuration` (`name`,`value`) VALUES ("level",'.acym_escapeDB($this->level).')';
171 + $query .= ',("version",'.acym_escapeDB($this->version).')';
172 + $query .= ',("installcomplete","0")';
173 + $query .= ',("previous_version",'.acym_escapeDB($this->previousVersion).')';
174 +
175 + return $this->updateQuery($query);
176 + }
177 +}