| @@ -1,0 +1,75 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AcyMailing\Types; | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\ListClass; | |
| 6 | +use AcyMailing\Core\AcymObject; | |
| 7 | + | |
| 8 | +class FailActionType extends AcymObject | |
| 9 | +{ | |
| 10 | + private array $values = []; | |
| 11 | + private array $lists = []; | |
| 12 | + | |
| 13 | + public function __construct() | |
| 14 | + { | |
| 15 | + parent::__construct(); | |
| 16 | + | |
| 17 | + $this->values[] = acym_selectOption('noaction', 'ACYM_DO_NOTHING'); | |
| 18 | + $this->values[] = acym_selectOption('remove', 'ACYM_REMOVE_SUB'); | |
| 19 | + $this->values[] = acym_selectOption('unsub', 'ACYM_UNSUB_USER'); | |
| 20 | + $this->values[] = acym_selectOption('sub', 'ACYM_SUBSCRIBE_USER'); | |
| 21 | + $this->values[] = acym_selectOption('block', 'ACYM_BLOCK_USER'); | |
| 22 | + $this->values[] = acym_selectOption('delete', 'ACYM_DELETE_USER'); | |
| 23 | + | |
| 24 | + $listClass = new ListClass(); | |
| 25 | + $lists = $listClass->getAll('name'); | |
| 26 | + foreach ($lists as $oneList) { | |
| 27 | + $this->lists[] = acym_selectOption($oneList->id, $oneList->name); | |
| 28 | + } | |
| 29 | + | |
| 30 | + $js = 'function updateSubAction(num){ | |
| 31 | + window.document.getElementById("bounce_action_lists_"+num).style.display = window.document.getElementById("bounce_action_"+num).value == "sub" ? "" : "none"; | |
| 32 | + }'; | |
| 33 | + acym_addScript(true, $js); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public function display(string $num, string $value): string | |
| 37 | + { | |
| 38 | + $js = 'jQuery(document).ready(function($){ updateSubAction("'.$num.'"); });'; | |
| 39 | + acym_addScript(true, $js); | |
| 40 | + | |
| 41 | + $return = acym_select( | |
| 42 | + $this->values, | |
| 43 | + 'config[bounce_action_'.$num.']', | |
| 44 | + $value, | |
| 45 | + [ | |
| 46 | + 'class' => 'intext_select', | |
| 47 | + 'style' => 'width: 200px;', | |
| 48 | + 'onchange' => "updateSubAction('".$num."');", | |
| 49 | + ], | |
| 50 | + 'value', | |
| 51 | + 'text', | |
| 52 | + 'bounce_action_'.$num | |
| 53 | + ); | |
| 54 | + | |
| 55 | + //We add a span with an ID around the dropdown as we can't hide/display the dropdown itself any more due to bootstrap integration | |
| 56 | + $return .= '<span id="bounce_action_lists_'.$num.'" style="display:none">'; | |
| 57 | + | |
| 58 | + $return .= acym_select( | |
| 59 | + $this->lists, | |
| 60 | + 'config[bounce_action_lists_'.$num.']', | |
| 61 | + $this->config->get('bounce_action_lists_'.$num), | |
| 62 | + [ | |
| 63 | + 'class' => 'intext_select', | |
| 64 | + 'style' => 'width: 200px;margin-left: 5px;', | |
| 65 | + ], | |
| 66 | + 'value', | |
| 67 | + 'text', | |
| 68 | + str_replace(['[', ']'], ['_', ''], 'config[bounce_action_lists_'.$num.']') | |
| 69 | + ); | |
| 70 | + | |
| 71 | + $return .= '</span>'; | |
| 72 | + | |
| 73 | + return $return; | |
| 74 | + } | |
| 75 | +} | |