PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.2.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.2.2
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
acymailing / back / Helpers / Update / DefaultData.php

DefaultData.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.2.2, at back/Helpers/Update/DefaultData.php

508 lines 42.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Helpers\Update;
4
5 use AcyMailing\Classes\ActionClass;
6 use AcyMailing\Classes\AutomationClass;
7 use AcyMailing\Classes\ConditionClass;
8 use AcyMailing\Classes\FieldClass;
9 use AcyMailing\Classes\ListClass;
10 use AcyMailing\Classes\MailClass;
11 use AcyMailing\Classes\OverrideClass;
12 use AcyMailing\Classes\PluginClass;
13 use AcyMailing\Classes\RuleClass;
14 use AcyMailing\Classes\StepClass;
15 use AcyMailing\Classes\UserClass;
16
17 trait DefaultData
18 {
19 public function installBounceRules(): void
20 {
21 $ruleClass = new RuleClass();
22 if ($ruleClass->getOrderingNumber() > 0) {
23 return;
24 }
25 $replyTo = $this->config->get('replyto_email');
26 $bounce = $this->config->get('bounce_email');
27 $from = $this->config->get('from_email');
28
29 $forwardEmail = $replyTo != $bounce ? $replyTo : $from;
30 if (empty($forwardEmail)) {
31 $forwardEmail = acym_currentUserEmail();
32 }
33
34 $forwardEmail = str_replace('"', '', $forwardEmail);
35
36 $query = "INSERT INTO `#__acym_rule` (`id`, `name`, `description`, `ordering`, `regex`, `executed_on`, `action_message`, `action_user`, `active`, `increment_stats`, `execute_action_after`) VALUES ";
37 $query .= "(1, 'ACYM_LIST_UNSUBSCRIBE_HANDLING', 'ACYM_LIST_UNSUBSCRIBE_HANDLING_DESC', 1, 'Please unsubscribe user ID \\\\d+', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 0, 0),";
38 $query .= "(2, 'ACYM_SUPPRESSION_LIST', 'ACYM_SUPPRESSION_LIST_DESC', 2, 'suppression list', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 1, 0),";
39 $query .= "(3, 'ACYM_ACTION_REQUIRED', 'ACYM_ACTION_REQUIRED_DESC', 3, 'action *requ|verif', '[\"subject\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 0, 0),";
40 $query .= "(4, 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT', 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT_DESC', 4, '(out|away) *(of|from)|vacation|vacanze|vacaciones|holiday|absen|congés|recept|acknowledg|thank you for|Auto *Response|Incident|Automati|Ticket|Resposta *automática', '[\"subject\"]', '[\"delete_message\"]', '[]', 1, 0, 0),";
41 $query .= "(5, 'ACYM_FEEDBACK_LOOP', 'ACYM_FEEDBACK_LOOP_DESC', 5, 'feedback|[email protected]|complaints@.{0,15}email-abuse.amazonses.com|complaint about message', '[\"senderInfo\",\"subject\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 0, 0),";
42 $query .= "(6, 'ACYM_FEEDBACK_LOOP_BODY', 'ACYM_FEEDBACK_LOOP_BODY_DESC', 6, 'Feedback-Type.{1,5}abuse', '[\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 1, 0),";
43 $query .= "(7, 'ACYM_MAILBOX_FULL', 'ACYM_MAILBOX_FULL_DESC', 7, '((mailbox|mailfolder|storage|quota|space|inbox) *(is)? *(over)? *(exceeded|size|storage|allocation|full|quota|maxi))|status(-code)? *(:|=)? *5.2.2|quota-issue|not *enough.{1,20}space|((over|exceeded|full|exhausted) *(allowed)? *(mail|storage|quota))|Space shortage', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
44 $query .= "(8, 'ACYM_BLOCKED_GOOGLE_GROUPS', 'ACYM_BLOCKED_GOOGLE_GROUPS_DESC', 8, 'message *rejected *by *Google *Groups', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 1, 0),";
45 $query .= "(9, 'ACYM_REJECTED', 'ACYM_REJECTED_DESC', 9, 'rejected *your *message|email *provider *rejected *it', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 1, 0),";
46 $query .= "(10, 'ACYM_MAILBOX_DOESNT_EXIST_1', 'ACYM_MAILBOX_DOESNT_EXIST_1_DESC', 10, '(Invalid|no such|unknown|bad|des?activated|inactive|unrouteable) *(mail|destination|recipient|user|address|person)|bad-mailbox|inactive-mailbox|not listed in.{1,20}directory|RecipNotFound|(user|mailbox|address|recipients?|host|account|domain) *(is|has been)? *(error|disabled|failed|unknown|unavailable|not *(found|available)|.{1,30}inactiv)|no *mailbox *here|user does.?n.t have.{0,30}account|no *longer *(active|working|in *use)|mail( *foi)? *desativado', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
47 $query .= "(11, 'ACYM_MESSAGE_BLOCKED_RECIPIENTS', 'ACYM_MESSAGE_BLOCKED_RECIPIENTS_DESC', 11, 'blocked *by|block *list|look(ed)? *like *spam|spam-related|spam *detected| CXBL | CDRBL | IPBL | URLBL |(unacceptable|banned|offensive|filtered|blocked|unsolicited) *(content|message|e?-?mail)|service refused|(status(-code)?|554) *(:|=)? *5.7.1|administratively *denied|blacklisted *IP|policy *reasons|rejected.{1,10}spam|junkmail *rejected|throttling *constraints|exceeded.{1,10}max.{1,40}hour|comply with required standards|421 RP-00|550 SC-00|550 DY-00|550 OU-00', '[\"body\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 1, 0),";
48 $query .= "(12, 'ACYM_MAILBOX_DOESNT_EXIST_2', 'ACYM_MAILBOX_DOESNT_EXIST_2_DESC', 12, 'status(-? ?code)? *(:|=)? *(550)? *5.(1.[1-6]|0.0|4.[0123467])|recipient *address *rejected|does *not *like *recipient|recipient *unknown *to *address|email *account *that *you *tried *to *reach *is *disabled', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
49 $query .= "(13, 'ACYM_DOMAIN_NOT_EXIST', 'ACYM_DOMAIN_NOT_EXIST_DESC', 13, 'No.{1,10}MX *(record|host)|host *does *not *receive *any *mail|bad-domain|connection.{1,10}mail.{1,20}fail|domain.{1,10}not *exist|fail.{1,10}establish *connection|Unable *to *lookup *DNS *for|Unable *to *connect *to *remote *host', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
50 $query .= "(14, 'ACYM_TEMPORARY_FAILURES', 'ACYM_TEMPORARY_FAILURES_DESC', 14, 'has.*been.*delayed|delayed *mail|message *delayed|message-expired|temporar(il)?y *(failure|unavailable|disable|offline|unable)|deferred|delayed *([0-9]*) *(hour|minut)|possible *mail *loop|too *many *hops|delivery *time *expired|Action.php: *delayed|status(-code)? *(:|=)? *4.4.6|will continue to be attempted|unable to deliver in.*Status: 4.4.7|Connection *closed *unexpectedly', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
51 $query .= "(15, 'ACYM_FAILED_PERM', 'ACYM_FAILED_PERM_DESC', 15, 'failed *permanently|permanent.{1,20}(failure|error)|not *accepting *(any)? *mail|does *not *exist|no *valid *route|delivery *failure', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),";
52 $query .= "(16, 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY', 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY_DESC', 16, 'vacanc|holiday|vacation|absen|urlaub|ferie|feriado|vacanz|vacaciones|(out *of|not *in|outside)( *the)? *office|automatisch *(generierte)? *Antwort|confirm *we(\\'ve| *have) *received|den *Ferien|automática|RISPOSTA AUTOMATICA|vakantie|recepcionado *(su *)?requerimiento|Kiitos viestistäsi|nicht im Büro|nicht am Arbeitsplatz|automatic *reply|auto(-|mated *|matic *)reply|Email *has *been *recived|ricevuto *il *Suo *messaggio|ticket|poza *biurem|Automatic *respon|Case *Number|Α�
53 τόματη *απάντηση', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 0, 0),";
54 $query .= "(17, 'ACYM_FINAL_RULE', 'ACYM_FINAL_RULE_DESC', 17, '.', '[\"senderInfo\",\"subject\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 0, 0);";
55
56 acym_query($query);
57
58 $this->config->save(['bounceVersion' => self::BOUNCE_VERSION]);
59 }
60
61 public function installFields(): void
62 {
63 $query = "INSERT IGNORE INTO #__acym_field (`id`, `name`, `type`, `value`, `active`, `default_value`, `required`, `ordering`, `option`, `core`, `backend_edition`, `backend_listing`, `frontend_edition`, `frontend_listing`, `namekey`) VALUES
64 (1, 'ACYM_NAME', 'text', NULL, 1, NULL, 0, 1, '{\"error_message\":\"\",\"error_message_invalid\":\"\",\"size\":\"\",\"rows\":\"\",\"columns\":\"\",\"format\":\"\",\"custom_text\":\"\",\"css_class\":\"\",\"authorized_content\":{\"0\":\"all\",\"regex\":\"\"}}', 1, 1, 1, 1, 1, 'acym_name'),
65 (2, 'ACYM_EMAIL', 'text', NULL, 1, NULL, 1, 2, '{\"error_message\":\"\",\"error_message_invalid\":\"\",\"size\":\"\",\"rows\":\"\",\"columns\":\"\",\"format\":\"\",\"custom_text\":\"\",\"css_class\":\"\",\"authorized_content\":{\"0\":\"all\",\"regex\":\"\"}}', 1, 1, 1, 1, 1, 'acym_email');";
66 acym_query($query);
67
68 $fieldClass = new FieldClass();
69 $fieldClass->insertLanguageField();
70 }
71
72 public function installTemplates(): void
73 {
74 $mailClass = new MailClass();
75 $installedTemplates = 0;
76
77 $templates = acym_getFiles(ACYM_BACK.'templates'.DS, '.zip', false, true);
78 foreach ($templates as $oneTemplate) {
79 $templateName = substr($oneTemplate, strrpos($oneTemplate, DS) + 1);
80 $templateName = substr($templateName, 0, strrpos($templateName, '.'));
81
82 $oneMail = $mailClass->getOneByName($templateName, false, MailClass::TYPE_TEMPLATE);
83 if (!empty($oneMail)) continue;
84
85 $templateFolder = $mailClass->extractTemplate($oneTemplate, false);
86 if (empty($templateFolder)) continue;
87
88 if ($mailClass->installExtractedTemplate($templateFolder)) {
89 $installedTemplates++;
90 }
91 }
92
93 if ($installedTemplates === 0) {
94 acym_enqueueMessage(acym_translation('ACYM_DEFAULT_TEMPLATES_ALREADY_INSTALL'), 'info');
95 }
96 }
97
98 public function installDefaultAutomations(): void
99 {
100 $this->newAutomationAdmin('ACYM_ADMIN_USER_CREATE');
101 $this->newAutomationAdmin('ACYM_ADMIN_USER_MODIFICATION');
102 }
103
104 public function installList(): void
105 {
106 $listClass = new ListClass();
107 $listClass->addDefaultList();
108 }
109
110 public function installNotifications(): bool
111 {
112 $searchSettings = [
113 'offset' => 0,
114 'mailsPerPage' => 9000,
115 'key' => 'name',
116 ];
117
118 $mailClass = new MailClass();
119 $notifications = $mailClass->getMailsByType(MailClass::TYPE_NOTIFICATION, $searchSettings);
120 $notifications = $notifications['mails'];
121 $user = $this->getCurrentUser();
122
123 $addNotif = [];
124
125 if (empty($notifications['acy_report'])) {
126 $addNotif[] = [
127 'name' => 'acy_report',
128 'subject' => 'AcyMailing Cron Report {mainreport}',
129 'content' => '<p>{report}</p><p>{detailreport}</p>',
130 ];
131 }
132
133 if (empty($notifications['acy_confirm'])) {
134 $addNotif[] = [
135 'name' => 'acy_confirm',
136 'subject' => '{subscriber:name|ucfirst}, {trans:ACYM_PLEASE_CONFIRM_SUBSCRIPTION}',
137 'content' => $this->getFormatedNotification(
138 '<h1 style="font-size: 24px;">{trans:ACYM_HELLO} '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
139 <p>{trans:ACYM_CONFIRM_MESSAGE}</p>
140 <p>{trans:ACYM_CONFIRM_MESSAGE_ACTIVATE}</p>
141 <p style="text-align: center;"><strong>{confirm}{trans:ACYM_CONFIRM_SUBSCRIPTION}{/confirm}</strong></p>'
142 ),
143 ];
144 }
145
146 if (empty($notifications['acy_notification_create'])) {
147 $addNotif[] = [
148 'name' => 'acy_notification_create',
149 'subject' => acym_translation('ACYM_NOTIFICATION_CREATE_SUBJECT').': {user:email}',
150 'content' => $this->getFormatedNotification(
151 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
152 <p>'.acym_translation('ACYM_NOTIFICATION_CREATE_BODY').'</p>
153 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
154 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>
155 <p>'.acym_translation('ACYM_SOURCE').': '.$this->getDTextDisplay('{user:source}', 'registration_form').'</p>
156 <p>'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2020-11-02 14:38:24').'</p>'
157 ),
158 ];
159 }
160
161 if (empty($notifications['acy_notification_unsub'])) {
162 $addNotif[] = [
163 'name' => 'acy_notification_unsub',
164 'subject' => acym_translation('ACYM_NOTIFICATION_UNSUB_SUBJECT').': {user:email}',
165 'content' => $this->getFormatedNotification(
166 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
167 <p>'.acym_translation('ACYM_NOTIFICATION_UNSUB_BODY').'</p>
168 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
169 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>
170 <p>'.acym_translation('ACYM_LISTS').': '.$this->getDTextDisplay('{lists}', 'Newsletters, Tips').'</p>'
171 ),
172 ];
173 }
174
175 if (empty($notifications['acy_notification_unsuball'])) {
176 $addNotif[] = [
177 'name' => 'acy_notification_unsuball',
178 'subject' => acym_translation('ACYM_NOTIFICATION_UNSUBALL_SUBJECT').': {user:email}',
179 'content' => $this->getFormatedNotification(
180 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
181 <p>'.acym_translation('ACYM_NOTIFICATION_UNSUBALL_BODY').'</p>
182 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
183 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>'
184 ),
185 ];
186 }
187
188 if (empty($notifications['acy_notification_subform'])) {
189 $addNotif[] = [
190 'name' => 'acy_notification_subform',
191 'subject' => acym_translation('ACYM_NOTIFICATION_SUBFORM_SUBJECT').': {user:email}',
192 'content' => $this->getFormatedNotification(
193 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
194 <p>'.acym_translation('ACYM_NOTIFICATION_SUBFORM_BODY').'</p>
195 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
196 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>
197 <p>'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'</p>'
198 ),
199 ];
200 }
201
202 if (empty($notifications['acy_notification_profile'])) {
203 $addNotif[] = [
204 'name' => 'acy_notification_profile',
205 'subject' => acym_translation('ACYM_NOTIFICATION_PROFILE_SUBJECT').': {user:email}',
206 'content' => $this->getFormatedNotification(
207 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
208 <p>'.acym_translation('ACYM_NOTIFICATION_PROFILE_BODY').'</p>
209 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
210 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>
211 <p>'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'</p>'
212 ),
213 ];
214 }
215
216 if (empty($notifications['acy_notification_confirm'])) {
217 $addNotif[] = [
218 'name' => 'acy_notification_confirm',
219 'subject' => acym_translation('ACYM_NOTIFICATION_CONFIRM_SUBJECT').': {user:email}',
220 'content' => $this->getFormatedNotification(
221 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
222 <p>'.acym_translation('ACYM_NOTIFICATION_CONFIRM_BODY').'</p>
223 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'</p>
224 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', '[email protected]').'</p>
225 <p>'.acym_translation('ACYM_IP').': '.$this->getDTextDisplay('{user:confirmation_ip}', '127.0.0.1').'</p>
226 <p>'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'</p>'
227 ),
228 ];
229 }
230
231 if (empty($notifications['acy_notification_cms'])) {
232 $addNotif[] = [
233 'name' => 'acy_notification_cms',
234 'subject' => '{subject}',
235 'content' => '{body}',
236 'drag_editor' => 0,
237 ];
238 }
239
240 if (empty($notifications['acy_notification_auto_campaign_admin'])) {
241 $addNotif[] = [
242 'name' => 'acy_notification_auto_campaign_admin',
243 'subject' => acym_translation('ACYM_NOTIFICATION_AUTO_CAMPAIGN_SUBJECT'),
244 'content' => $this->getFormatedNotification(
245 '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
246 <p>'.acym_translation('ACYM_NOTIFICATION_AUTO_CAMPAIGN_BODY').'</p>'
247 ),
248 ];
249 }
250
251 $firstEmail = $mailClass->getOneByName(acym_translation(self::FIRST_EMAIL_NAME_KEY));
252 if (empty($firstEmail)) {
253 $body = '<div id="acym__wysid__template" class="cell"><table class="body"><tbody><tr><td align="center" class="center acym__wysid__template__content" valign="top" style="background-color: rgb(239, 239, 239); padding: 30px 0px 120px;"><center><table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="acym__wysid__row ui-droppable ui-sortable" bgcolor="#ffffff" style="background-color: rgb(255, 255, 255); min-height: 0px; display: table-cell;"><table class="row acym__wysid__row__element" border="0" cellpadding="0" cellspacing="0" style="z-index: 100; background-color: rgb(238, 238, 238);" bgcolor="#eeeeee"><tbody bgcolor="" style="background-color: inherit;"><tr><th class="small-12 medium-12 large-12 columns" style="height: auto;"><table class="acym__wysid__column" style="min-height: 0px; display: table; height: auto;" border="0" cellpadding="0" cellspacing="0"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group; height: auto;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--text mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_41"><p style="font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; word-break: break-word; text-align: center; line-height: inherit;"><span style="font-size: 12px;">Having trouble seeing this email?&nbsp;<span class="mceNonEditable acym_dynamic" contenteditable="false" data-dynamic="{readonline}View it online{/readonline}"><a style="text-decoration: none; font-family: Helvetica; font-size: 12px; font-weight: normal; line-height: inherit; font-style: normal; color: #38c2f3;" href="view_it_online_link" target="_blank" rel="noopener"><span class="acym_online">View it online</span></a><em class="acym_remove_dynamic acymicon-close">‍‍</em></span>&nbsp;</span></p></div></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#ffffff" style="background-color: rgb(255, 255, 255); z-index: 100;" cellpadding="0" cellspacing="0" border="0"><tbody bgcolor="" style="background-color: inherit;"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th" valign="top"><table class="acym__wysid__column" border="0" cellpadding="0" cellspacing="0" style="min-height: 0px; display: table;"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="height: 21px; outline-width: 0px;"><span class="acy-editor__space" style="display:block; padding: 0;margin: 0; height: 100%"></span></td></tr><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--image mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_45"><p style="font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; word-break: break-word; line-height: inherit;"><img class="acym__wysid__media__inserted" style="max-width: 100%; height: 85px; box-sizing: border-box; padding: 0px 5px; display: block; margin-left: auto; margin-right: auto; width: 306px;" src="'.ACYM_LIVE.ACYM_UPLOAD_FOLDER.'logo_acymailing_step_email.png" alt="logo_acymailing_step_email.png" height="85" width="306"></p></div></td></tr><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="height: 29px; outline-width: 0px;"><span class="acy-editor__space" style="display:block; padding: 0;margin: 0; height: 100%"></span></td></tr><tr class="acym__wysid__column__element acym__wysid__column__element__separator cursor-pointer ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><hr style="border-bottom: 3px solid rgb(214, 214, 214); width: 24%; border-top: none; border-left: none; border-right: none; size: 3px;" class="acym__wysid__row__separator"></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#ffffff" style="background-color: rgb(255, 255, 255); z-index: 100;" cellpadding="0" cellspacing="0" border="0"><tbody bgcolor="" style="background-color: inherit;"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th" valign="top"><table class="acym__wysid__column" border="0" cellpadding="0" cellspacing="0" style="min-height: 0px; display: table;"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--text mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_42"><h1 style="font-family: Helvetica; font-size: 20px; font-weight: normal; font-style: normal; color: #000000; line-height: inherit; text-align: left;">Dear&nbsp;<span class="mceNonEditable acym_dynamic" contenteditable="false" data-dynamic="{subscriber:name|part:first|ucfirst}">Admin<em class="acym_remove_dynamic acymicon-close">‍‍</em></span>,</h1></div></td></tr><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--text mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_43"><p style="word-break: break-word; font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; line-height: inherit; text-align: left;"><span style="color: #000000;"><span style="font-family: Helvetica;">Feel free to drag &amp; drop some content and&nbsp;</span><span style="font-family: Helvetica;">try the AcyMailing editor.</span></span></p><p style="word-break: break-word; font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; line-height: inherit; text-align: left;"><span style="color: #000000; font-family: Helvetica;">Once it is done, click on the "Apply" button.</span></p></div></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#ffffff" style="background-color: rgb(255, 255, 255); z-index: 100; padding: 0px;" cellpadding="0" cellspacing="0" border="0"><tbody bgcolor="" style="background-color: inherit;"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th" valign="top"><table class="acym__wysid__column" border="0" cellpadding="0" cellspacing="0" style="min-height: 0px; display: table;"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--image mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_46"><p style="font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; word-break: break-word; line-height: inherit;"><img class="acym__wysid__media__inserted" style="max-width: 100%; height: auto; box-sizing: border-box; padding: 0px 5px; display: block; margin-left: auto; margin-right: auto; width: 580px;" src="'.ACYM_LIVE.ACYM_UPLOAD_FOLDER.'image_mailing_step_email.jpg" alt="image_mailing_step_email.jpg" height="400.68" width="580"></p></div></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#303e47" style="background-color: rgb(48, 62, 71); z-index: 100;" cellpadding="0" cellspacing="0" border="0"><tbody bgcolor="" style="background-color: inherit;"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th" valign="top"><table class="acym__wysid__column" border="0" cellpadding="0" cellspacing="0" style="min-height: 0px; display: table;"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline-width: 0px;"><div class="acym__wysid__tinymce--text mce-content-body" style="position: relative;" spellcheck="false" contenteditable="false" id="mce_44"><p style="font-family: Helvetica; font-size: 12px; font-weight: normal; font-style: normal; color: #000000; text-align: center; word-break: break-word; line-height: inherit;"><span style="color: #ffffff;">If you\'re not interested anymore, you can</span> <span class="mceNonEditable acym_dynamic" data-dynamic="{unsubscribe}unsubscribe{/unsubscribe}" contenteditable="false"><a style="text-decoration: none; font-family: Helvetica; font-size: 12px; font-weight: normal; line-height: inherit; font-style: normal; color: #38c2f3;" target="_blank" href="'.acym_frontendLink(
254 'frontusers&task=unsubscribe&id='.$user->id.'&key='.$user->key.'&'.acym_noTemplate()
255 ).'" rel="noopener"><span class="acym_unsubscribe acym_link" style="font-family: Helvetica; font-size: 12px; font-weight: normal; line-height: inherit; font-style: normal; color: #ffffff;">unsubscribe</span></a><em class="acym_remove_dynamic acymicon-close">‍</em></span></p></div></td></tr></tbody></table></th></tr></tbody></table></td></tr></tbody></table></center></td></tr></tbody></table></div>';
256
257 $addNotif[] = [
258 'name' => acym_translation(self::FIRST_EMAIL_NAME_KEY),
259 'subject' => acym_translation('ACYM_YOUR_FIRST_EMAIL'),
260 'content' => $body,
261 'settings' => '{"default":{"font-family":"Helvetica"},"p":{"font-family":"Helvetica","font-size":"12px","overridden":{"font-size":true,"line-height":true},"line-height":"inherit"},"a":{"font-family":"Helvetica","font-size":"12px","overridden":{"font-size":true,"line-height":true,"color":true},"line-height":"inherit","color":"#38c2f3"},"span.acym_link":{"font-family":"Helvetica","font-size":"12px","overridden":{"font-size":true,"line-height":true,"color":true},"line-height":"inherit","color":"#ffffff"},"h1":{"font-family":"Helvetica","font-size":"20px","overridden":{"font-size":true,"line-height":true},"line-height":"inherit"}}',
262 'type' => MailClass::TYPE_TEMPLATE,
263 'thumbnail' => 'thumbnail_first_email.png',
264 ];
265 $mailingImage = 'image_mailing_step_email.jpg';
266 $logoAcymailing = 'logo_acymailing_step_email.png';
267 $thumbnailFirstStep = 'thumbnail_first_email.png';
268
269 $uploadFolder = ACYM_ROOT.ACYM_UPLOAD_FOLDER;
270 $defaultImagesFolder = ACYM_ROOT.ACYM_MEDIA_FOLDER.'images'.DS.'templates'.DS.'first_email'.DS;
271
272 acym_createFolder($uploadFolder);
273 acym_createFolder(ACYM_UPLOAD_FOLDER_THUMBNAIL);
274
275 if (!file_exists($uploadFolder.$mailingImage)) {
276 copy(
277 $defaultImagesFolder.$mailingImage,
278 $uploadFolder.$mailingImage
279 );
280 }
281 if (!file_exists($uploadFolder.$logoAcymailing)) {
282 copy(
283 $defaultImagesFolder.$logoAcymailing,
284 $uploadFolder.$logoAcymailing
285 );
286 }
287 if (!file_exists(ACYM_UPLOAD_FOLDER_THUMBNAIL.$thumbnailFirstStep)) {
288 copy(
289 $defaultImagesFolder.$thumbnailFirstStep,
290 ACYM_UPLOAD_FOLDER_THUMBNAIL.$thumbnailFirstStep
291 );
292 }
293 }
294
295 if (!empty($addNotif)) {
296 foreach ($addNotif as $oneNotif) {
297 $notif = new \stdClass();
298 $notif->type = $oneNotif['type'] ?? MailClass::TYPE_NOTIFICATION;
299 $notif->settings = $oneNotif['settings'] ?? '';
300 $notif->drag_editor = $oneNotif['drag_editor'] ?? 1;
301 $notif->creator_id = acym_currentUserId();
302 $notif->creation_date = date('Y-m-d H:i:s', time() - date('Z'));
303 $notif->name = $oneNotif['name'];
304 $notif->subject = $oneNotif['subject'];
305 $notif->body = $oneNotif['content'];
306 $notif->thumbnail = $oneNotif['thumbnail'] ?? '';
307
308 $notif->id = $mailClass->save($notif);
309 if (empty($notif->id)) {
310 acym_enqueueMessage(acym_translationSprintf('ACYM_ERROR_INSTALLING_X_TEMPLATE', $notif->name), 'error');
311
312 return false;
313 }
314
315 if (strpos($notif->body, 'view_it_online_link') !== false) {
316 $viewItOnlineLink = 'archive&task=view&id='.$notif->id.'&userid='.$user->id.'-'.$user->key.'&'.acym_noTemplate();
317 $notif->body = str_replace('view_it_online_link', acym_frontendLink($viewItOnlineLink), $notif->body);
318 $mailClass->save($notif);
319 }
320 }
321 }
322
323 return true;
324 }
325
326 public function installAddons(): void
327 {
328 $pluginClass = new PluginClass();
329 $installedAddons = array_keys($pluginClass->getAll('folder_name'));
330 $coreAddons = acym_coreAddons();
331
332 foreach ($coreAddons as $oneAddon) {
333 if (in_array($oneAddon->folder_name, $installedAddons)) {
334 continue;
335 }
336
337 $pluginClass->save($oneAddon);
338 }
339 }
340
341 public function installOverrideEmails(): void
342 {
343 $overrideClass = new OverrideClass();
344 $mailClass = new MailClass();
345 $currentUserId = acym_currentUserId();
346
347 $emailOverrides = acym_getEmailOverrides();
348 $existingOverrides = $mailClass->getMailsByType(MailClass::TYPE_OVERRIDE, ['offset' => 0, 'mailsPerPage' => 9000, 'key' => 'name']);
349 $existingOverrides = $existingOverrides['mails'];
350
351 foreach ($emailOverrides as $oneOverride) {
352 if (!empty($existingOverrides[$oneOverride['name']])) {
353 continue;
354 }
355
356 $mail = new \stdClass();
357 $mail->name = $oneOverride['name'];
358 $mail->creation_date = date('Y-m-d H:i:s', time() - date('Z'));
359 $mail->type = MailClass::TYPE_OVERRIDE;
360 $mail->subject = $oneOverride['new_subject'];
361 $mail->body = $this->getFormatedNotification($oneOverride['new_body']);
362 $mail->drag_editor = 1;
363 $mail->creator_id = $currentUserId;
364 $mailId = $mailClass->save($mail);
365
366 if (empty($mailId)) {
367 continue;
368 }
369
370 $override = new \stdClass();
371 $override->mail_id = $mailId;
372 $override->description = $oneOverride['description'];
373 $override->source = $oneOverride['source'];
374 $override->active = 0;
375 $override->base_subject = json_encode($oneOverride['base_subject']);
376 $override->base_body = empty($oneOverride['base_body']) ? '' : json_encode($oneOverride['base_body']);
377
378 $overrideClass->save($override);
379 }
380 }
381
382 private function newAutomationAdmin(string $title): void
383 {
384 $automationClass = new AutomationClass();
385 $stepClass = new StepClass();
386 $conditionClass = new ConditionClass();
387 $mailClass = new MailClass();
388 $actionClass = new ActionClass();
389
390 $adminCreate = new \stdClass();
391 $adminCreate->desc = 'ACYM_ADMIN_USER_CREATE_DESC';
392 $adminCreate->triggers = '{"user_creation":[""],"type_trigger":"user"}';
393 $adminCreate->conditions = '{"type_condition":"user"}';
394 $adminCreate->emailTitle = acym_translation('ACYM_SUBSCRIBER_CREATION');
395 $adminCreate->emailSubject = acym_translation('ACYM_SUBSCRIBER_CREATION');
396 $adminCreate->emailContent = '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
397 <p>'.acym_translation('ACYM_NEW_USER_ACYMAILING').':</p>
398 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{subscriber:name|info:current}', 'Roger').'</p>
399 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{subscriber:email|info:current}', '[email protected]').'</p>';
400
401 $adminModif = new \stdClass();
402 $adminModif->desc = 'ACYM_ADMIN_USER_MODIFICATION_DESC';
403 $adminModif->triggers = '{"user_modification":[""],"type_trigger":"user"}';
404 $adminModif->conditions = '{"type_condition":"user"}';
405 $adminModif->emailTitle = acym_translation('ACYM_SUBSCRIBER_MODIFICATION');
406 $adminModif->emailSubject = acym_translation('ACYM_SUBSCRIBER_MODIFICATION');
407 $adminModif->emailContent = '<h1 style="font-size: 24px;">'.acym_translation('ACYM_HELLO').' '.$this->getDTextDisplay('{subscriber:name|ucfirst}', 'Marc').',</h1>
408 <p>'.acym_translation('ACYM_USER_MODIFY_ACYMAILING').':</p>
409 <p>'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{subscriber:name|info:current}', 'Roger').'</p>
410 <p>'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{subscriber:email|info:current}', '[email protected]').'</p>';
411
412 $info = [
413 'ACYM_ADMIN_USER_CREATE' => $adminCreate,
414 'ACYM_ADMIN_USER_MODIFICATION' => $adminModif,
415 ];
416
417 $newAutomation = new \stdClass();
418 $newAutomation->name = acym_translation($title);
419 $newAutomation->description = acym_translation($info[$title]->desc);
420 $newAutomation->active = 0;
421 $newAutomation->admin = 1;
422 $newAutomation->id = $automationClass->save($newAutomation);
423 if (empty($newAutomation->id)) {
424 return;
425 }
426
427 $newStep = new \stdClass();
428 $newStep->name = acym_translation($title);
429 $newStep->triggers = $info[$title]->triggers;
430 $newStep->automation_id = $newAutomation->id;
431 $newStep->id = $stepClass->save($newStep);
432 if (empty($newStep->id)) {
433 return;
434 }
435
436 $newCondition = new \stdClass();
437 $newCondition->step_id = $newStep->id;
438 $newCondition->conditions = $info[$title]->conditions;
439 $newCondition->id = $conditionClass->save($newCondition);
440 if (empty($newCondition->id)) {
441 return;
442 }
443
444 $mailAutomation = new \stdClass();
445 $mailAutomation->type = MailClass::TYPE_AUTOMATION;
446 $mailAutomation->drag_editor = 1;
447 $mailAutomation->creator_id = acym_currentUserId();
448 $mailAutomation->creation_date = date('Y-m-d H:i:s', time() - date('Z'));
449 $mailAutomation->name = acym_translation($info[$title]->emailTitle);
450 $mailAutomation->subject = acym_translation($info[$title]->emailSubject);
451 $mailAutomation->body = $this->getFormatedNotification($info[$title]->emailContent);
452
453 $mailAutomation->id = $mailClass->save($mailAutomation);
454 if (empty($mailAutomation->id)) {
455 return;
456 }
457
458 $newAction = new \stdClass();
459 $newAction->condition_id = $newCondition->id;
460 $newAction->actions = '[{"acy_add_queue":{"mail_id":"'.intval($mailAutomation->id).'","time":"[time]"}}]';
461 $newAction->filters = '{"0":{"1":{"acy_field":{"field":"email","operator":"=","value":"'.acym_currentUserEmail().'"}}},"type_filter":"classic"}';
462 $newAction->order = 1;
463 $newAction->id = $actionClass->save($newAction);
464 }
465
466 private function getDTextDisplay(string $dtext, string $preview): string
467 {
468 $display = '<span class="acym_dynamic mceNonEditable" contenteditable="false" data-dynamic="'.acym_escape($dtext).'" data-mce-selected="1">';
469 $display .= $preview;
470 $display .= '<em class="acym_remove_dynamic acymicon-close">&zwj;</em>';
471 $display .= '</span>';
472
473 return $display;
474 }
475
476 private function getFormatedNotification(string $content): string
477 {
478 $beginning = '<div id="acym__wysid__template" class="cell"><table class="body"><tbody><tr><td align="center" class="center acym__wysid__template__content" valign="top" style="background-color: rgb(239, 239, 239); padding: 40px 0 120px 0;"><center><table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="acym__wysid__row ui-droppable ui-sortable" style="min-height: 0px; display: table-cell;"><table class="row acym__wysid__row__element" bgcolor="#dadada" border="0" cellpadding="0" cellspacing="0"><tbody style="background-color: rgb(218,218,218);" bgcolor="#ffffff"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th"><table class="acym__wysid__column" style="min-height: 0px; display: table;" border="0" cellpadding="0" cellspacing="0"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline: rgb(0,163,254) dashed 0px; outline-offset: -1px;"><span class="acy-editor__space acy-editor__space--focus" style="display: block; padding: 0px; margin: 0px; height: 10px;"></span></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0"><tbody style="background-color: transparent;" bgcolor="#ffffff"><tr><th class="small-12 medium-12 large-12 columns"><table class="acym__wysid__column" style="min-height: 0px; display: table;" border="0" cellpadding="0" cellspacing="0"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline: rgb(0, 163, 254) dashed 0px; outline-offset: -1px;"><div class="acym__wysid__tinymce--text mce-content-body" style="position: relative;" spellcheck="false">';
479 $ending = '</div></td></tr></tbody></table></th></tr></tbody></table><table class="row acym__wysid__row__element" bgcolor="#dadada" style="position: relative; z-index: 100; top: 0; left: 0;" border="0" cellpadding="0" cellspacing="0"><tbody style="background-color: rgb(218, 218, 218);" bgcolor="#ffffff"><tr><th class="small-12 medium-12 large-12 columns acym__wysid__row__element__th"><table class="acym__wysid__column" style="min-height: 0px; display: table;" border="0" cellpadding="0" cellspacing="0"><tbody class="ui-sortable" style="min-height: 0px; display: table-row-group;"><tr class="acym__wysid__column__element ui-draggable" style="position: relative; top: inherit; left: inherit; right: inherit; bottom: inherit; height: auto;"><td class="large-12 acym__wysid__column__element__td" style="outline: rgb(0, 163, 254) dashed 0px; outline-offset: -1px;"><span class="acy-editor__space acy-editor__space--focus" style="display: block; padding: 0px; margin: 0px; height: 10px;"></span></td></tr></tbody></table></th></tr></tbody></table></td></tr></tbody></table></center></td></tr></tbody></table></div>';
480
481 return $beginning.$content.$ending;
482 }
483
484 private function getCurrentUser()
485 {
486 $currentCMSId = acym_currentUserId();
487 $userClass = new UserClass();
488 $user = $userClass->getOneByCMSId($currentCMSId);
489 if (!empty($user)) {
490 return $user;
491 }
492
493 $currentCMSEmail = acym_currentUserEmail();
494 $user = $userClass->getOneByEmail($currentCMSEmail);
495 if (!empty($user)) {
496 return $user;
497 }
498
499 $newUser = new \stdClass();
500 $newUser->email = $currentCMSEmail;
501 $newUser->confirmed = 1;
502 $newUser->cms_id = $currentCMSId;
503 $newUser->id = $userClass->save($newUser);
504
505 return $userClass->getOneById($newUser->id);
506 }
507 }
508