| @@ -1,0 +1,252 @@ | ||
| 1 | +<?php | |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View file, its variables are local to the include scope, not true globals. | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 5 | +use AcyMailing\Helpers\SecurityHelper; | |
| 6 | + | |
| 7 | +$formName = acym_getModuleFormName(); | |
| 8 | +$allowedIntroTags = array_merge(SecurityHelper::ALLOWED_HTML_INTRO, [ | |
| 9 | + 'a' => [ | |
| 10 | + 'href' => true, | |
| 11 | + 'target' => true, | |
| 12 | + 'title' => true, | |
| 13 | + 'class' => true, | |
| 14 | + 'rel' => true, | |
| 15 | + 'aria-label' => true, | |
| 16 | + ], | |
| 17 | +]); | |
| 18 | +?> | |
| 19 | +<div id="acym_fulldiv_<?php echo esc_attr($formName); ?>" class="acym_front_page <?php echo empty($data['suffix']) ? '' : esc_attr($data['suffix']); ?>"> | |
| 20 | + <?php | |
| 21 | + if (!empty($data['show_page_heading'])) { | |
| 22 | + echo '<h1 class="contentheading'.esc_attr($data['suffix']).'">'.esc_html($data['page_heading']).'</h1>'; | |
| 23 | + } | |
| 24 | + | |
| 25 | + if (!empty($data['introtext'])) { | |
| 26 | + echo '<span class="acym_introtext">'.wp_kses( | |
| 27 | + $data['introtext'], | |
| 28 | + $allowedIntroTags | |
| 29 | + ).'</span>'; | |
| 30 | + } | |
| 31 | + ?> | |
| 32 | + | |
| 33 | + <form enctype="multipart/form-data" | |
| 34 | + action="<?php echo esc_url(acym_frontendLink('frontusers'.(acym_isNoTemplate() ? '&'.acym_noTemplate() : ''))); ?>" | |
| 35 | + method="post" | |
| 36 | + name="<?php echo esc_attr($formName); ?>" | |
| 37 | + id="<?php echo esc_attr($formName); ?>" | |
| 38 | + onsubmit="this.querySelector('input[type=submit]').click(); return false;" novalidate> | |
| 39 | + <fieldset class="adminform acy_user_info"> | |
| 40 | + <legend> | |
| 41 | + <span> | |
| 42 | + <?php | |
| 43 | + echo wp_kses( | |
| 44 | + acym_translation('ACYM_USER_INFORMATION'), | |
| 45 | + SecurityHelper::ALLOWED_HTML_INTRO | |
| 46 | + ); | |
| 47 | + ?> | |
| 48 | + </span> | |
| 49 | + </legend> | |
| 50 | + <div id="acyuserinfo"> | |
| 51 | + <?php | |
| 52 | + foreach ($data['fields'] as $field) { | |
| 53 | + $field->option = !empty($field->option) ? json_decode($field->option) : new stdClass(); | |
| 54 | + $fieldDB = empty($field->option->fieldDB) ? '' : json_decode($field->option->fieldDB); | |
| 55 | + $field->value = empty($field->value) ? '' : json_decode($field->value); | |
| 56 | + $valuesArray = []; | |
| 57 | + if (!empty($field->value)) { | |
| 58 | + foreach ($field->value as $value) { | |
| 59 | + $valueTmp = new stdClass(); | |
| 60 | + $valueTmp->text = $value->title; | |
| 61 | + $valueTmp->value = $value->value; | |
| 62 | + if ($value->disabled == 'y') { | |
| 63 | + $valueTmp->disable = true; | |
| 64 | + } | |
| 65 | + $valuesArray[$value->value] = $valueTmp; | |
| 66 | + } | |
| 67 | + } | |
| 68 | + if (!empty($fieldDB) && !empty($fieldDB->value)) { | |
| 69 | + $fromDB = $data['fieldClass']->getValueFromDB($fieldDB); | |
| 70 | + foreach ($fromDB as $value) { | |
| 71 | + $valuesArray[$value->value] = $value->title; | |
| 72 | + } | |
| 73 | + } | |
| 74 | + echo '<span class="onefield fieldacy'.esc_attr($field->id).'" id="field_'.esc_attr($field->id).'">'; | |
| 75 | + | |
| 76 | + $data['fieldClass']->displayField($field, $field->default_value, $valuesArray, true, true, $data['user']); | |
| 77 | + echo '</span>'; | |
| 78 | + | |
| 79 | + if ($field->id == 2 && $this->config->get('email_confirmation')) { | |
| 80 | + $data['fieldClass']->setEmailConfirmationField(true, $field, 'span', false); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + ?> | |
| 84 | + </div> | |
| 85 | + | |
| 86 | + <?php | |
| 87 | + if ($this->config->get('user_tracking_control', 0)) { | |
| 88 | + $trackingChecked = isset($data['user']->tracking) ? (int)$data['user']->tracking === 1 : !$this->config->get('dont_track_by_default', 0); | |
| 89 | + echo '<div class="onefield fieldacytracking" id="field_tracking_'.esc_attr($formName).'">'; | |
| 90 | + echo '<label for="mailingdata_tracking_'.esc_attr($formName).'">'; | |
| 91 | + echo '<input type="hidden" name="user[tracking]" value="0"/>'; | |
| 92 | + echo '<input id="mailingdata_tracking_'.esc_attr( | |
| 93 | + $formName | |
| 94 | + ).'" class="checkbox" type="checkbox" name="user[tracking]" value="1" '.checked($trackingChecked, true, false).'/> '.esc_html( | |
| 95 | + acym_translation('ACYM_ALLOW_TRACKING') | |
| 96 | + ); | |
| 97 | + echo '</label>'; | |
| 98 | + echo '</div>'; | |
| 99 | + } | |
| 100 | + | |
| 101 | + $exportButton = $this->config->get('gdpr_export', 0); | |
| 102 | + $deleteButton = $this->config->get('gdpr_delete', 0); | |
| 103 | + if (!empty($data['user']->id) && !(empty($exportButton) && empty($deleteButton))) { | |
| 104 | + ?> | |
| 105 | + <div id="acyuseractions"> | |
| 106 | + <table role="presentation"> | |
| 107 | + <tr> | |
| 108 | + <?php | |
| 109 | + if ($exportButton == 1) { | |
| 110 | + ?> | |
| 111 | + <td id="acybutton_subscriber_download_data" <?php if ($deleteButton == 1) { | |
| 112 | + echo 'style="padding-right: 10px;"'; | |
| 113 | + } ?>> | |
| 114 | + <button class="btn btn-secondary button" onclick="this.form.task.value='exportdata'; this.form.submit(); return false;"> | |
| 115 | + <?php echo esc_html(acym_translation('ACYM_EXPORT_MY_DATA')); ?> | |
| 116 | + </button> | |
| 117 | + </td> | |
| 118 | + <?php | |
| 119 | + } | |
| 120 | + if ($deleteButton == 1) { | |
| 121 | + ?> | |
| 122 | + <td id="acybutton_subscriber_delete_data"> | |
| 123 | + <button class="btn btn-secondary button" | |
| 124 | + onclick="if(confirm(ACYM_JS_TXT.ACYM_ARE_YOU_SURE + '\n' + ACYM_JS_TXT.ACYM_DELETE_MY_DATA_CONFIRM)){ this.form.task.value = 'gdprDelete'; this.form.submit(); } return false;"> | |
| 125 | + <?php echo esc_html(acym_translation('ACYM_DELETE_MY_DATA')); ?> | |
| 126 | + </button> | |
| 127 | + </td> | |
| 128 | + <?php | |
| 129 | + } | |
| 130 | + ?> | |
| 131 | + </tr> | |
| 132 | + </table> | |
| 133 | + </div> | |
| 134 | + <?php } ?> | |
| 135 | + </fieldset> | |
| 136 | + <?php | |
| 137 | + if ($data['displayLists']) { | |
| 138 | + ?> | |
| 139 | + <fieldset class="adminform acy_subscription_list margin-bottom-1"> | |
| 140 | + <legend><span><?php echo esc_html(acym_translation('ACYM_SUBSCRIPTION')); ?></span></legend> | |
| 141 | + | |
| 142 | + <div id="acyusersubscription"> | |
| 143 | + <?php | |
| 144 | + if (empty($data['dropdown'])) { | |
| 145 | + $values = []; | |
| 146 | + $values[0] = acym_selectOption('-1', 'ACYM_NO'); | |
| 147 | + $values[1] = acym_selectOption('1', 'ACYM_YES'); | |
| 148 | + $values[0]->class = 'btn-danger'; | |
| 149 | + $values[1]->class = 'btn-success'; | |
| 150 | + | |
| 151 | + $k = 0; | |
| 152 | + foreach ($data['subscription'] as $row) { | |
| 153 | + if (empty($row->active) || !$row->visible) { | |
| 154 | + continue; | |
| 155 | + } | |
| 156 | + if (empty($row->status)) { | |
| 157 | + $row->status = -1; | |
| 158 | + } | |
| 159 | + | |
| 160 | + echo '<div class="acym_list"> | |
| 161 | + <div class="acystatus">'; | |
| 162 | + acym_radio( | |
| 163 | + $values, | |
| 164 | + 'data[listsub]['.$row->id.'][status]', | |
| 165 | + $row->status, | |
| 166 | + [], | |
| 167 | + ['id' => 'status'.$k++], | |
| 168 | + true | |
| 169 | + ); | |
| 170 | + echo '</div> | |
| 171 | + <div class="list_name">'.esc_html(!empty($row->display_name) ? $row->display_name : $row->name).'</div> | |
| 172 | + </div>'; | |
| 173 | + } | |
| 174 | + } else { | |
| 175 | + $selectedIndex = ''; | |
| 176 | + $k = 0; | |
| 177 | + $dropdownOpts = []; | |
| 178 | + foreach ($data['subscription'] as $key => $row) { | |
| 179 | + if (empty($row->active) || !$row->visible) { | |
| 180 | + continue; | |
| 181 | + } | |
| 182 | + | |
| 183 | + $value = 0; | |
| 184 | + $dropdownOpts[] = acym_selectOption($row->id, (!empty($row->display_name) ? $row->display_name : $row->name)); | |
| 185 | + if ($row->status == 1) { | |
| 186 | + $value = 1; | |
| 187 | + $selectedIndex = $k; | |
| 188 | + } | |
| 189 | + echo '<input type="hidden" class="listsub-dropdown" name="data[listsub]['.esc_attr($row->id).'][status]" value="'.esc_attr($value).'">'; | |
| 190 | + | |
| 191 | + $k++; | |
| 192 | + } | |
| 193 | + | |
| 194 | + acym_select($dropdownOpts, 'data[listsubdropdown]', $selectedIndex, null, 'value', 'text', null, false, true); | |
| 195 | + } | |
| 196 | + ?> | |
| 197 | + </div> | |
| 198 | + </fieldset> | |
| 199 | + <?php | |
| 200 | + } | |
| 201 | + | |
| 202 | + if (empty($data['user']->id) && $data['config']->get('captcha', 'none') !== 'none' && !empty($data['captchaHelper'])) { | |
| 203 | + echo '<div id="trcaptcha" class="acy_onefield">'; | |
| 204 | + $data['captchaHelper']->display($formName); | |
| 205 | + echo '</div>'; | |
| 206 | + } | |
| 207 | + | |
| 208 | + if (!empty($data['source'])) { | |
| 209 | + echo '<input type="hidden" name="acy_source" value="'.esc_attr($data['source']).'" />'; | |
| 210 | + } | |
| 211 | + | |
| 212 | + // CMS specific things | |
| 213 | + if (!empty($data['Itemid'])) { | |
| 214 | + echo '<input type="hidden" name="Itemid" value="'.esc_attr($data['Itemid']).'" />'; | |
| 215 | + } | |
| 216 | + | |
| 217 | + if (acym_isNoTemplate()) { | |
| 218 | + echo '<input type="hidden" name="tmpl" value="component"/>'; | |
| 219 | + } | |
| 220 | + | |
| 221 | + // Form params | |
| 222 | + acym_formOptions(true, 'savechanges', '', 'frontusers'); | |
| 223 | + | |
| 224 | + if (isset($data['disableButtons']) && $data['disableButtons']) { | |
| 225 | + $actionClick = 'return false;'; | |
| 226 | + } else { | |
| 227 | + $actionClick = 'return submitAcymForm(\'savechanges\',\''.$formName.'\', \'acym_checkChangeForm\');'; | |
| 228 | + } | |
| 229 | + ?> | |
| 230 | + | |
| 231 | + <input type="hidden" name="hiddenlists" value="<?php echo esc_attr(implode(',', $data['hiddenlists'])); ?>" /> | |
| 232 | + <input type="hidden" name="user[id]" value="<?php echo esc_attr($data['user']->id); ?>" /> | |
| 233 | + <input type="hidden" name="userId" value="<?php echo esc_attr($data['user']->id); ?>" /> | |
| 234 | + <input type="hidden" name="userKey" value="<?php echo esc_attr($data['user']->key ?? ''); ?>" /> | |
| 235 | + <input type="hidden" name="ajax" value="1" /> | |
| 236 | + <input type="hidden" name="acyprofile" value="1" /> | |
| 237 | + | |
| 238 | + <p class="acymodifybutton"> | |
| 239 | + <button class="btn btn-primary" | |
| 240 | + type="submit" | |
| 241 | + onclick="<?php echo esc_attr($actionClick); ?>"> | |
| 242 | + <?php echo esc_html(acym_translation(empty($data['user']->id) ? 'ACYM_SUBSCRIBE' : 'ACYM_SAVE_CHANGES')); ?> | |
| 243 | + </button> | |
| 244 | + </p> | |
| 245 | + </form> | |
| 246 | + <?php if (!empty($data['posttext'])) { | |
| 247 | + echo '<span class="acym_posttext">'.wp_kses( | |
| 248 | + $data['posttext'], | |
| 249 | + $allowedIntroTags | |
| 250 | + ).'</span>'; | |
| 251 | + } ?> | |
| 252 | +</div> | |