| @@ -4,8 +4,9 @@ | ||
| 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 | 11 | public function dynamicText(?int $mailId): ?object |
| 11 | 12 | { |
| @@ -51,9 +52,9 @@ | ||
| 51 | 52 | if (!empty($isAutomation)) { |
| 52 | 53 | $typeinfo[] = acym_selectOption('current', 'ACYM_USER_TRIGGERING_AUTOMATION'); |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | - echo acym_radio( | |
| 56 | + acym_radio( | |
| 56 | 57 | $typeinfo, |
| 57 | 58 | 'typeInfoUser', |
| 58 | 59 | 'receiver', |
| 59 | 60 | ['onclick' => 'changeUserTag(selectedUserDText)'], |
| @@ -68,15 +69,19 @@ | ||
| 68 | 69 | 'groups' => 'ACYM_USER_GROUPS', |
| 69 | 70 | ]; |
| 70 | 71 | |
| 71 | 72 | foreach ($fields as $fieldname => $description) { |
| 72 | - echo '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" id="'.$fieldname.'option" onclick="changeUserTag(\''.$fieldname.'\');" > | |
| 73 | - <div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_escape($fieldname).'</div> | |
| 74 | - <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> | |
| 75 | 78 | </div>'; |
| 76 | 79 | } |
| 77 | 80 | |
| 81 | + // Handle joomla custom fields | |
| 78 | 82 | if (ACYM_CMS == 'joomla' && ACYM_J37) { |
| 83 | + // Load field groups | |
| 79 | 84 | $groups = acym_loadObjectList('SELECT id, title FROM #__fields_groups WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC'); |
| 80 | 85 | $defaultGroup = new stdClass(); |
| 81 | 86 | $defaultGroup->id = 0; |
| 82 | 87 | $defaultGroup->title = acym_translation('ACYM_NO_GROUP'); |
| @@ -81,11 +86,12 @@ | ||
| 81 | 86 | $defaultGroup->id = 0; |
| 82 | 87 | $defaultGroup->title = acym_translation('ACYM_NO_GROUP'); |
| 83 | 88 | array_unshift($groups, $defaultGroup); |
| 84 | 89 | |
| 90 | + // Load custom fields | |
| 85 | 91 | $customFields = acym_loadObjectList('SELECT id, title, group_id FROM #__fields WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC'); |
| 86 | 92 | if (!empty($customFields)) { |
| 87 | - 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>'; | |
| 88 | 94 | |
| 89 | 95 | foreach ($groups as $oneGroup) { |
| 90 | 96 | foreach ($customFields as $oneCF) { |
| 91 | 97 | if ($oneCF->group_id != $oneGroup->id) { |
| @@ -90,10 +96,12 @@ | ||
| 90 | 96 | foreach ($customFields as $oneCF) { |
| 91 | 97 | if ($oneCF->group_id != $oneGroup->id) { |
| 92 | 98 | continue; |
| 93 | 99 | } |
| 94 | - 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\');" > | |
| 95 | - <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> | |
| 96 | 104 | </div>'; |
| 97 | 105 | } |
| 98 | 106 | } |
| 99 | 107 | } |
| @@ -127,19 +135,23 @@ | ||
| 127 | 135 | $mytag->default = ''; |
| 128 | 136 | |
| 129 | 137 | $values = new stdClass(); |
| 130 | 138 | $idused = 0; |
| 139 | + //Should we keep | |
| 131 | 140 | $save = false; |
| 132 | 141 | |
| 142 | + //Sender information | |
| 133 | 143 | if (!empty($mytag->info) && $mytag->info == 'sender' && !empty($email->creator_id)) { |
| 134 | 144 | $idused = $email->creator_id; |
| 135 | 145 | $save = true; |
| 136 | 146 | } |
| 137 | 147 | |
| 148 | + //Current user information | |
| 138 | 149 | if (!empty($mytag->info) && $mytag->info == 'current') { |
| 139 | 150 | continue; |
| 140 | 151 | } |
| 141 | 152 | |
| 153 | + //Receiver information | |
| 142 | 154 | if ((empty($mytag->info) || $mytag->info == 'receiver') && !empty($user->cms_id)) { |
| 143 | 155 | $idused = $user->cms_id; |
| 144 | 156 | } |
| 145 | 157 | |
| @@ -146,8 +158,9 @@ | ||
| 146 | 158 | if (!empty($idused) && empty($this->sendervalues[$idused]) && empty($receivervalues[$idused])) { |
| 147 | 159 | global $acymCmsUserVars; |
| 148 | 160 | $receivervalues[$idused] = acym_loadObject('SELECT * FROM '.$acymCmsUserVars->table.' WHERE '.$acymCmsUserVars->id.' = '.intval($idused)); |
| 149 | 161 | |
| 162 | + //If we save the value in the object as we may reuse it... | |
| 150 | 163 | if ($save) { |
| 151 | 164 | $this->sendervalues[$idused] = $receivervalues[$idused]; |
| 152 | 165 | } |
| 153 | 166 | } |