PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.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
← All changes | back/Controllers/Stats/Detailed.php +0 -104 11.0.3 → 11.1.1 View file →
@@ -1,104 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Stats;
4 -
5 -use AcyMailing\Classes\UserStatClass;
6 -use AcyMailing\Helpers\ExportHelper;
7 -use AcyMailing\Helpers\PaginationHelper;
8 -
9 -trait Detailed
10 -{
11 - public function detailedStats(): void
12 - {
13 - acym_setVar('layout', 'detailed_stats');
14 -
15 - $data = [];
16 -
17 - $this->prepareDefaultPageInfo($data);
18 -
19 - $this->prepareDetailedListing($data);
20 - if (count($this->selectedMailIds) == 1) {
21 - if ($data['isAbTest']) {
22 - $this->prepareAbTestMails($data);
23 - } elseif (acym_isMultilingual()) {
24 - $this->prepareMultilingualMails($data);
25 - }
26 - }
27 - $this->prepareMailFilter($data);
28 -
29 - parent::display($data);
30 - }
31 -
32 - public function exportDetailed(): void
33 - {
34 - wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
35 -
36 - $exportHelper = new ExportHelper();
37 - $data = [];
38 - $this->prepareDefaultPageInfo($data);
39 -
40 - $where = '';
41 - if (!empty($this->selectedMailIds)) {
42 - $where = 'WHERE userstat.`mail_id` IN ('.implode(',', $this->selectedMailIds).')';
43 - }
44 -
45 - $groupBy = ' GROUP BY userstat.mail_id, userstat.user_id ';
46 -
47 - $columnsMailStat = acym_getColumns('user_stat');
48 - $columnsToExport = [];
49 -
50 - $columnsToExport['mail.subject'] = acym_translation('ACYM_EMAIL_SUBJECT');
51 - $columnsToExport['user.email'] = acym_translation('ACYM_USER_EMAIL');
52 - $columnsToExport['user.name'] = acym_translation('ACYM_USER_NAME');
53 - foreach ($columnsMailStat as $column) {
54 - if (in_array($column, ['user_id', 'mail_id'])) continue;
55 - $trad = acym_translation('ACYM_'.strtoupper($column).'_COLUMN_STAT');
56 - if ($column === 'send_date') $trad = acym_translation('ACYM_SEND_DATE');
57 - if ($column === 'open') $trad = acym_translation('ACYM_OPEN_TOTAL_COLUMN_STAT');
58 - if ($column === 'bounce') $trad = acym_translation('ACYM_BOUNCE_UNIQUE_COLUMN_STAT');
59 - $columnsToExport['userstat.'.$column] = $trad;
60 - }
61 -
62 - $query = 'SELECT '.implode(', ', array_keys($columnsToExport)).', SUM(urlclick.click) AS click FROM #__acym_user_stat AS userstat
63 - LEFT JOIN #__acym_user AS user ON user.id = userstat.user_id
64 - LEFT JOIN #__acym_mail AS mail ON mail.id = userstat.mail_id
65 - LEFT JOIN #__acym_url_click AS urlclick ON urlclick.user_id = userstat.user_id AND userstat.mail_id = urlclick.mail_id '.$where.$groupBy;
66 - $columnsToExport['urlclick.click'] = acym_translation('ACYM_TOTAL_CLICK');
67 - $exportHelper->exportStatsFullCSV($query, $columnsToExport, 'detailed');
68 - exit;
69 - }
70 -
71 - private function prepareDetailedListing(array &$data): void
72 - {
73 - $data['search'] = $this->getVarFiltersListing('string', 'detailed_stats_search', '');
74 - $data['ordering'] = $this->getVarFiltersListing('cmd', 'detailed_stats_ordering', 'send_date');
75 - $data['orderingSortOrder'] = $this->getVarFiltersListing('cmd', 'detailed_stats_ordering_sort_order', 'desc');
76 -
77 - if (empty($this->selectedMailIds)) {
78 - return;
79 - }
80 -
81 - $userStatClass = new UserStatClass();
82 - $pagination = new PaginationHelper();
83 -
84 - $detailedStatsPerPage = $pagination->getListLimit();
85 - $page = $this->getVarFiltersListing('int', 'detailed_stats_pagination_page', 1);
86 -
87 - $matchingDetailedStats = $userStatClass->getDetailedStats(
88 - [
89 - 'ordering' => $data['ordering'],
90 - 'ordering_sort_order' => $data['orderingSortOrder'],
91 - 'search' => $data['search'],
92 - 'detailedStatsPerPage' => $detailedStatsPerPage,
93 - 'offset' => ($page - 1) * $detailedStatsPerPage,
94 - 'mail_ids' => $this->selectedMailIds,
95 - ]
96 - );
97 -
98 - // Prepare the pagination
99 - $pagination->setStatus((int)$matchingDetailedStats['total']->total, $page, $detailedStatsPerPage);
100 -
101 - $data['pagination'] = $pagination;
102 - $data['detailed_stats'] = $matchingDetailedStats['detailed_stats'];
103 - }
104 -}