| @@ -1,79 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace AcyMailing\Controllers\Automations; | |
| 4 | - | |
| 5 | -use AcyMailing\Classes\AutomationClass; | |
| 6 | -use AcyMailing\Classes\ConditionClass; | |
| 7 | -use AcyMailing\Classes\StepClass; | |
| 8 | -use AcyMailing\Helpers\WorkflowHelper; | |
| 9 | - | |
| 10 | -trait Condition | |
| 11 | -{ | |
| 12 | - public function condition(): void | |
| 13 | - { | |
| 14 | - if (!acym_level(ACYM_ENTERPRISE)) { | |
| 15 | - acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true)); | |
| 16 | - } | |
| 17 | - | |
| 18 | - } | |
| 19 | - | |
| 20 | - private function getSaveConditions(bool $isMassAction = false): array | |
| 21 | - { | |
| 22 | - $automationID = acym_getVar('int', 'id'); | |
| 23 | - $conditionId = acym_getVar('int', 'conditionId'); | |
| 24 | - $condition = acym_getVar('array', 'acym_condition', []); | |
| 25 | - $conditionClass = new ConditionClass(); | |
| 26 | - | |
| 27 | - $stepAutomationId = acym_getVar('int', 'stepAutomationId'); | |
| 28 | - | |
| 29 | - if (!empty($conditionId)) { | |
| 30 | - $condition['id'] = $conditionId; | |
| 31 | - } | |
| 32 | - | |
| 33 | - $condition['conditions']['type_condition'] = acym_getVar('string', 'type_condition'); | |
| 34 | - | |
| 35 | - if ($isMassAction) { | |
| 36 | - acym_session(); | |
| 37 | - $_SESSION['massAction']['conditions'] = $condition['conditions']; | |
| 38 | - | |
| 39 | - return []; | |
| 40 | - } | |
| 41 | - | |
| 42 | - $condition['conditions'] = json_encode($condition['conditions']); | |
| 43 | - | |
| 44 | - $condition['step_id'] = $stepAutomationId; | |
| 45 | - | |
| 46 | - foreach ($condition as $column => $value) { | |
| 47 | - acym_secureDBColumn($column); | |
| 48 | - } | |
| 49 | - | |
| 50 | - $condition = (object)$condition; | |
| 51 | - | |
| 52 | - $condition->id = $conditionClass->save($condition); | |
| 53 | - | |
| 54 | - return [ | |
| 55 | - 'automationId' => $automationID, | |
| 56 | - 'stepId' => $stepAutomationId, | |
| 57 | - 'conditionId' => $condition->id, | |
| 58 | - ]; | |
| 59 | - } | |
| 60 | - | |
| 61 | - public function saveExitConditions(): void | |
| 62 | - { | |
| 63 | - $this->getSaveConditions(); | |
| 64 | - | |
| 65 | - acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success'); | |
| 66 | - | |
| 67 | - $this->listing(); | |
| 68 | - } | |
| 69 | - | |
| 70 | - public function saveConditions(): void | |
| 71 | - { | |
| 72 | - $ids = $this->getSaveConditions(); | |
| 73 | - | |
| 74 | - acym_setVar('id', $ids['automationId']); | |
| 75 | - acym_setVar('stepId', $ids['stepId']); | |
| 76 | - acym_setVar('conditionId', $ids['conditionId']); | |
| 77 | - $this->action(); | |
| 78 | - } | |
| 79 | -} | |