| @@ -32,8 +32,9 @@ | ||
| 32 | 32 | if (!empty($automationId)) { |
| 33 | 33 | $automation['id'] = $automationId; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + // if the automation already exists | |
| 36 | 37 | if (!empty($stepAutomationId)) { |
| 37 | 38 | $stepAutomation['id'] = $stepAutomationId; |
| 38 | 39 | $conditionClass = new ConditionClass(); |
| 39 | 40 | $actionClass = new ActionClass(); |
| @@ -39,15 +40,18 @@ | ||
| 39 | 40 | $actionClass = new ActionClass(); |
| 40 | 41 | $condition = $conditionClass->getOneByStepId($stepAutomationId); |
| 41 | 42 | $step = $stepClass->getOneById($stepAutomationId); |
| 42 | 43 | |
| 44 | + // and the type_trigger has changed from "user" to "classic" | |
| 43 | 45 | $triggerChanged = $typeTrigger === 'classic' && json_decode($step->triggers)->type_trigger === 'user'; |
| 44 | 46 | if ($triggerChanged && !empty($condition)) { |
| 45 | 47 | $action = $actionClass->getOneByConditionId($condition->id); |
| 48 | + // if conditions are set on "user", we reset conditions | |
| 46 | 49 | if (json_decode($condition->conditions)->type_condition === 'user') { |
| 47 | 50 | $condition->conditions = null; |
| 48 | 51 | $conditionClass->save($condition); |
| 49 | 52 | } |
| 53 | + // if actions filters are set on "user", we reset actions filters | |
| 50 | 54 | if (!empty($action->filters) && json_decode($action->filters)->type_filter === 'user') { |
| 51 | 55 | $action->filters = null; |
| 52 | 56 | $actionClass->save($action); |
| 53 | 57 | } |
| @@ -82,8 +86,9 @@ | ||
| 82 | 86 | foreach ($stepAutomation as $stepColumn => $stepValue) { |
| 83 | 87 | acym_secureDBColumn($stepColumn); |
| 84 | 88 | } |
| 85 | 89 | |
| 90 | + //We need objects to save it so we make objects | |
| 86 | 91 | $automation = (object)$automation; |
| 87 | 92 | $stepAutomation = (object)$stepAutomation; |
| 88 | 93 | |
| 89 | 94 | $automation->id = $automationClass->save($automation); |
| @@ -104,8 +109,10 @@ | ||
| 104 | 109 | } |
| 105 | 110 | |
| 106 | 111 | public function saveExitInfo(): void |
| 107 | 112 | { |
| 113 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 114 | + | |
| 108 | 115 | $ids = $this->saveInfos(); |
| 109 | 116 | |
| 110 | 117 | if (empty($ids)) { |
| 111 | 118 | return; |
| @@ -119,8 +126,10 @@ | ||
| 119 | 126 | } |
| 120 | 127 | |
| 121 | 128 | public function saveInfo(): void |
| 122 | 129 | { |
| 130 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 131 | + | |
| 123 | 132 | $ids = $this->saveInfos(); |
| 124 | 133 | |
| 125 | 134 | if (empty($ids)) { |
| 126 | 135 | return; |