| @@ -1,0 +1,466 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\FieldClass; | |
| 6 | +use AcyMailing\Classes\ListClass; | |
| 7 | +use AcyMailing\Classes\UserClass; | |
| 8 | +use AcyMailing\Core\AcymParameter; | |
| 9 | +use AcyMailing\FrontControllers\FrontusersController; | |
| 10 | +use AcyMailing\FrontControllers\ArchiveController; | |
| 11 | + | |
| 12 | +function acym_formToken(): void | |
| 13 | +{ | |
| 14 | + echo '<input type="hidden" name="_wpnonce" value="'.esc_attr(wp_create_nonce('acymnonce')).'">'; | |
| 15 | +} | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * Check token with all the possibilities | |
| 19 | + */ | |
| 20 | +function acym_checkToken(): void | |
| 21 | +{ | |
| 22 | + $token = acym_getVar('cmd', '_wpnonce'); | |
| 23 | + if (!wp_verify_nonce($token, 'acymnonce')) { | |
| 24 | + die('Invalid Token'); | |
| 25 | + } | |
| 26 | +} | |
| 27 | + | |
| 28 | +function acym_getFormToken(): string | |
| 29 | +{ | |
| 30 | + $token = acym_getVar('cmd', '_wpnonce', ''); | |
| 31 | + if (empty($token)) { | |
| 32 | + $token = wp_create_nonce('acymnonce'); | |
| 33 | + acym_setVar('_wpnonce', $token); | |
| 34 | + } | |
| 35 | + | |
| 36 | + return '_wpnonce='.$token; | |
| 37 | +} | |
| 38 | + | |
| 39 | +function acym_noTemplate(): string | |
| 40 | +{ | |
| 41 | + return 'noheader=1'; | |
| 42 | +} | |
| 43 | + | |
| 44 | +function acym_isNoTemplate(): bool | |
| 45 | +{ | |
| 46 | + return acym_getVar('cmd', 'noheader') == '1'; | |
| 47 | +} | |
| 48 | + | |
| 49 | +function acym_setNoTemplate(bool $status = true): void | |
| 50 | +{ | |
| 51 | + if ($status) { | |
| 52 | + acym_setVar('noheader', '1'); | |
| 53 | + } else { | |
| 54 | + unset($_REQUEST['noheader']); | |
| 55 | + } | |
| 56 | +} | |
| 57 | + | |
| 58 | +function acym_formOptions(bool $token = true, string $task = '', string $currentStep = '', string $currentCtrl = '', bool $addPage = true): void | |
| 59 | +{ | |
| 60 | + if (!empty($currentStep)) { | |
| 61 | + echo '<input type="hidden" name="step" value="'.esc_attr($currentStep).'"/>'; | |
| 62 | + } | |
| 63 | + echo '<input type="hidden" name="nextstep" value=""/>'; | |
| 64 | + echo '<input type="hidden" name="task" value="'.esc_attr($task).'"/>'; | |
| 65 | + if ($addPage) { | |
| 66 | + echo '<input type="hidden" name="page" value="'.esc_attr(acym_getVar('cmd', 'page', '')).'"/>'; | |
| 67 | + } | |
| 68 | + echo '<input type="hidden" name="ctrl" value="'.esc_attr(empty($currentCtrl) ? acym_getVar('cmd', 'ctrl', '') : $currentCtrl).'"/>'; | |
| 69 | + if ($token) { | |
| 70 | + acym_formToken(); | |
| 71 | + } | |
| 72 | + echo '<button type="submit" class="is-hidden" id="formSubmit"></button>'; | |
| 73 | +} | |
| 74 | + | |
| 75 | +global $acymMetaData; | |
| 76 | +function acym_addMetadata($meta, $data, string $name = 'name'): void | |
| 77 | +{ | |
| 78 | + global $acymMetaData; | |
| 79 | + | |
| 80 | + $tag = new stdClass(); | |
| 81 | + $tag->meta = $meta; | |
| 82 | + $tag->data = $data; | |
| 83 | + $tag->name = $name; | |
| 84 | + | |
| 85 | + $acymMetaData[] = $tag; | |
| 86 | +} | |
| 87 | + | |
| 88 | +add_action('wp_head', 'acym_head_wp'); | |
| 89 | +add_action('admin_head', 'acym_head_wp'); | |
| 90 | +add_action('acym_head', 'acym_head_wp'); | |
| 91 | +function acym_head_wp(): void | |
| 92 | +{ | |
| 93 | + global $acymMetaData; | |
| 94 | + | |
| 95 | + if (!empty($acymMetaData)) { | |
| 96 | + foreach ($acymMetaData as $metadata) { | |
| 97 | + if (empty($metadata->data)) { | |
| 98 | + echo '<meta '.esc_attr($metadata->name).'="'.esc_attr($metadata->meta).'"/>'; | |
| 99 | + } else { | |
| 100 | + echo '<meta '.esc_attr($metadata->name).'="'.esc_attr($metadata->meta).'" content="'.esc_attr($metadata->data).'"/>'; | |
| 101 | + } | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + $acymMetaData = []; | |
| 106 | +} | |
| 107 | + | |
| 108 | +function acym_includeHeaders(): void | |
| 109 | +{ | |
| 110 | + do_action('acym_head'); | |
| 111 | +} | |
| 112 | + | |
| 113 | +function acym_getOptionRegacyPosition(): void | |
| 114 | +{ | |
| 115 | +} | |
| 116 | + | |
| 117 | +function acym_renderForm(AcymParameter $params, array $args = []): void | |
| 118 | +{ | |
| 119 | + acym_initModule($params); | |
| 120 | + | |
| 121 | + if (!empty($args['before_widget'])) { | |
| 122 | + echo wp_kses_post($args['before_widget']); | |
| 123 | + } | |
| 124 | + | |
| 125 | + $title = apply_filters('widget_title', $params->get('title')); | |
| 126 | + if (!empty($title)) { | |
| 127 | + if (!empty($args['before_title'])) { | |
| 128 | + echo wp_kses_post($args['before_title']); | |
| 129 | + } | |
| 130 | + echo esc_html($title); | |
| 131 | + if (!empty($args['after_title'])) { | |
| 132 | + echo wp_kses_post($args['after_title']); | |
| 133 | + } | |
| 134 | + } | |
| 135 | + | |
| 136 | + $identifiedUser = null; | |
| 137 | + $currentUserEmail = acym_currentUserEmail(); | |
| 138 | + $userClass = new UserClass(); | |
| 139 | + if ($params->get('userinfo', '1') == '1' && !empty($currentUserEmail)) { | |
| 140 | + $identifiedUser = $userClass->getOneByEmail($currentUserEmail); | |
| 141 | + } | |
| 142 | + | |
| 143 | + $visibleLists = $params->get('displists', []); | |
| 144 | + $hiddenLists = $params->get('hiddenlists', []); | |
| 145 | + $allFields = $params->get('fields', []); | |
| 146 | + acym_arrayToInteger($visibleLists); | |
| 147 | + acym_arrayToInteger($hiddenLists); | |
| 148 | + acym_arrayToInteger($allFields); | |
| 149 | + | |
| 150 | + // We need the email address | |
| 151 | + if (!in_array(2, $allFields)) { | |
| 152 | + $allFields[] = 2; | |
| 153 | + } | |
| 154 | + | |
| 155 | + $listClass = new ListClass(); | |
| 156 | + $fieldClass = new FieldClass(); | |
| 157 | + | |
| 158 | + $allLists = $listClass->getAllWithoutManagement(true); | |
| 159 | + $visibleLists = array_intersect($visibleLists, array_keys($allLists)); | |
| 160 | + $hiddenLists = array_intersect($hiddenLists, array_keys($allLists)); | |
| 161 | + | |
| 162 | + $allFields = $fieldClass->getFieldsByID($allFields); | |
| 163 | + $fields = []; | |
| 164 | + foreach ($allFields as $field) { | |
| 165 | + if (intval($field->active) === 0) continue; | |
| 166 | + $fields[$field->id] = $field; | |
| 167 | + } | |
| 168 | + | |
| 169 | + if (empty($visibleLists) && empty($hiddenLists)) { | |
| 170 | + $hiddenLists = array_keys($allLists); | |
| 171 | + } | |
| 172 | + | |
| 173 | + // Make sure we don't display a list that's in "automatically subscribe to" | |
| 174 | + if (!empty($visibleLists) && !empty($hiddenLists)) { | |
| 175 | + $visibleLists = array_diff($visibleLists, $hiddenLists); | |
| 176 | + } | |
| 177 | + | |
| 178 | + if (empty($identifiedUser->id)) { | |
| 179 | + //Check lists based on the option | |
| 180 | + $checkedLists = $params->get('listschecked', []); | |
| 181 | + if (!is_array($checkedLists)) { | |
| 182 | + if (strtolower($checkedLists) == 'all') { | |
| 183 | + $checkedLists = $visibleLists; | |
| 184 | + } elseif (strpos($checkedLists, ',') || is_numeric($checkedLists)) { | |
| 185 | + $checkedLists = explode(',', $checkedLists); | |
| 186 | + } else { | |
| 187 | + $checkedLists = []; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } else { | |
| 191 | + $checkedLists = []; | |
| 192 | + $userLists = $userClass->getUserSubscriptionById($identifiedUser->id); | |
| 193 | + | |
| 194 | + $countSub = 0; | |
| 195 | + $countUnsub = 0; | |
| 196 | + $formLists = array_merge($visibleLists, $hiddenLists); | |
| 197 | + foreach ($formLists as $idOneList) { | |
| 198 | + if (empty($userLists[$idOneList]) || $userLists[$idOneList]->status == 0) { | |
| 199 | + $countSub++; | |
| 200 | + } else { | |
| 201 | + $countUnsub++; | |
| 202 | + $checkedLists[] = $idOneList; | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + acym_arrayToInteger($checkedLists); | |
| 207 | + | |
| 208 | + $config = acym_config(); | |
| 209 | + | |
| 210 | + // Texts | |
| 211 | + $subscribeText = $params->get('subtext', 'ACYM_SUBSCRIBE'); | |
| 212 | + if (!empty($identifiedUser->id)) $subscribeText = $params->get('subtextlogged', 'ACYM_SUBSCRIBE'); | |
| 213 | + $unsubscribeText = $params->get('unsubtext', 'ACYM_UNSUBSCRIBE'); | |
| 214 | + $unsubButton = $params->get('unsub', '0'); | |
| 215 | + | |
| 216 | + $disableButtons = !empty($args['disableButtons']) || acym_isAdmin(); | |
| 217 | + | |
| 218 | + // Formatting | |
| 219 | + $listPosition = $params->get('listposition', 'before'); | |
| 220 | + $displayOutside = $params->get('textmode') == '0'; | |
| 221 | + | |
| 222 | + $showTrackingConsent = $params->get('trackingconsent', '0') == '1'; | |
| 223 | + | |
| 224 | + // Display success message | |
| 225 | + $successMode = $params->get('successmode', 'replace'); | |
| 226 | + | |
| 227 | + // Redirections | |
| 228 | + $redirectURL = $params->get('redirect', ''); | |
| 229 | + $unsubRedirectURL = $params->get('unsubredirect', ''); | |
| 230 | + $ajax = empty($redirectURL) && empty($unsubRedirectURL) && $successMode != 'standard' ? '1' : '0'; | |
| 231 | + | |
| 232 | + // Customization | |
| 233 | + $formClass = $params->get('formclass', ''); | |
| 234 | + $alignment = $params->get('alignment', 'none'); | |
| 235 | + | |
| 236 | + // Articles | |
| 237 | + $termsURL = acym_getArticleURL($params->get('termscontent', 0), false, 'ACYM_TERMS_CONDITIONS'); | |
| 238 | + $privacyURL = acym_getArticleURL($params->get('privacypolicy', 0), false, 'ACYM_PRIVACY_POLICY'); | |
| 239 | + | |
| 240 | + if (empty($termsURL)) { | |
| 241 | + $termsURL = $params->get('termscontentURL') ?? ''; | |
| 242 | + if (!empty($termsURL)) { | |
| 243 | + $termsURL = '<a href="'.esc_url($termsURL).'" target="_blank">'.esc_html(acym_translation('ACYM_TERMS_CONDITIONS')).'</a>'; | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + if (empty($privacyURL)) { | |
| 248 | + $privacyURL = $params->get('privacypolicyURL') ?? ''; | |
| 249 | + if (!empty($privacyURL)) { | |
| 250 | + $privacyURL = '<a href="'.esc_url($privacyURL).'" target="_blank">'.esc_html(acym_translation('ACYM_PRIVACY_POLICY')).'</a>'; | |
| 251 | + } | |
| 252 | + } | |
| 253 | + | |
| 254 | + if (empty($termsURL) && empty($privacyURL)) { | |
| 255 | + $termslink = ''; | |
| 256 | + } elseif (empty($privacyURL)) { | |
| 257 | + $termslink = acym_translationSprintf('ACYM_I_AGREE_TERMS', $termsURL); | |
| 258 | + } elseif (empty($termsURL)) { | |
| 259 | + $termslink = acym_translationSprintf('ACYM_I_AGREE_PRIVACY', $privacyURL); | |
| 260 | + } else { | |
| 261 | + $termslink = acym_translationSprintf('ACYM_I_AGREE_BOTH', $termsURL, $privacyURL); | |
| 262 | + } | |
| 263 | + | |
| 264 | + $formName = acym_getModuleFormName(); | |
| 265 | + $formAction = htmlspecialchars_decode(acym_frontendLink('frontusers')); | |
| 266 | + | |
| 267 | + $buttonStyle = ''; | |
| 268 | + if (!empty($params->get('button_background_color', ''))) $buttonStyle .= 'background-color: '.esc_attr($params->get('button_background_color', '')).';'; | |
| 269 | + if (!empty($params->get('button_text_color', ''))) $buttonStyle .= 'color: '.esc_attr($params->get('button_text_color', '')).';'; | |
| 270 | + if (strlen($params->get('button_border_size', '')) > 0) $buttonStyle .= 'border-width: '.esc_attr($params->get('button_border_size', '')).'px;'; | |
| 271 | + if (!empty($params->get('button_border_type', ''))) $buttonStyle .= 'border-style: '.esc_attr($params->get('button_border_type', '')).';'; | |
| 272 | + if (!empty($params->get('button_border_color', ''))) $buttonStyle .= 'border-color: '.esc_attr($params->get('button_border_color', '')).';'; | |
| 273 | + if (strlen($params->get('button_border_radius', '')) > 0) $buttonStyle .= 'border-radius: '.esc_attr($params->get('button_border_radius', '')).'px;'; | |
| 274 | + | |
| 275 | + if (!empty($buttonStyle)) { | |
| 276 | + acym_addStyle(true, '#acym_module_'.$formName.' .acysubbuttons .subbutton {'.$buttonStyle.'}'); | |
| 277 | + } | |
| 278 | + | |
| 279 | + $globalStyle = ''; | |
| 280 | + if (!empty($params->get('background_color', ''))) $globalStyle .= 'background-color: '.$params->get('background_color', '').';'; | |
| 281 | + if (!empty($params->get('text_color', ''))) $globalStyle .= 'color: '.$params->get('text_color', '').';'; | |
| 282 | + | |
| 283 | + if (!empty($globalStyle)) { | |
| 284 | + acym_addStyle(true, '#acym_module_'.$formName.', #acym_module_'.$formName.' td {'.$globalStyle.'}'); | |
| 285 | + } | |
| 286 | + | |
| 287 | + // Exclude default values from fields, if the user didn't fill them in | |
| 288 | + ?> | |
| 289 | + <script type="text/javascript"> | |
| 290 | + window.addEventListener('DOMContentLoaded', (event) => { | |
| 291 | + window.acymModule[<?php echo json_encode('excludeValues'.$formName); ?>] = []; | |
| 292 | + <?php | |
| 293 | + foreach ($fields as $field) { | |
| 294 | + echo 'window.acymModule["excludeValues'.esc_attr($formName).'"]["'.esc_attr($field->id).'"] = '.json_encode(acym_translation($field->name)).';'; | |
| 295 | + } | |
| 296 | + ?> | |
| 297 | + }); | |
| 298 | + </script> | |
| 299 | + <div class="acym_module <?php echo esc_attr($formClass); ?>" id="acym_module_<?php echo esc_attr($formName); ?>"> | |
| 300 | + <div class="acym_fulldiv" id="acym_fulldiv_<?php echo esc_attr($formName); ?>" <?php echo $alignment === 'none' ? '' : 'style="text-align: '.esc_attr($alignment).'"'; ?>> | |
| 301 | + <form enctype="multipart/form-data" | |
| 302 | + id="<?php echo esc_attr($formName); ?>" | |
| 303 | + name="<?php echo esc_attr($formName); ?>" | |
| 304 | + method="POST" | |
| 305 | + aria-label="<?php echo esc_attr(acym_translation('ACYM_SUBSCRIPTION')); ?>" | |
| 306 | + action="<?php echo esc_attr($formAction); ?>" | |
| 307 | + onsubmit="return submitAcymForm('subscribe','<?php echo esc_attr($formName); ?>')"> | |
| 308 | + <div class="acym_module_form"> | |
| 309 | + <?php | |
| 310 | + $introText = $params->get('introtext', ''); | |
| 311 | + if (!empty($introText)) { | |
| 312 | + echo '<div class="acym_introtext">'.esc_html($introText).'</div>'; | |
| 313 | + } | |
| 314 | + if ($params->get('mode', 'tableless') === 'tableless') { | |
| 315 | + include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'tableless.php'; | |
| 316 | + } else { | |
| 317 | + $displayInline = $params->get('mode', 'tableless') !== 'vertical'; | |
| 318 | + include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'default.php'; | |
| 319 | + } | |
| 320 | + ?> | |
| 321 | + </div> | |
| 322 | + | |
| 323 | + <input type="hidden" name="ctrl" value="frontusers" /> | |
| 324 | + <input type="hidden" name="task" value="notask" /> | |
| 325 | + <input type="hidden" name="option" value="<?php echo esc_attr(ACYM_COMPONENT); ?>" /> | |
| 326 | + | |
| 327 | + <?php | |
| 328 | + if (!empty($redirectURL)) echo '<input type="hidden" name="redirect" value="'.esc_url($redirectURL).'"/>'; | |
| 329 | + if (!empty($unsubRedirectURL)) echo '<input type="hidden" name="redirectunsub" value="'.esc_url($unsubRedirectURL).'"/>'; | |
| 330 | + ?> | |
| 331 | + <input type="hidden" name="ajax" value="<?php echo esc_attr($ajax); ?>" /> | |
| 332 | + <input type="hidden" name="successmode" value="<?php echo esc_attr($successMode); ?>" /> | |
| 333 | + <input type="hidden" name="acy_source" value="<?php echo esc_attr($params->get('source', '')); ?>" /> | |
| 334 | + <input type="hidden" name="hiddenlists" value="<?php echo esc_attr(implode(',', $hiddenLists)); ?>" /> | |
| 335 | + <input type="hidden" name="acyformname" value="<?php echo esc_attr($formName); ?>" /> | |
| 336 | + <input type="hidden" name="acysubmode" value="widget_acym" /> | |
| 337 | + <input type="hidden" name="confirmation_message" value="<?php echo esc_attr($params->get('confirmation_message', '')); ?>" /> | |
| 338 | + | |
| 339 | + <?php | |
| 340 | + $postText = $params->get('posttext', ''); | |
| 341 | + if (!empty($postText)) { | |
| 342 | + echo '<div class="acym_posttext">'.esc_html($postText).'</div>'; | |
| 343 | + } | |
| 344 | + ?> | |
| 345 | + </form> | |
| 346 | + </div> | |
| 347 | + </div> | |
| 348 | + <?php | |
| 349 | + if (!empty($args['after_widget'])) { | |
| 350 | + echo wp_kses_post($args['after_widget']); | |
| 351 | + } | |
| 352 | +} | |
| 353 | + | |
| 354 | +function acym_renderFormProfile(AcymParameter $params, array $args = []): string | |
| 355 | +{ | |
| 356 | + acym_initModule($params); | |
| 357 | + | |
| 358 | + if (!is_array($params->get('listsdropdown', '0'))) { | |
| 359 | + $listDropdown = $params->get('listsdropdown', '0'); | |
| 360 | + } else { | |
| 361 | + $listDropdown = $params->get('listsdropdown')[0]; | |
| 362 | + } | |
| 363 | + | |
| 364 | + $instance = [ | |
| 365 | + 'title' => $params->get('title', ''), | |
| 366 | + 'lists' => $params->get('lists'), | |
| 367 | + 'listschecked' => $params->get('listschecked'), | |
| 368 | + 'dropdown' => $listDropdown, | |
| 369 | + 'hiddenlists' => $params->get('hiddenlists'), | |
| 370 | + 'fields' => $params->get('fields'), | |
| 371 | + 'introtext' => $params->get('introtext', ''), | |
| 372 | + 'posttext' => $params->get('posttext', ''), | |
| 373 | + 'source' => $params->get('source', ''), | |
| 374 | + ]; | |
| 375 | + | |
| 376 | + $title = apply_filters('widget_title', $instance['title']); | |
| 377 | + if (!empty($title)) { | |
| 378 | + $title = '<span class="gamma widget-title">'.esc_html($title).'</span>'; | |
| 379 | + } | |
| 380 | + $return = $title; | |
| 381 | + | |
| 382 | + ob_start(); | |
| 383 | + acym_setVar('page', ACYM_COMPONENT.'_front'); | |
| 384 | + | |
| 385 | + $userController = new FrontusersController(); | |
| 386 | + $data = $userController->prepareParams((object)$instance); | |
| 387 | + $data['disableButtons'] = !empty($args['disableButtons']) || acym_isAdmin(); | |
| 388 | + | |
| 389 | + if (empty($data['user']->language)) { | |
| 390 | + $cmsUserLanguage = acym_getCmsUserLanguage(); | |
| 391 | + $data['user']->language = empty($cmsUserLanguage) ? acym_getLanguageTag() : $cmsUserLanguage; | |
| 392 | + } | |
| 393 | + | |
| 394 | + acym_setVar('layout', 'profile'); | |
| 395 | + $userController->display($data); | |
| 396 | + $return .= ob_get_clean(); | |
| 397 | + | |
| 398 | + return $return; | |
| 399 | +} | |
| 400 | + | |
| 401 | +function acym_renderFormArchive(AcymParameter $params, array $args = []): string | |
| 402 | +{ | |
| 403 | + acym_initModule($params); | |
| 404 | + | |
| 405 | + if (!is_array($params->get('popup', '1'))) { | |
| 406 | + $popup = $params->get('popup', '1'); | |
| 407 | + } else { | |
| 408 | + $popup = $params->get('popup')[0]; | |
| 409 | + } | |
| 410 | + if (!is_array($params->get('displayUserListOnly', '1'))) { | |
| 411 | + $displayUserListOnly = $params->get('displayUserListOnly', '1'); | |
| 412 | + } else { | |
| 413 | + $displayUserListOnly = $params->get('displayUserListOnly')[0]; | |
| 414 | + } | |
| 415 | + | |
| 416 | + $instance = [ | |
| 417 | + 'title' => $params->get('title', ''), | |
| 418 | + 'archiveNbNewslettersPerPage' => $params->get('archiveNbNewslettersPerPage', 20), | |
| 419 | + 'lists' => $params->get('lists'), | |
| 420 | + 'popup' => $popup, | |
| 421 | + 'displayUserListOnly' => $displayUserListOnly, | |
| 422 | + ]; | |
| 423 | + | |
| 424 | + $title = apply_filters('widget_title', $instance['title']); | |
| 425 | + if (!empty($title)) { | |
| 426 | + $title = '<span class="gamma widget-title">'.esc_html($title).'</span>'; | |
| 427 | + } | |
| 428 | + $return = $title; | |
| 429 | + ob_start(); | |
| 430 | + acym_setVar('page', 'front'); | |
| 431 | + $searchs = acym_getVar('array', 'acym_search', []); | |
| 432 | + $search = ''; | |
| 433 | + if (!empty($searchs[0])) $search = $searchs[0]; | |
| 434 | + $disableButtons = !empty($args['disableButtons']) || acym_isAdmin(); | |
| 435 | + $viewParams = [ | |
| 436 | + 'listsSent' => isset($instance['lists']) ? $instance['lists'] : [], | |
| 437 | + 'popup' => isset($instance['popup']) ? $instance['popup'] : '1', | |
| 438 | + 'displayUserListOnly' => isset($instance['displayUserListOnly']) ? $instance['displayUserListOnly'] : '1', | |
| 439 | + 'paramsCMS' => ['widget_id' => 0, 'suffix' => ''], | |
| 440 | + 'search' => $search, | |
| 441 | + 'disableButtons' => $disableButtons, | |
| 442 | + 'nbNewslettersPerPage' => $instance['archiveNbNewslettersPerPage'], | |
| 443 | + ]; | |
| 444 | + | |
| 445 | + $archiveController = new ArchiveController(); | |
| 446 | + $archiveController->showArchive($viewParams); | |
| 447 | + | |
| 448 | + $return .= ob_get_clean(); | |
| 449 | + | |
| 450 | + return $return; | |
| 451 | +} | |
| 452 | + | |
| 453 | +function acym_checked(bool $checked, bool $current = true, bool $display = true): string | |
| 454 | +{ | |
| 455 | + return checked($checked, $current, $display); | |
| 456 | +} | |
| 457 | + | |
| 458 | +function acym_selected(bool $selected, bool $current = true, bool $display = true): string | |
| 459 | +{ | |
| 460 | + return selected($selected, $current, $display); | |
| 461 | +} | |
| 462 | + | |
| 463 | +function acym_disabled(bool $disabled, bool $current = true, bool $display = true): string | |
| 464 | +{ | |
| 465 | + return disabled($disabled, $current, $display); | |
| 466 | +} | |