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/FrontstatsController.php +25 -12 11.0.0 → 11.1.0 View file →
@@ -52,39 +52,52 @@
52 52 if (empty($userStat) || acym_isRobot() || (!empty($delay) && acym_getTimeFromUTCDate($userStat->send_date) > time() - $delay)) {
53 53 return;
54 54 }
55 55
56 + $anonymousStats = !empty($this->config->get('anonymous_stats', 0));
57 +
56 58 $mailStat = new \stdClass();
57 59 $mailStat->mail_id = $mailId;
58 - $mailStat->open_unique = $userStat->open > 0 ? 0 : 1;
59 60 $mailStat->open_total = 1;
61 + $mailStat->open_unique = $anonymousStats ? 1 : ($userStat->open > 0 ? 0 : 1);
60 62
61 63 $mailStatClass = new MailStatClass();
62 64 $mailStatClass->save($mailStat);
63 65
64 - $userStatToInsert = new \stdClass();
65 - $userStatToInsert->user_id = $userId;
66 - $userStatToInsert->mail_id = $mailId;
67 - $userStatToInsert->open = 1;
68 - $userStatToInsert->open_date = acym_date('now', 'Y-m-d H:i:s', false);
69 - $userStatToInsert->device = '';
70 - $userStatToInsert->opened_with = '';
66 + $openDate = acym_date('now', 'Y-m-d H:i:s', false);
71 67
68 + $device = '';
69 + $openedWith = '';
72 70 $userAgent = acym_getVar('string', 'HTTP_USER_AGENT', null, 'SERVER');
73 71 if (!empty($userAgent)) {
74 72 $browserDetection = new BrowserDetection();
75 73 $openingInformation = $browserDetection->getAll($userAgent);
76 74
77 - $userStatToInsert->device = $openingInformation['os_name'] === 'unknown' ? '' : $openingInformation['os_name'];
78 - $userStatToInsert->opened_with = $openingInformation['browser_name'] === 'unknown' ? '' : $openingInformation['browser_name'];
75 + $device = $openingInformation['os_name'] === 'unknown' ? '' : $openingInformation['os_name'];
76 + $openedWith = $openingInformation['browser_name'] === 'unknown' ? '' : $openingInformation['browser_name'];
79 77 }
80 78
81 - $userStatClass->save($userStatToInsert);
79 + if ($anonymousStats) {
80 + $mailStatClass->incrementDetail($mailId, 'device', $device);
81 + $mailStatClass->incrementDetail($mailId, 'client', $openedWith);
82 + $mailStatClass->incrementDetail($mailId, 'open_time', acym_date('now', 'Y-m-d H', false).':00:00');
83 + } else {
84 + $userStatToInsert = new \stdClass();
85 + $userStatToInsert->user_id = $userId;
86 + $userStatToInsert->mail_id = $mailId;
87 + $userStatToInsert->open = 1;
88 + $userStatToInsert->open_date = $openDate;
89 + $userStatToInsert->device = $device;
90 + $userStatToInsert->opened_with = $openedWith;
91 + $userStatClass->save($userStatToInsert);
92 + }
82 93
94 + UserStatClass::triggerActivity('user_open', $userId, $mailId);
95 +
83 96 $userClass = new UserClass();
84 97 $subscriber = $userClass->getOneById($userId);
85 98 if (!empty($subscriber)) {
86 - $subscriber->last_open_date = $userStatToInsert->open_date;
99 + $subscriber->last_open_date = $openDate;
87 100 $userClass->triggers = false;
88 101 $userClass->sendConf = false;
89 102 $userClass->save($subscriber);
90 103 }