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 | front/FrontControllers/ArchiveController.php +0 -222 10.2.2 → 11.1.1 View file →
@@ -1,222 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\FrontControllers;
4 -
5 -use AcyMailing\Classes\CampaignClass;
6 -use AcyMailing\Classes\MailArchiveClass;
7 -use AcyMailing\Classes\UserClass;
8 -use AcyMailing\Helpers\EditorHelper;
9 -use AcyMailing\Helpers\MailerHelper;
10 -use AcyMailing\Helpers\PaginationHelper;
11 -use AcyMailing\Core\AcymController;
12 -use AcyMailing\Core\AcymParameter;
13 -
14 -class ArchiveController extends AcymController
15 -{
16 - public function __construct()
17 - {
18 - parent::__construct();
19 - $this->setDefaultTask('view');
20 -
21 - $this->publicFrontTasks = [
22 - 'view',
23 - 'showArchive',
24 - 'listing',
25 - ];
26 - }
27 -
28 - public function view(): void
29 - {
30 - if ($this->config->get('archive_index', 0) == 0) {
31 - acym_addMetadata('robots', 'noindex,nofollow');
32 - }
33 -
34 - acym_addMetadata('UTF-8', '', 'charset');
35 -
36 - $mailId = acym_getVar('int', 'id', 0);
37 - $isPopup = acym_getVar('int', 'is_popup', 0);
38 -
39 - $mailArchiveClass = new MailArchiveClass();
40 - $oneMail = $mailArchiveClass->getOneByMailId($mailId);
41 - if (empty($oneMail)) {
42 - $mailerHelper = new MailerHelper();
43 - $oneMail = $mailerHelper->load($mailId);
44 - }
45 -
46 - if (empty($oneMail)) {
47 - acym_raiseError(404, acym_translation('ACYM_EMAIL_NOT_FOUND'));
48 -
49 - return;
50 - }
51 -
52 - acym_addMetadata('og:url', acym_frontendLink('archive&task=view&id='.$mailId));
53 - acym_addMetadata('og:title', $oneMail->subject);
54 - acym_setPageTitle($oneMail->subject);
55 -
56 - $userKeys = acym_getVar('string', 'userid', 0);
57 - if (!empty($userKeys)) {
58 - $userId = intval(substr($userKeys, 0, strpos($userKeys, '-')));
59 - $userKey = substr($userKeys, strpos($userKeys, '-') + 1);
60 - $receiver = acym_loadObject('SELECT * FROM #__acym_user WHERE `id` = '.intval($userId).' AND `key` = '.acym_escapeDB($userKey));
61 - }
62 -
63 - $currentEmail = acym_currentUserEmail();
64 - if (empty($receiver) && !empty($currentEmail)) {
65 - $userClass = new UserClass();
66 - $receiver = $userClass->getOneByEmail($currentEmail);
67 - }
68 -
69 - if (empty($receiver)) {
70 - $receiver = new \stdClass();
71 - $receiver->name = acym_translation('ACYM_VISITOR');
72 - }
73 -
74 - acym_trigger('replaceUserInformation', [&$oneMail, &$receiver, false]);
75 -
76 - preg_match('@href="{unsubscribe:(.*)}"@', $oneMail->body, $match);
77 - if (!empty($match)) {
78 - $oneMail->body = str_replace($match[0], 'href="'.$match[1].'"', $oneMail->body);
79 - }
80 -
81 - if (strpos($oneMail->body, 'acym__wysid__template') !== false) {
82 - acym_addStyle(false, ACYM_CSS.'libraries/foundation_email.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'libraries'.DS.'foundation_email.min.css'));
83 - }
84 - acym_addStyle(true, acym_getEmailCssFixes());
85 - if (!empty($oneMail->stylesheet)) {
86 - acym_addStyle(true, $oneMail->stylesheet);
87 - }
88 - $editorHelper = new EditorHelper();
89 - $settings = json_decode($oneMail->settings, true);
90 - if (!empty($settings)) {
91 - $settings = $editorHelper->getSettingsStyle($settings);
92 -
93 - if (!empty($settings)) {
94 - acym_addStyle(true, $settings);
95 - }
96 - }
97 -
98 - $oneMail->body = preg_replace('#background\-image: url\(&quot;([^)]*)&quot;\)#Uis', 'background-image: url($1)', $oneMail->body);
99 -
100 - $data = [
101 - 'mail' => $oneMail,
102 - 'receiver' => $receiver,
103 - ];
104 -
105 - acym_includeHeaders();
106 - parent::display($data);
107 -
108 - if ($isPopup || 'wordpress' === ACYM_CMS) exit;
109 - }
110 -
111 - public function listing(): void
112 - {
113 - acym_setVar('layout', 'listing');
114 -
115 - $search = acym_getVar('string', 'acym_search', '');
116 -
117 - $menu = acym_getMenu();
118 - if (!is_object($menu)) {
119 - acym_redirect(acym_rootURI());
120 -
121 - return;
122 - }
123 - $params = method_exists($menu, 'getParams') ? $menu->getParams() : $menu->params;
124 - $menuParams = new AcymParameter($params);
125 -
126 - $paramsJoomla = [];
127 - $paramsJoomla['suffix'] = $menuParams->get('pageclass_sfx', '');
128 - $paramsJoomla['page_heading'] = $menuParams->get('page_heading');
129 - $paramsJoomla['show_page_heading'] = $menuParams->get('show_page_heading', 0);
130 -
131 - if ($menuParams->get('menu-meta_description')) {
132 - acym_addMetadata('description', $menuParams->get('menu-meta_description'));
133 - }
134 -
135 - if ($menuParams->get('menu-meta_keywords')) {
136 - acym_addMetadata('keywords', $menuParams->get('menu-meta_keywords'));
137 - }
138 -
139 - if ($menuParams->get('robots')) {
140 - acym_addMetadata('robots', $menuParams->get('robots'));
141 - }
142 -
143 - $nbNewslettersPerPage = $menuParams->get('archiveNbNewslettersPerPage', 10);
144 - $listsSent = $menuParams->get('lists', '');
145 - $popup = $menuParams->get('popup', '1');
146 - $displayUserListOnly = $menuParams->get('displayUserListOnly', '1');
147 -
148 - $viewParams = [
149 - 'nbNewslettersPerPage' => $nbNewslettersPerPage,
150 - 'listsSent' => $listsSent,
151 - 'popup' => $popup,
152 - 'paramsCMS' => $paramsJoomla,
153 - 'search' => $search,
154 - 'displayUserListOnly' => $displayUserListOnly,
155 - ];
156 -
157 - $this->showArchive($viewParams);
158 - }
159 -
160 - public function showArchive(array $viewParams): void
161 - {
162 - acym_setVar('layout', 'listing');
163 -
164 - $data = $this->getDataForArchive($viewParams);
165 -
166 - parent::display($data);
167 - }
168 -
169 - private function getDataForArchive(array $viewParams): array
170 - {
171 - $params = [];
172 -
173 - $userId = false;
174 - $userClass = new UserClass();
175 - $currentUser = $userClass->identify(true);
176 - if (!empty($currentUser)) {
177 - $params['userId'] = $currentUser->id;
178 - $userId = $currentUser->id;
179 - }
180 -
181 - if (acym_isMultilingual()) {
182 - $params['language'] = acym_getLanguageTag();
183 - }
184 -
185 - if (!empty($viewParams['listsSent'])) {
186 - $params['lists'] = $viewParams['listsSent'];
187 - }
188 -
189 - if (!empty($viewParams['search'])) {
190 - $params['search'] = $viewParams['search'];
191 - }
192 -
193 - if (!empty($viewParams['displayUserListOnly'])) {
194 - $params['displayUserListOnly'] = $viewParams['displayUserListOnly'];
195 - }
196 -
197 - $params['page'] = $this->getVarFiltersListing('int', 'archive_pagination_page', 1);
198 - $campaignClass = new CampaignClass();
199 - $pagination = new PaginationHelper();
200 - $params['numberPerPage'] = (int)$viewParams['nbNewslettersPerPage'];
201 -
202 - $returnLastNewsletters = $campaignClass->getLastNewsletters($params);
203 - $pagination->setStatus($returnLastNewsletters['count'], $params['page'], $params['numberPerPage']);
204 -
205 - $disableButtons = '';
206 - if (isset($viewParams['disableButtons'])) {
207 - $disableButtons = $viewParams['disableButtons'];
208 - }
209 -
210 - return [
211 - 'newsletters' => $returnLastNewsletters['matchingNewsletters'],
212 - 'paramsCMS' => $viewParams['paramsCMS'],
213 - 'pagination' => $pagination,
214 - 'userId' => $userId,
215 - 'popup' => '1' === $viewParams['popup'],
216 - 'displayUserListOnly' => '1' === $viewParams['displayUserListOnly'],
217 - 'search' => $viewParams['search'],
218 - 'actionUrl' => acym_currentURL(),
219 - 'disableButtons' => $disableButtons,
220 - ];
221 - }
222 -}