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/DynamicsController.php +0 -92 10.2.2 → 11.1.1 View file →
@@ -1,92 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers;
4 -
5 -use AcyMailing\Classes\UserClass;
6 -use AcyMailing\Helpers\PluginHelper;
7 -use AcyMailing\Core\AcymController;
8 -
9 -class DynamicsController extends AcymController
10 -{
11 - public function replaceDummy(): void
12 - {
13 - $mailId = acym_getVar('int', 'mailId', 0);
14 - $code = acym_getVar('string', 'code', '', '', ACYM_ALLOWRAW);
15 - $previewBody = acym_getVar('string', 'previewBody', '', '', ACYM_ALLOWRAW);
16 -
17 - $pluginHelper = new PluginHelper();
18 - $email = $pluginHelper->createDummyEmailObject($mailId, $code, $previewBody);
19 -
20 - @acym_trigger('replaceContent', [&$email, false]);
21 -
22 - $userClass = new UserClass();
23 - $userEmail = acym_currentUserEmail();
24 - $user = $userClass->getOneByEmail($userEmail);
25 -
26 - if (empty($user)) {
27 - $user = new \stdClass();
28 - $user->email = $userEmail;
29 - $user->name = acym_currentUserName();
30 - $user->cms_id = acym_currentUserId();
31 - $user->confirmed = 0;
32 - $user->source = acym_isAdmin() ? 'Back-end' : 'Front-end';
33 -
34 - $userClass->checkVisitor = false;
35 - $user->id = $userClass->save($user);
36 - }
37 -
38 - @acym_trigger('replaceUserInformation', [&$email, &$user, false]);
39 -
40 - acym_sendAjaxResponse(
41 - '',
42 - [
43 - 'content' => $email->body,
44 - 'custom_view' => !empty($email->custom_view),
45 - ]
46 - );
47 - }
48 -
49 - public function trigger(): void
50 - {
51 - $plugin = acym_getVar('cmd', 'plugin', '');
52 - $trigger = acym_getVar('cmd', 'trigger', '');
53 - if (empty($plugin) || empty($trigger)) exit;
54 -
55 - $triggerParams = $this->getTriggerParams($plugin, $trigger);
56 - acym_trigger($trigger, $triggerParams, $plugin);
57 - exit;
58 - }
59 -
60 - private function getTriggerParams(string $plugin, string $trigger): array
61 - {
62 - $shortcode = acym_getVar('string', 'shortcode', '');
63 - $shortcode = trim($shortcode, '{}');
64 -
65 - $separatorPosition = strpos($shortcode, ':');
66 - if (false !== $separatorPosition) {
67 - $pluginSubType = substr($shortcode, 0, $separatorPosition);
68 - $shortcode = substr($shortcode, $separatorPosition + 1);
69 - $pluginHelper = new PluginHelper();
70 - $defaultValues = $pluginHelper->extractTag($shortcode);
71 - $defaultValues->defaultPluginTab = $pluginSubType;
72 -
73 - return [$defaultValues];
74 - }
75 -
76 - if ($trigger === 'insertionOptions') {
77 - $rawDefaultValues = $this->config->get('dcontent_default_'.$plugin);
78 -
79 - if (!empty($rawDefaultValues)) {
80 - $defaultValues = json_decode($rawDefaultValues, true);
81 - unset($defaultValues['id']);
82 - unset($defaultValues['from']);
83 - unset($defaultValues['to']);
84 - $defaultValues = (object)$defaultValues;
85 -
86 - return [$defaultValues];
87 - }
88 - }
89 -
90 - return [];
91 - }
92 -}