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 | back/dynamics/user/UserInsertion.php +27 -14 10.0.1 → 11.1.0 View file →
@@ -4,16 +4,17 @@
4 4 {
5 5 private $customFields;
6 6 private $usergroups;
7 7
8 + //Keep the sender information to not load them every time
8 9 private $sendervalues = [];
9 10
10 - public function dynamicText($mailId)
11 + public function dynamicText(?int $mailId): ?object
11 12 {
12 13 return $this->pluginDescription;
13 14 }
14 15
15 - public function textPopup()
16 + public function textPopup(): void
16 17 {
17 18 ?>
18 19 <script type="text/javascript">
19 20 let selectedUserDText;
@@ -41,9 +42,8 @@
41 42 }
42 43 </script>
43 44
44 45 <?php
45 -
46 46 $isAutomation = acym_getVar('string', 'automation');
47 47 echo '<div class="acym__popup__listing text-center grid-x">';
48 48
49 49 $typeinfo = [];
@@ -52,9 +52,9 @@
52 52 if (!empty($isAutomation)) {
53 53 $typeinfo[] = acym_selectOption('current', 'ACYM_USER_TRIGGERING_AUTOMATION');
54 54 }
55 55
56 - echo acym_radio(
56 + acym_radio(
57 57 $typeinfo,
58 58 'typeInfoUser',
59 59 'receiver',
60 60 ['onclick' => 'changeUserTag(selectedUserDText)'],
@@ -69,15 +69,19 @@
69 69 'groups' => 'ACYM_USER_GROUPS',
70 70 ];
71 71
72 72 foreach ($fields as $fieldname => $description) {
73 - echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" id="'.$fieldname.'option" onclick="changeUserTag(\''.$fieldname.'\');" >
74 - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape($fieldname).'</div>
75 - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape(acym_translation($description)).'</div>
73 + echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" id="'.esc_attr(
74 + $fieldname
75 + ).'option" onclick="changeUserTag(\''.esc_attr($fieldname).'\');" >
76 + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($fieldname).'</div>
77 + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html(acym_translation($description)).'</div>
76 78 </div>';
77 79 }
78 80
81 + // Handle joomla custom fields
79 82 if (ACYM_CMS == 'joomla' && ACYM_J37) {
83 + // Load field groups
80 84 $groups = acym_loadObjectList('SELECT id, title FROM #__fields_groups WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC');
81 85 $defaultGroup = new stdClass();
82 86 $defaultGroup->id = 0;
83 87 $defaultGroup->title = acym_translation('ACYM_NO_GROUP');
@@ -82,11 +86,12 @@
82 86 $defaultGroup->id = 0;
83 87 $defaultGroup->title = acym_translation('ACYM_NO_GROUP');
84 88 array_unshift($groups, $defaultGroup);
85 89
90 + // Load custom fields
86 91 $customFields = acym_loadObjectList('SELECT id, title, group_id FROM #__fields WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC');
87 92 if (!empty($customFields)) {
88 - echo '<h1 class="acym__title acym__title__secondary text-center cell" style="margin-top: 20px;">'.acym_translation('ACYM_CUSTOM_FIELDS').'</h1>';
93 + echo '<h1 class="acym__title acym__title__secondary text-center cell" style="margin-top: 20px;">'.esc_html(acym_translation('ACYM_CUSTOM_FIELDS')).'</h1>';
89 94
90 95 foreach ($groups as $oneGroup) {
91 96 foreach ($customFields as $oneCF) {
92 97 if ($oneCF->group_id != $oneGroup->id) {
@@ -91,10 +96,12 @@
91 96 foreach ($customFields as $oneCF) {
92 97 if ($oneCF->group_id != $oneGroup->id) {
93 98 continue;
94 99 }
95 - echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" id="'.$oneCF->id.'customoption" onclick="changeUserTag(\''.$oneCF->id.'custom\');" >
96 - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape($oneCF->title).'</div>
100 + echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" id="'.esc_attr(
101 + $oneCF->id
102 + ).'customoption" onclick="changeUserTag(\''.esc_attr($oneCF->id).'custom\');" >
103 + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($oneCF->title).'</div>
97 104 </div>';
98 105 }
99 106 }
100 107 }
@@ -102,9 +109,9 @@
102 109
103 110 echo '</div>';
104 111 }
105 112
106 - public function replaceUserInformation(&$email, &$user, $send = true)
113 + public function replaceUserInformation(object &$email, ?object &$user, bool $send = true): void
107 114 {
108 115 $extractedTags = $this->pluginHelper->extractTags($email, 'usertag');
109 116 if (empty($extractedTags)) {
110 117 return;
@@ -128,19 +135,23 @@
128 135 $mytag->default = '';
129 136
130 137 $values = new stdClass();
131 138 $idused = 0;
139 + //Should we keep
132 140 $save = false;
133 141
142 + //Sender information
134 143 if (!empty($mytag->info) && $mytag->info == 'sender' && !empty($email->creator_id)) {
135 144 $idused = $email->creator_id;
136 145 $save = true;
137 146 }
138 147
148 + //Current user information
139 149 if (!empty($mytag->info) && $mytag->info == 'current') {
140 150 continue;
141 151 }
142 152
153 + //Receiver information
143 154 if ((empty($mytag->info) || $mytag->info == 'receiver') && !empty($user->cms_id)) {
144 155 $idused = $user->cms_id;
145 156 }
146 157
@@ -147,8 +158,9 @@
147 158 if (!empty($idused) && empty($this->sendervalues[$idused]) && empty($receivervalues[$idused])) {
148 159 global $acymCmsUserVars;
149 160 $receivervalues[$idused] = acym_loadObject('SELECT * FROM '.$acymCmsUserVars->table.' WHERE '.$acymCmsUserVars->id.' = '.intval($idused));
150 161
162 + //If we save the value in the object as we may reuse it...
151 163 if ($save) {
152 164 $this->sendervalues[$idused] = $receivervalues[$idused];
153 165 }
154 166 }
@@ -177,11 +189,12 @@
177 189
178 190 $fieldValues = trim(implode(', ', $userFieldVals), ', ');
179 191 if (empty($fieldValues)) {
180 192 $defaultValue = acym_loadObject('SELECT default_value, type FROM #__fields WHERE id = '.intval($mytag->id));
181 - if (($defaultValue->type == 'user' && !empty($defaultValue->default_value)) || ($defaultValue->type != 'user' && strlen(
182 - $defaultValue->default_value
183 - ) > 0)) {
193 + if (
194 + ($defaultValue->type === 'user' && !empty($defaultValue->default_value))
195 + || ($defaultValue->type !== 'user' && strlen($defaultValue->default_value) > 0)
196 + ) {
184 197 $userFieldVals = [$defaultValue->default_value];
185 198 }
186 199 }
187 200