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 | front/FrontControllers/FronturlController.php +32 -13 10.11.1 → 11.1.0 View file →
@@ -49,18 +49,21 @@
49 49
50 50 $userStatClass = new UserStatClass();
51 51 $userStat = $userStatClass->getOneByMailAndUserId($mailId, $userId);
52 52
53 + // The mail has been deleted, or we didn't send this email to this user, or it's a bot
53 54 $delay = $this->config->get('tracking_delay', 0);
54 55 if (empty($mail) || empty($userStat) || acym_isRobot() || (!empty($delay) && acym_getTimeFromUTCDate($userStat->send_date) > time() - $delay)) {
55 - acym_redirect($this->resolveSubscriberTags($urlObject->url, $userId));
56 + acym_redirect($this->resolveSubscriberTags($urlObject->url, $userId), '', 'message', false);
56 57 }
57 58
59 + $anonymousStats = !empty($this->config->get('anonymous_stats', 0));
60 +
58 61 $urlClick = new \stdClass();
59 62 $urlClick->mail_id = $mailId;
60 63 $urlClick->url_id = $urlObject->id;
61 64 $urlClick->click = 1;
62 - $urlClick->user_id = $userId;
65 + $urlClick->user_id = $anonymousStats ? 0 : $userId;
63 66 $urlClick->date_click = acym_date('now', 'Y-m-d H:i:s', false);
64 67
65 68 $mailStatClass = new MailStatClass();
66 69 $urlClickClass = new UrlClickClass();
@@ -65,26 +68,42 @@
65 68 $mailStatClass = new MailStatClass();
66 69 $urlClickClass = new UrlClickClass();
67 70 $urlClickClass->save($urlClick);
68 71
69 - if (empty($userStat->open)) {
70 - $userStatToInsert = new \stdClass();
71 - $userStatToInsert->user_id = $userId;
72 - $userStatToInsert->mail_id = $mailId;
73 - $userStatToInsert->open = 1;
74 - $userStatToInsert->open_date = acym_date('now', 'Y-m-d H:i:s', false);
75 - $userStatClass->save($userStatToInsert);
72 + UserStatClass::triggerActivity('user_click', $userId, $mailId);
76 73
74 + if (!$anonymousStats) {
75 + if (empty($userStat->open)) {
76 + $userStatToInsert = new \stdClass();
77 + $userStatToInsert->user_id = $userId;
78 + $userStatToInsert->mail_id = $mailId;
79 + $userStatToInsert->open = 1;
80 + $userStatToInsert->open_date = acym_date('now', 'Y-m-d H:i:s', false);
81 + $userStatClass->save($userStatToInsert);
82 +
83 + $mailStat = new \stdClass();
84 + $mailStat->mail_id = $mailId;
85 + $mailStat->open_unique = 1;
86 + $mailStat->open_total = 1;
87 + $mailStatClass->save($mailStat);
88 +
89 + UserStatClass::triggerActivity('user_open', $userId, $mailId);
90 + }
91 +
92 + $clickStats = $urlClickClass->getOneByMailIdAndUserId($mailId, $userId);
93 + $mailStatClass->incrementClicks($mailId, $clickStats->click == 1);
94 + } else {
95 + $mailStatClass->incrementClicks($mailId, true);
96 +
97 + // Anonymous mode tracks totals only and keeps no per-recipient open state, so this is not deduplicated.
77 98 $mailStat = new \stdClass();
78 99 $mailStat->mail_id = $mailId;
79 100 $mailStat->open_unique = 1;
80 101 $mailStat->open_total = 1;
81 102 $mailStatClass->save($mailStat);
103 + $mailStatClass->incrementDetail($mailId, 'open_time', acym_date('now', 'Y-m-d H', false).':00:00');
82 104 }
83 105
84 - $clickStats = $urlClickClass->getOneByMailIdAndUserId($mailId, $userId);
85 - $mailStatClass->incrementClicks($mailId, $clickStats->click == 1);
86 -
87 106 $userClass = new UserClass();
88 107 $subscriber = $userClass->getOneById($userId);
89 108 if (!empty($subscriber)) {
90 109 $subscriber->last_open_date = acym_date('now', 'Y-m-d H:i:s', false);
@@ -93,9 +112,9 @@
93 112 $userClass->sendConf = false;
94 113 $userClass->save($subscriber);
95 114 }
96 115
97 - acym_redirect($this->resolveSubscriberTags($urlObject->url, $userId));
116 + acym_redirect($this->resolveSubscriberTags($urlObject->url, $userId), '', 'message', false);
98 117 }
99 118
100 119 private function resolveSubscriberTags(string $url, int $userId): string
101 120 {