← All changes
|
back/dynamics/subscriber/SubscriberInsertion.php
+25
-13
10.2.2
→
11.1.0
View file →
| @@ -4,14 +4,14 @@ | ||
| 4 | 4 | use AcyMailing\Classes\FieldClass; |
| 5 | 5 | |
| 6 | 6 | trait SubscriberInsertion |
| 7 | 7 | { |
| 8 | - public function dynamicText($mailId) | |
| 8 | + public function dynamicText(?int $mailId): ?object | |
| 9 | 9 | { |
| 10 | 10 | return $this->pluginDescription; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public function textPopup() | |
| 13 | + public function textPopup(): void | |
| 14 | 14 | { |
| 15 | 15 | ?> |
| 16 | 16 | <script type="text/javascript"> |
| 17 | 17 | let selectedSubscriberDText; |
| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | if (!tagname) return; |
| 21 | 21 | |
| 22 | 22 | selectedSubscriberDText = tagname; |
| 23 | 23 | |
| 24 | - let baseTag = '<?php echo $this->name; ?>'; | |
| 24 | + let baseTag = '<?php echo esc_html($this->name); ?>'; | |
| 25 | 25 | const $inputType = jQuery('input[name="typeInfoSubscriber"]:checked'); |
| 26 | 26 | if ($inputType.length > 0 && $inputType.val() === 'current') { |
| 27 | 27 | baseTag = 'user'; |
| 28 | 28 | } |
| @@ -69,9 +69,9 @@ | ||
| 69 | 69 | $textTrigger = $mailType == 'notification' ? 'ACYM_USER_TRIGGERING_NOTIFICATION' : 'ACYM_USER_TRIGGERING_AUTOMATION'; |
| 70 | 70 | $typeinfo = []; |
| 71 | 71 | $typeinfo[] = acym_selectOption('receiver', 'ACYM_RECEIVER_INFORMATION'); |
| 72 | 72 | $typeinfo[] = acym_selectOption('current', $textTrigger); |
| 73 | - echo acym_radio( | |
| 73 | + acym_radio( | |
| 74 | 74 | $typeinfo, |
| 75 | 75 | 'typeInfoSubscriber', |
| 76 | 76 | 'receiver', |
| 77 | 77 | ['onclick' => 'changeSubscriberTag(selectedSubscriberDText, jQuery(this))'] |
| @@ -76,9 +76,9 @@ | ||
| 76 | 76 | 'receiver', |
| 77 | 77 | ['onclick' => 'changeSubscriberTag(selectedSubscriberDText, jQuery(this))'] |
| 78 | 78 | ); |
| 79 | 79 | } |
| 80 | - echo '<h1 class="acym__title acym__title__secondary text-center cell">'.acym_translation('ACYM_RECEIVER_INFORMATION').'</h1>'; | |
| 80 | + echo '<h1 class="acym__title acym__title__secondary text-center cell">'.esc_html(acym_translation('ACYM_RECEIVER_INFORMATION')).'</h1>'; | |
| 81 | 81 | |
| 82 | 82 | $others = []; |
| 83 | 83 | $others['name|part:first|ucfirst'] = ['name' => acym_translation('ACYM_USER_FIRSTPART'), 'desc' => acym_translation('ACYM_USER_FIRSTPART_DESC')]; |
| 84 | 84 | $others['name|part:last|ucfirst'] = ['name' => acym_translation('ACYM_USER_LASTPART'), 'desc' => acym_translation('ACYM_USER_LASTPART_DESC')]; |
| @@ -83,11 +83,13 @@ | ||
| 83 | 83 | $others['name|part:first|ucfirst'] = ['name' => acym_translation('ACYM_USER_FIRSTPART'), 'desc' => acym_translation('ACYM_USER_FIRSTPART_DESC')]; |
| 84 | 84 | $others['name|part:last|ucfirst'] = ['name' => acym_translation('ACYM_USER_LASTPART'), 'desc' => acym_translation('ACYM_USER_LASTPART_DESC')]; |
| 85 | 85 | |
| 86 | 86 | foreach ($others as $tagname => $tag) { |
| 87 | - echo '<div style="cursor:pointer" class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="changeSubscriberTag(\''.$tagname.'\', jQuery(this));"> | |
| 88 | - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['name'].'</div> | |
| 89 | - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['desc'].'</div> | |
| 87 | + echo '<div style="cursor:pointer" class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="changeSubscriberTag(\''.esc_attr( | |
| 88 | + $tagname | |
| 89 | + ).'\', jQuery(this));"> | |
| 90 | + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($tag['name']).'</div> | |
| 91 | + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($tag['desc']).'</div> | |
| 90 | 92 | </div>'; |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | foreach ($fields as $field) { |
| @@ -101,11 +103,13 @@ | ||
| 101 | 103 | if (in_array($fieldKey, ['creation_date', 'open_date', 'date_click', 'send_date'])) { |
| 102 | 104 | $type = '|type:time'; |
| 103 | 105 | } |
| 104 | 106 | |
| 105 | - echo '<div style="cursor:pointer" class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="changeSubscriberTag(\''.$fieldKey.$type.'\', jQuery(this));"> | |
| 106 | - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape($fieldName).'</div> | |
| 107 | - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape($descriptions[$fieldKey]).'</div> | |
| 107 | + echo '<div style="cursor:pointer" class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="changeSubscriberTag(\''.esc_attr( | |
| 108 | + $fieldKey.$type | |
| 109 | + ).'\', jQuery(this));"> | |
| 110 | + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($fieldName).'</div> | |
| 111 | + <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.esc_html($descriptions[$fieldKey]).'</div> | |
| 108 | 112 | </div>'; |
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | echo '</div>'; |
| @@ -110,9 +114,9 @@ | ||
| 110 | 114 | |
| 111 | 115 | echo '</div>'; |
| 112 | 116 | } |
| 113 | 117 | |
| 114 | - public function replaceUserInformation(&$email, &$user, $send = true) | |
| 118 | + public function replaceUserInformation(object &$email, ?object &$user, bool $send = true): void | |
| 115 | 119 | { |
| 116 | 120 | $extractedTags = $this->pluginHelper->extractTags($email, $this->name); |
| 117 | 121 | $backwardsTags = $this->pluginHelper->extractTags($email, 'subtag'); |
| 118 | 122 | foreach ($backwardsTags as $tag => $params) { |
| @@ -122,9 +126,9 @@ | ||
| 122 | 126 | if (empty($extractedTags)) return; |
| 123 | 127 | |
| 124 | 128 | $fieldClass = new FieldClass(); |
| 125 | 129 | $fields = $fieldClass->getFieldsByNameKey(array_column($extractedTags, 'id')); |
| 126 | - $fieldsData = empty($user->id) ? [] : $fieldClass->getAllFieldsListingByUserIds($user->id, array_keys($fields)); | |
| 130 | + $fieldsData = empty($user->id) ? [] : $fieldClass->getAllFieldsListingByUserIds([$user->id], array_keys($fields)); | |
| 127 | 131 | $fieldsNameKeyIdMap = array_combine(array_column($fields, 'namekey'), array_column($fields, 'id')); |
| 128 | 132 | |
| 129 | 133 | $tags = []; |
| 130 | 134 | foreach ($extractedTags as $i => $oneTag) { |
| @@ -132,8 +136,16 @@ | ||
| 132 | 136 | continue; |
| 133 | 137 | } |
| 134 | 138 | |
| 135 | 139 | $fieldNameKey = $oneTag->id === 'acym_language' ? 'language' : $oneTag->id; |
| 140 | + | |
| 141 | + if ($fieldNameKey === 'autologin_token' && !empty($user->id) && !empty($user->key)) { | |
| 142 | + $fieldValue = acym_generateAutologinToken(intval($user->id), $user->key); | |
| 143 | + $this->pluginHelper->formatString($fieldValue, $oneTag); | |
| 144 | + $tags[$i] = $fieldValue; | |
| 145 | + continue; | |
| 146 | + } | |
| 147 | + | |
| 136 | 148 | $fieldId = $fieldsNameKeyIdMap[$fieldNameKey] ?? 0; |
| 137 | 149 | $fieldValue = $user->$fieldNameKey ?? ''; |
| 138 | 150 | |
| 139 | 151 | if (strlen($fieldValue) === 0 && !empty($user->id) && !empty($fieldId)) { |