← All changes
|
back/dynamics/user/UserAutomationConditions.php
+102
-62
11.0.1
→
11.1.0
View file →
| @@ -5,10 +5,26 @@ | ||
| 5 | 5 | use AcyMailing\Types\OperatorType; |
| 6 | 6 | |
| 7 | 7 | trait UserAutomationConditions |
| 8 | 8 | { |
| 9 | - public function onAcymDeclareConditions(array &$conditions): void | |
| 9 | + protected function initAutomationConditions(): void | |
| 10 | 10 | { |
| 11 | + $this->automationConditions = [ | |
| 12 | + 'user' => [ | |
| 13 | + 'acy_group' => acym_translation('ACYM_GROUP'), | |
| 14 | + 'acy_cmsfield' => acym_translation('ACYM_ACCOUNT_USER_FIELD'), | |
| 15 | + ], | |
| 16 | + 'classic' => [ | |
| 17 | + 'acy_totaluser' => acym_translation('ACYM_NUMBER_OF_SUBSCRIBERS'), | |
| 18 | + ], | |
| 19 | + 'both' => [ | |
| 20 | + 'acy_toss' => acym_translation('ACYM_TOSS'), | |
| 21 | + ], | |
| 22 | + ]; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public function displayConditionOptions_acy_group(string $fieldName): void | |
| 26 | + { | |
| 11 | 27 | $allGroups = acym_getGroups(); |
| 12 | 28 | $groups = ['' => acym_translation('ACYM_NO_GROUP')]; |
| 13 | 29 | foreach ($allGroups as $group) { |
| 14 | 30 | $groups[$group->id] = $group->text; |
| @@ -13,34 +29,40 @@ | ||
| 13 | 29 | foreach ($allGroups as $group) { |
| 14 | 30 | $groups[$group->id] = $group->text; |
| 15 | 31 | } |
| 16 | 32 | $operatorIn = new OperatorInType(); |
| 33 | + ?> | |
| 34 | + <div class="intext_select_automation cell"> | |
| 35 | + <?php $operatorIn->display($fieldName.'[in]', '', 'acym__select', true); ?> | |
| 36 | + </div> | |
| 37 | + <div class="intext_select_automation cell"> | |
| 38 | + <?php acym_select( | |
| 39 | + $groups, | |
| 40 | + $fieldName.'[group]', | |
| 41 | + null, | |
| 42 | + ['class' => 'acym__select'], | |
| 43 | + 'value', | |
| 44 | + 'text', | |
| 45 | + null, | |
| 46 | + false, | |
| 47 | + true | |
| 48 | + ); ?> | |
| 49 | + </div> | |
| 50 | + <?php if (ACYM_CMS === 'joomla') { ?> | |
| 51 | + <div class="cell grid-x medium-3"> | |
| 52 | + <?php acym_switch([ | |
| 53 | + 'name' => $fieldName.'[subgroup]', | |
| 54 | + 'value' => 1, | |
| 55 | + 'label' => acym_translation('ACYM_INCLUDE_SUB_GROUPS'), | |
| 56 | + // One switch per row of the form, the JS replaces the placeholder to keep the ids unique | |
| 57 | + 'idPrefix' => '__numand__', | |
| 58 | + ]); ?> | |
| 59 | + </div> | |
| 60 | + <?php } | |
| 61 | + } | |
| 17 | 62 | |
| 18 | - $conditions['user']['acy_group'] = new stdClass(); | |
| 19 | - $conditions['user']['acy_group']->name = acym_translation('ACYM_GROUP'); | |
| 20 | - $conditions['user']['acy_group']->option = '<div class="intext_select_automation cell">'; | |
| 21 | - $conditions['user']['acy_group']->option .= $operatorIn->display('acym_condition[conditions][__numor__][__numand__][acy_group][in]'); | |
| 22 | - $conditions['user']['acy_group']->option .= '</div>'; | |
| 23 | - $conditions['user']['acy_group']->option .= '<div class="intext_select_automation cell">'; | |
| 24 | - $conditions['user']['acy_group']->option .= acym_select( | |
| 25 | - $groups, | |
| 26 | - 'acym_condition[conditions][__numor__][__numand__][acy_group][group]', | |
| 27 | - null, | |
| 28 | - ['class' => 'acym__select'] | |
| 29 | - ); | |
| 30 | - $conditions['user']['acy_group']->option .= '</div>'; | |
| 31 | - if (ACYM_CMS === 'joomla') { | |
| 32 | - $conditions['user']['acy_group']->option .= '<div class="cell grid-x medium-3">'; | |
| 33 | - ob_start(); | |
| 34 | - acym_switch([ | |
| 35 | - 'name' => 'acym_condition[conditions][__numor__][__numand__][acy_group][subgroup]', | |
| 36 | - 'value' => 1, | |
| 37 | - 'label' => acym_translation('ACYM_INCLUDE_SUB_GROUPS'), | |
| 38 | - ]); | |
| 39 | - $conditions['user']['acy_group']->option .= ob_get_clean(); | |
| 40 | - $conditions['user']['acy_group']->option .= '</div>'; | |
| 41 | - } | |
| 42 | - | |
| 63 | + private function getCmsFieldsForConditions(): array | |
| 64 | + { | |
| 43 | 65 | $cmsFields = []; |
| 44 | 66 | foreach (acym_getColumns('users', false) as $key => $column) { |
| 45 | 67 | $cmsFields[$column] = $column; |
| 46 | 68 | } |
| @@ -62,49 +84,67 @@ | ||
| 62 | 84 | foreach ($excluded as $oneExcluded) { |
| 63 | 85 | unset($cmsFields[$oneExcluded]); |
| 64 | 86 | } |
| 65 | 87 | |
| 88 | + return $cmsFields; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public function displayConditionOptions_acy_cmsfield(string $fieldName): void | |
| 92 | + { | |
| 66 | 93 | $operator = new OperatorType(); |
| 94 | + ?> | |
| 95 | + <div class="intext_select_automation cell"> | |
| 96 | + <?php acym_select( | |
| 97 | + $this->getCmsFieldsForConditions(), | |
| 98 | + $fieldName.'[field]', | |
| 99 | + null, | |
| 100 | + ['class' => 'acym__select'], | |
| 101 | + 'value', | |
| 102 | + 'text', | |
| 103 | + null, | |
| 104 | + false, | |
| 105 | + true | |
| 106 | + ); ?> | |
| 107 | + </div> | |
| 108 | + <div class="intext_select_automation cell"> | |
| 109 | + <?php $operator->display($fieldName.'[operator]', '', 'acym__select', true); ?> | |
| 110 | + </div> | |
| 111 | + <input class="intext_input_automation cell" type="text" name="<?php echo esc_attr($fieldName.'[value]'); ?>"> | |
| 112 | + <?php | |
| 113 | + } | |
| 67 | 114 | |
| 68 | - $conditions['user']['acy_cmsfield'] = new stdClass(); | |
| 69 | - $conditions['user']['acy_cmsfield']->name = acym_translation('ACYM_ACCOUNT_USER_FIELD'); | |
| 70 | - $conditions['user']['acy_cmsfield']->option = '<div class="intext_select_automation cell">'; | |
| 71 | - $conditions['user']['acy_cmsfield']->option .= acym_select( | |
| 72 | - $cmsFields, | |
| 73 | - 'acym_condition[conditions][__numor__][__numand__][acy_cmsfield][field]', | |
| 74 | - null, | |
| 75 | - ['class' => 'acym__select'] | |
| 76 | - ); | |
| 77 | - $conditions['user']['acy_cmsfield']->option .= '</div>'; | |
| 78 | - $conditions['user']['acy_cmsfield']->option .= '<div class="intext_select_automation cell">'; | |
| 79 | - $conditions['user']['acy_cmsfield']->option .= $operator->display('acym_condition[conditions][__numor__][__numand__][acy_cmsfield][operator]'); | |
| 80 | - $conditions['user']['acy_cmsfield']->option .= '</div>'; | |
| 81 | - $conditions['user']['acy_cmsfield']->option .= '<input class="intext_input_automation cell" type="text" name="acym_condition[conditions][__numor__][__numand__][acy_cmsfield][value]">'; | |
| 82 | - | |
| 83 | - $conditions['classic']['acy_totaluser'] = new stdClass(); | |
| 84 | - $conditions['classic']['acy_totaluser']->name = acym_translation('ACYM_NUMBER_OF_SUBSCRIBERS'); | |
| 85 | - $conditions['classic']['acy_totaluser']->option = '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_THERE_IS').'</div>'; | |
| 86 | - $conditions['classic']['acy_totaluser']->option .= '<div class="intext_select_automation cell">'; | |
| 87 | - $conditions['classic']['acy_totaluser']->option .= acym_select( | |
| 88 | - ['=' => acym_translation('ACYM_EXACTLY'), '>' => acym_translation('ACYM_MORE_THAN'), '<' => acym_translation('ACYM_LESS_THAN')], | |
| 89 | - 'acym_condition[conditions][__numor__][__numand__][acy_totaluser][operator]', | |
| 90 | - null, | |
| 91 | - ['class' => 'intext_select_automation acym__select'] | |
| 92 | - ); | |
| 93 | - $conditions['classic']['acy_totaluser']->option .= '</div>'; | |
| 94 | - $conditions['classic']['acy_totaluser']->option .= '<input type="number" min="0" class="intext_input_automation cell" name="acym_condition[conditions][__numor__][__numand__][acy_totaluser][number]">'; | |
| 95 | - $conditions['classic']['acy_totaluser']->option .= '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_ACYMAILING_USERS').'</div>'; | |
| 96 | - | |
| 97 | - $conditions['both']['acy_toss'] = new stdClass(); | |
| 98 | - $conditions['both']['acy_toss']->name = acym_translation('ACYM_TOSS'); | |
| 99 | - $conditions['both']['acy_toss']->option = '<input type="hidden" name="acym_condition[conditions][__numor__][__numand__][acy_toss][toss]" value="true"><div class="acym__automation__inner__text">'.acym_translation( | |
| 100 | - 'ACYM_TOSS_DESC' | |
| 101 | - ).'</div>'; | |
| 115 | + public function displayConditionOptions_acy_totaluser(string $fieldName): void | |
| 116 | + { | |
| 117 | + ?> | |
| 118 | + <div class="cell shrink acym__automation__inner__text"><?php echo esc_html(acym_translation('ACYM_THERE_IS')); ?></div> | |
| 119 | + <div class="intext_select_automation cell"> | |
| 120 | + <?php acym_select( | |
| 121 | + [ | |
| 122 | + '=' => acym_translation('ACYM_EXACTLY'), | |
| 123 | + '>' => acym_translation('ACYM_MORE_THAN'), | |
| 124 | + '<' => acym_translation('ACYM_LESS_THAN'), | |
| 125 | + ], | |
| 126 | + $fieldName.'[operator]', | |
| 127 | + null, | |
| 128 | + ['class' => 'intext_select_automation acym__select'], | |
| 129 | + 'value', | |
| 130 | + 'text', | |
| 131 | + null, | |
| 132 | + false, | |
| 133 | + true | |
| 134 | + ); ?> | |
| 135 | + </div> | |
| 136 | + <input type="number" min="0" class="intext_input_automation cell" name="<?php echo esc_attr($fieldName.'[number]'); ?>"> | |
| 137 | + <div class="cell shrink acym__automation__inner__text"><?php echo esc_html(acym_translation('ACYM_ACYMAILING_USERS')); ?></div> | |
| 138 | + <?php | |
| 102 | 139 | } |
| 103 | 140 | |
| 104 | - public function onAcymDeclareConditionsScenario(array &$conditions): void | |
| 141 | + public function displayConditionOptions_acy_toss(string $fieldName): void | |
| 105 | 142 | { |
| 106 | - $this->onAcymDeclareConditions($conditions); | |
| 143 | + ?> | |
| 144 | + <input type="hidden" name="<?php echo esc_attr($fieldName.'[toss]'); ?>" value="true"> | |
| 145 | + <div class="acym__automation__inner__text"><?php echo esc_html(acym_translation('ACYM_TOSS_DESC')); ?></div> | |
| 146 | + <?php | |
| 107 | 147 | } |
| 108 | 148 | |
| 109 | 149 | public function onAcymProcessCondition_acy_toss(&$query, $option, $num, &$conditionNotValid) |
| 110 | 150 | { |