PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.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
acymailing / back / Classes / FollowupClass.php

FollowupClass.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Classes/FollowupClass.php

667 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Classes;
4
5 use AcyMailing\Helpers\PaginationHelper;
6 use AcyMailing\Core\AcymClass;
7
8 class FollowupClass extends AcymClass
9 {
10 const DEFAULT_DELAY_UNIT = 86400;
11 const DELAY_UNIT = [
12 60 => 'ACYM_MINUTES',
13 3600 => 'ACYM_HOURS',
14 86400 => 'ACYM_DAYS',
15 604800 => 'ACYM_WEEKS',
16 2628000 => 'ACYM_MONTHS',
17 ];
18
19 public function __construct()
20 {
21 parent::__construct();
22
23 $this->table = 'followup';
24 $this->pkey = 'id';
25 }
26
27 public function getDelayUnits()
28 {
29 $return = self::DELAY_UNIT;
30 foreach ($return as $key => $value) {
31 $return[$key] = acym_translation($value);
32 }
33
34 return $return;
35 }
36
37 public function getMatchingElements(array $settings = []): array
38 {
39 $query = 'SELECT `followup`.*, COUNT(`mails`.`mail_id`) AS nbEmails
40 FROM #__acym_followup AS followup
41 LEFT JOIN #__acym_followup_has_mail AS mails
42 ON followup.id = mails.followup_id';
43
44 $queryCount = 'SELECT COUNT(*)
45 FROM #__acym_followup AS followup ';
46
47 $filters = [];
48
49 if (!empty($settings['search'])) {
50 $filters[] = 'followup.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
51 }
52
53 if (!empty($filters)) {
54 $query .= ' WHERE ('.implode(') AND (', $filters).')';
55 $queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
56 }
57
58 $query .= ' GROUP BY `followup`.`id` ';
59
60 if (empty($settings['ordering'])) $settings['ordering'] = $this->pkey;
61 $query .= ' ORDER BY `'.acym_secureDBColumn($settings['ordering']).'`';
62 if (!empty($settings['ordering_sort_order'])) $query .= ' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
63
64 if (empty($settings['offset']) || $settings['offset'] < 0) {
65 $settings['offset'] = 0;
66 }
67
68 if (empty($settings['elementsPerPage']) || $settings['elementsPerPage'] < 1) {
69 $pagination = new PaginationHelper();
70 $settings['elementsPerPage'] = $pagination->getListLimit();
71 }
72
73 $results = [];
74 $results['elements'] = acym_loadObjectList($query, '', $settings['offset'], $settings['elementsPerPage']);
75 $urlClickClass = new UrlClickClass();
76 foreach ($results['elements'] as $key => $oneFollowup) {
77 $results['elements'][$key]->subscribers = $this->getNumberSubscribersByListId($oneFollowup->list_id);
78 $this->getGlobalStats($results['elements'][$key], $urlClickClass);
79 }
80
81 $results['total'] = acym_loadResult($queryCount);
82
83 return $results;
84 }
85
86 public function getNumberSubscribersByListId($listId = 0, $onlySubscribed = false)
87 {
88 if (empty($listId)) return 0;
89
90 $query = 'SELECT COUNT(*)
91 FROM #__acym_user_has_list
92 WHERE `list_id` = '.intval($listId);
93
94 if ($onlySubscribed) {
95 $query .= ' AND `status` = 1';
96 }
97
98 return acym_loadResult($query);
99 }
100
101 private function getGlobalStats(&$element, $urlClickClass)
102 {
103 $mailsStats = acym_loadObjectList(
104 'SELECT mail_stat.*
105 FROM #__acym_mail_stat AS mail_stat
106 JOIN #__acym_followup_has_mail AS fhm ON fhm.mail_id = mail_stat.mail_id
107 WHERE fhm.followup_id = '.intval($element->id)
108 );
109
110 $element->open = 0;
111 $element->click = 0;
112 $element->income = 0;
113 $numberMailSent = 0;
114 if (empty($mailsStats)) return;
115
116 foreach ($mailsStats as $key => $mailsStat) {
117 $element->open += $mailsStat->open_unique;
118 $element->click += $urlClickClass->getNumberUsersClicked($mailsStat->mail_id);
119 $numberMailSent += $mailsStat->sent;
120 }
121
122 if (!empty($numberMailSent)) {
123 $element->open = number_format($element->open / $numberMailSent * 100, 2);
124 $element->click = number_format($element->click / $numberMailSent * 100, 2);
125 }
126
127 if (!acym_isTrackingSalesActive()) return;
128
129 $trackingSales = acym_loadObject(
130 'SELECT SUM(user_stat.tracking_sale) AS sale, user_stat.currency
131 FROM #__acym_user_stat AS user_stat
132 JOIN #__acym_followup_has_mail AS fhm ON fhm.mail_id = user_stat.mail_id
133 WHERE fhm.followup_id = '.intval($element->id)
134 );
135
136 $element->sale = $trackingSales->sale;
137 if (empty($element->currency)) $element->currency = '';
138 acym_trigger('getCurrency', [&$element->currency]);
139 }
140
141 public function delete($elements)
142 {
143 if (!is_array($elements)) $elements = [$elements];
144 acym_arrayToInteger($elements);
145
146 if (empty($elements)) return 0;
147
148 $emailIds = $this->getEmailsByIds($elements);
149 if (!empty($emailIds)) {
150 $mailClass = new MailClass();
151 $mailClass->delete($emailIds);
152 }
153
154 $listIds = $this->getListsByIds($elements);
155
156 $result = parent::delete($elements);
157
158 $listClass = new ListClass();
159 $listClass->delete($listIds);
160
161 return $result;
162 }
163
164 public function getEmailsByIds($followupIds)
165 {
166 if (!is_array($followupIds)) $followupIds = [$followupIds];
167 acym_arrayToInteger($followupIds);
168
169 if (empty($followupIds)) return [];
170
171 return acym_loadResultArray(
172 'SELECT `mail_id`
173 FROM #__acym_followup_has_mail
174 WHERE `followup_id` IN ('.implode(', ', $followupIds).')
175 ORDER BY `delay`*`delay_unit` ASC'
176 );
177 }
178
179 public function getListsByIds($followupIds)
180 {
181 if (!is_array($followupIds)) $followupIds = [$followupIds];
182 acym_arrayToInteger($followupIds);
183
184 if (empty($followupIds)) return [];
185
186 return acym_loadResultArray(
187 'SELECT `list_id`
188 FROM #__acym_followup
189 WHERE `id` IN ('.implode(', ', $followupIds).')'
190 );
191 }
192
193 public function getOneById($id)
194 {
195 $followup = parent::getOneById($id);
196
197 if (empty($followup)) return false;
198
199 if (!empty($followup->condition)) {
200 $followup->condition = json_decode($followup->condition, true);
201 }
202
203 if (!empty($followup->loop_mail_skip)) {
204 $followup->loop_mail_skip = json_decode($followup->loop_mail_skip, true);
205 }
206
207 return $followup;
208 }
209
210 public function getOneByListId($listId)
211 {
212 $followup = acym_loadObject('SELECT * FROM `#__acym_followup` WHERE `list_id` = '.intval($listId));
213
214 if (empty($followup)) return null;
215
216 if (!empty($followup->condition)) $followup->condition = json_decode($followup->condition, true);
217
218 return $followup;
219 }
220
221 public function save($element)
222 {
223 if (!empty($element->condition) && is_array($element->condition)) {
224 $element->condition = json_encode($element->condition);
225 }
226
227 if (!empty($element->loop_mail_skip) && is_array($element->loop_mail_skip)) {
228 $element->loop_mail_skip = json_encode($element->loop_mail_skip);
229 }
230
231 $this->updateListFollowup($element);
232
233 return parent::save($element);
234 }
235
236 private function updateListFollowup(&$element)
237 {
238 $listClass = new ListClass();
239 if (empty($element->list_id)) {
240 $list = new \stdClass();
241 $list->name = $element->display_name;
242 $list->description = '';
243 $randColor = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
244 $list->color = '#'.$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)];
245 $list->access = '';
246 $list->type = ListClass::LIST_TYPE_FOLLOWUP;
247 } else {
248 $list = $listClass->getOneById($element->list_id);
249 $list->name = $element->display_name;
250 }
251
252 $element->list_id = $listClass->save($list);
253 }
254
255 public function getTriggerNiceName($trigger)
256 {
257 $triggers = [];
258 acym_trigger('getFollowupTriggers', [&$triggers]);
259 if (key_exists($trigger, $triggers)) {
260 return $triggers[$trigger];
261 }
262
263 return '';
264 }
265
266 public function getConditionSummary($condition, $trigger)
267 {
268 $statusArray = [
269 'is' => acym_strtolower(acym_translation('ACYM_IS')),
270 'is_not' => acym_strtolower(acym_translation('ACYM_IS_NOT')),
271 ];
272 $listClass = new ListClass();
273 $segmentClass = new SegmentClass();
274
275 $return = [];
276 if (empty($condition['lists_status']) || empty($condition['lists'])) {
277 $return[] = acym_translation('ACYM_NO_CONDITION_USER_SUBSCRIPTION');
278 } else {
279 $lists = $listClass->getListsByIds($condition['lists']);
280 $listsToDisplay = [];
281 foreach ($lists as $list) {
282 $listsToDisplay[] = $list->name;
283 }
284
285 $translationKey = $trigger === 'user_subscribe' ? 'ACYM_X_SUBSCRIBING_X_LIST' : 'ACYM_X_SUBSCRIBED_X_LIST';
286 $return[] = acym_translationSprintf($translationKey, acym_strtolower($statusArray[$condition['lists_status']]), implode(',', $listsToDisplay));
287 }
288
289
290 if (empty($condition['segments_status']) || empty($condition['segments'])) {
291 $return[] = acym_translation('ACYM_NO_CONDITION_SEGMENT');
292 } else {
293 $segments = $segmentClass->getByIds($condition['segments']);
294 $segmentsToDisplay = [];
295 foreach ($segments as $segment) {
296 $segmentsToDisplay[] = $segment->name;
297 }
298 $return[] = acym_translationSprintf('ACYM_X_PART_X_SEGMENT', acym_strtolower($statusArray[$condition['segments_status']]), implode(',', $segmentsToDisplay));
299 }
300
301 acym_trigger('getFollowupConditionSummary', [&$return, $condition, $trigger, $statusArray]);
302
303 return $return;
304 }
305
306 private function getKeyMailArray($key, $mailsKey)
307 {
308 if (!empty($mailsKey) && in_array($key, $mailsKey)) {
309 return $this->getKeyMailArray(++$key, $mailsKey);
310 }
311
312 return $key;
313 }
314
315 public function getOneByIdWithMails($id)
316 {
317 $followup = $this->getOneById($id);
318
319 if (empty($followup)) return false;
320
321 $mailClass = new MailClass();
322 $mails = $mailClass->decode(
323 acym_loadObjectList(
324 'SELECT mail.subject, mail.id, followup_mail.delay, followup_mail.delay_unit
325 FROM #__acym_mail AS mail
326 JOIN #__acym_followup_has_mail AS followup_mail ON mail.id = followup_mail.mail_id AND followup_mail.followup_id = '.intval($id),
327 'id'
328 )
329 );
330
331 $return = [];
332 foreach ($mails as $key => $mail) {
333 $mail->delay_display = $this->getDelayDisplay($mail->delay, $mail->delay_unit);
334 $mail->edit_link = acym_completeLink('mails&task=edit&step=editEmail&type=followup&id='.$key.'&followup_id='.$id.'&return='.urlencode(acym_currentURL()), false, true);
335 $finalKey = $this->getKeyMailArray(intval($mail->delay) * intval($mail->delay_unit), array_keys($return));
336 $return[$finalKey] = $mail;
337 }
338
339 ksort($return);
340
341 $followup->mails = empty($return) ? [] : $return;
342
343 return $followup;
344 }
345
346 private function getDelayDisplay($delay, $delayUnit)
347 {
348 $delayUnits = $this->getDelayUnits();
349
350 return acym_translationSprintf('ACYM_X_PLUS_X_FOLLOW_UP', $delayUnits[$delayUnit], $delay);
351 }
352
353 public function getDelaySettingToMail(&$mail, $followupId)
354 {
355 $settings = acym_loadObject('SELECT delay, delay_unit FROM #__acym_followup_has_mail WHERE followup_id = '.intval($followupId).' AND mail_id = '.intval($mail->id));
356
357 if (empty($settings)) return false;
358
359 $mail->delay = $settings->delay;
360 $mail->delay_unit = $settings->delay_unit;
361
362 return true;
363 }
364
365 public function saveDelaySettings($followupData, $mailId)
366 {
367 if (empty($followupData['id']) || empty($followupData['delay_unit']) || empty($mailId)) return false;
368
369 acym_arrayToInteger($followupData);
370
371 $affectedRow = acym_query(
372 'INSERT INTO #__acym_followup_has_mail (`mail_id`, `followup_id`, `delay`, `delay_unit`) VALUE ('.intval(
373 $mailId
374 ).', '.$followupData['id'].', '.$followupData['delay'].', '.$followupData['delay_unit'].') ON DUPLICATE KEY UPDATE delay = '.$followupData['delay'].', delay_unit = '.$followupData['delay_unit'].''
375 );
376
377 return $affectedRow !== false;
378 }
379
380 public function duplicateMail($mailId, $id)
381 {
382 if (empty($mailId) || empty($id)) return false;
383 $mailClass = new MailClass();
384 $mail = $mailClass->getOneById($mailId);
385
386 if (empty($mail)) return false;
387
388 $delaySettings = new \stdClass();
389 $delaySettings->id = $mail->id;
390 $this->getDelaySettingToMail($delaySettings, $id);
391
392 unset($mail->id);
393 $mail->name .= '_copy';
394
395 $mail->id = $mailClass->save($mail);
396 if (empty($mail->id)) return false;
397
398 $affectedRow = acym_query(
399 'INSERT INTO #__acym_followup_has_mail (`mail_id`, `followup_id`, `delay`, `delay_unit`) VALUE ('.intval($mail->id).', '.$id.', '.intval(
400 $delaySettings->delay
401 ).', '.intval($delaySettings->delay_unit).')'
402 );
403
404 return !empty($affectedRow);
405 }
406
407 public function deleteMail($mailId)
408 {
409 if (empty($mailId)) return false;
410 $mailClass = new MailClass();
411
412 return $mailClass->delete($mailId);
413 }
414
415 public function getFollowupsWithMailsInfoByIds($followupIds)
416 {
417 if (!is_array($followupIds)) $followupIds = [$followupIds];
418 acym_arrayToInteger($followupIds);
419
420 $mailsInfo = acym_loadObjectList(
421 'SELECT followup_mail.*, followup.send_once
422 FROM #__acym_followup_has_mail AS followup_mail
423 JOIN #__acym_followup AS followup ON followup.id = followup_mail.followup_id AND followup_mail.followup_id IN ('.implode(',', $followupIds).')'
424 );
425
426 if (empty($mailsInfo)) return [];
427
428 $return = [];
429
430 foreach ($mailsInfo as $mailInfo) {
431 if (!isset($return[$mailInfo->followup_id])) $return[$mailInfo->followup_id] = [];
432 $return[$mailInfo->followup_id][] = $mailInfo;
433 }
434
435 return $return;
436 }
437
438 public function subscribeUserToFollowupList(array $followupIds, $userId): array
439 {
440 acym_arrayToInteger($followupIds);
441
442 $followupLists = acym_loadObjectList(
443 'SELECT followup.list_id, IF(user_list.status IS NULL, "", status) AS status, followup.id, followup.send_once FROM #__acym_followup AS followup
444 LEFT JOIN #__acym_user_has_list AS user_list ON followup.list_id = user_list.list_id AND (user_list.user_id = '.intval($userId).' OR user_list.user_id IS NULL)
445 WHERE followup.id IN ('.implode(',', $followupIds).')',
446 'list_id'
447 );
448
449 if (empty($followupLists)) {
450 return [];
451 }
452
453 $followupListIds = [];
454 foreach ($followupLists as $listId => $followupList) {
455 if (in_array($followupList->status, [0, '0'], true)) {
456 continue;
457 }
458
459 if ($followupList->status === '' || $followupList->send_once == 0) {
460 $followupListIds[$listId] = $followupList->id;
461 }
462 }
463
464 if (empty($followupListIds)) {
465 return [];
466 }
467
468 $userClass = new UserClass();
469 $userClass->subscribe($userId, array_keys($followupListIds), false);
470
471 return $followupListIds;
472 }
473
474 public function addFollowupEmailsQueue($followupTrigger, $userId, $params = [])
475 {
476 if (empty($followupTrigger) || empty($userId)) return false;
477
478 $followupToTrigger = acym_loadObjectList('SELECT * FROM #__acym_followup WHERE active = 1 AND `trigger` = '.acym_escapeDB($followupTrigger), 'id');
479
480 if (empty($followupToTrigger)) return false;
481
482 foreach ($followupToTrigger as $key => $followup) {
483 if (!empty($followup->condition)) {
484 $followupToTrigger[$key]->condition = json_decode($followup->condition, true);
485 }
486 }
487
488 acym_trigger('matchFollowupsConditions', [&$followupToTrigger, $userId, $params]);
489
490 if (empty($followupToTrigger)) return false;
491
492 $followupIds = $this->subscribeUserToFollowupList(array_keys($followupToTrigger), $userId);
493
494 if (empty($followupIds)) return false;
495
496 $followups = $this->getFollowupsWithMailsInfoByIds($followupIds);
497
498 if (empty($followups)) return false;
499
500 $priority = $this->config->get('followup_max_priority', 0) == 1 ? 1 : 2;
501
502 $valuesToInsert = [];
503
504 foreach ($followups as $followupId => $mailsInfo) {
505 foreach ($mailsInfo as $mailInfo) {
506 $sendDate = time() + (intval($mailInfo->delay) * intval($mailInfo->delay_unit));
507 $sendDate = acym_date($sendDate, 'Y-m-d H:i:s', false);
508 $valuesToInsert[] = ' ('.intval($mailInfo->mail_id).', '.intval($userId).', '.acym_escapeDB($sendDate).', '.intval($priority).', '.acym_escapeDB(
509 json_encode($params)
510 ).') ';
511 $this->addMailStat($mailInfo->mail_id);
512 }
513 $followupToTrigger[$followupId]->last_trigger = time();
514 $this->save($followupToTrigger[$followupId]);
515 }
516
517 $query = 'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`, `priority`, `params`) VALUES '.implode(',', $valuesToInsert);
518
519 $affectedRows = acym_query($query);
520
521 return !empty($affectedRows);
522 }
523
524 private function addMailStat($mailId)
525 {
526 $mailStatClass = new MailStatClass();
527 $mailStat = $mailStatClass->getOneRowByMailId($mailId);
528 $newMailStat = [
529 'mail_id' => intval($mailId),
530 'total_subscribers' => 1,
531 ];
532 if (empty($mailStat)) {
533 $newMailStat['send_date'] = acym_date('now', 'Y-m-d H:i:s', false);
534 }
535
536 $mailStatClass->save($newMailStat);
537 }
538
539 public function getFollowupDailyBases()
540 {
541 $triggers = [];
542 acym_trigger('onAcymGetFollowupDailyBases', [&$triggers]);
543
544 return acym_loadObjectList('SELECT * FROM #__acym_followup WHERE `trigger` IN ("'.implode('","', $triggers).'") AND active = 1');
545 }
546
547 public function queueForSubscribers($emailId)
548 {
549 if (empty($emailId)) return false;
550
551 $mailInfo = acym_loadObject(
552 'SELECT map.*, followup.list_id
553 FROM #__acym_followup_has_mail AS map
554 JOIN #__acym_followup AS followup
555 ON followup.id = map.followup_id
556 WHERE map.mail_id = '.intval($emailId)
557 );
558 if (empty($mailInfo)) return false;
559
560 $this->addMailStat($mailInfo->mail_id);
561
562 $delay = intval($mailInfo->delay) * intval($mailInfo->delay_unit);
563 $query = 'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`, `priority`)
564 SELECT '.intval($mailInfo->mail_id).', user_id, TIMESTAMPADD(SECOND, '.$delay.', subscription_date), 2
565 FROM #__acym_user_has_list
566 WHERE status = 1
567 AND list_id = '.intval($mailInfo->list_id);
568
569 return acym_query($query);
570 }
571
572 public function getXFollowups(array $options): array
573 {
574 $limit = $options['limit'] ?? 10;
575 $offset = $options['offset'] ?? 0;
576 $filters = $options['filters'] ?? [];
577
578 $conditions = [];
579 foreach ($filters as $column => $filter) {
580 switch ($column) {
581 case 'id':
582 case 'active':
583 case 'send_one':
584 $conditions[] = acym_secureDBColumn($column).' = '.intval($filter);
585 break;
586 case 'name':
587 case 'trigger':
588 case 'display_name':
589 $conditions[] = '`'.acym_secureDBColumn($column).'` LIKE '.acym_escapeDB('%'.$filter.'%');
590 break;
591 default:
592 $conditions[] = acym_secureDBColumn($column).' = '.acym_escapeDB('%'.$filter.'%');
593 }
594 }
595
596 $query = 'SELECT * FROM #__acym_followup ';
597
598 if (!empty($conditions)) {
599 $query .= ' WHERE '.implode(' AND ', $conditions);
600 }
601
602 $followUps = acym_loadObjectList($query, $this->pkey, $offset, $limit);
603
604 if (empty($followUps)) {
605 return [];
606 }
607
608 foreach ($followUps as &$followUp) {
609 if (!empty($followUp->condition)) {
610 $followUp->condition = json_decode($followUp->condition, true);
611 }
612 }
613
614 return $followUps;
615 }
616
617 public function getOneByMailId(int $mailId): ?object
618 {
619 return acym_loadObject(
620 'SELECT followup.*
621 FROM #__acym_followup AS followup
622 JOIN #__acym_followup_has_mail AS map
623 ON followup.id = map.followup_id
624 WHERE mail_id = '.intval($mailId)
625 );
626 }
627
628 public function getLastEmail(int $followupId): object
629 {
630 return acym_loadObject(
631 'SELECT mail_id as id, delay * delay_unit as totalDelay FROM #__acym_followup_has_mail WHERE followup_id = '.intval($followupId).' ORDER BY totalDelay DESC'
632 );
633 }
634
635 public function triggerFollowUp(int $followUpId, int $userId, int $additionalDelay = 0, array $mailIdToSkip = []): void
636 {
637 $followUp = $this->getOneById($followUpId);
638
639 if (empty($followUp)) {
640 return;
641 }
642
643 $values = intval($userId).', '.intval($followUp->list_id).', 1, '.acym_escapeDB(acym_date(time(), 'Y-m-d H:i:s'));
644
645 acym_query('INSERT IGNORE INTO #__acym_user_has_list (`user_id`, `list_id`, `status`, `subscription_date`) VALUES ('.$values.') ON DUPLICATE KEY UPDATE status = 1');
646
647 $followups = $this->getFollowupsWithMailsInfoByIds($followUpId);
648 $allValues = [];
649 foreach ($followups as $mails) {
650 foreach ($mails as $mail) {
651 if (in_array($mail->mail_id, $mailIdToSkip)) {
652 continue;
653 }
654 $sendDate = time() + (intval($mail->delay) * intval($mail->delay_unit)) + $additionalDelay;
655 $sendDate = acym_escapeDB(acym_date($sendDate, 'Y-m-d H:i:s', false));
656 $allValues[] = '('.intval($mail->mail_id).', '.intval($userId).', '.$sendDate.', '.$this->config->get('priority_newsletter', 3).', 0'.')';
657 }
658 }
659
660 $queryToProcess = 'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`, `priority`, `try`) VALUES '.implode(', ', $allValues);
661
662 if (empty(acym_query($queryToProcess))) {
663 acym_logError("Error adding follow up email to queue \n Values: ".implode(', ', $allValues)." \n Error: ".acym_getDBError());
664 }
665 }
666 }
667