PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Classes / ConditionClass.php

ConditionClass.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.1, at back/Classes/ConditionClass.php

67 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Classes;
4
5 use AcyMailing\Core\AcymClass;
6
7 class ConditionClass extends AcymClass
8 {
9 public function __construct()
10 {
11 parent::__construct();
12
13 $this->table = 'condition';
14 $this->pkey = 'id';
15 }
16
17 public function getOneByStepId(int $stepId): ?object
18 {
19 $condition = acym_loadObject('SELECT * FROM #__acym_condition WHERE step_id = '.intval($stepId));
20
21 return empty($condition) ? null : $condition;
22 }
23
24 public function delete(array $elements): int
25 {
26 if (empty($elements)) return 0;
27
28 acym_arrayToInteger($elements);
29
30 $actionClass = new ActionClass();
31 $actionsIds = $actionClass->getAllActionsIdByConditionsId($elements);
32 if (!empty($actionsIds)) $actionClass->delete($actionsIds);
33
34 return parent::delete($elements);
35 }
36
37 public function save(object $element): ?int
38 {
39 foreach ($element as $oneAttribute => $value) {
40 if (empty($value)) {
41 continue;
42 }
43
44 if ($oneAttribute !== 'conditions') {
45 $element->$oneAttribute = is_array($value) ? json_encode($value) : acym_stripTags($value);
46 }
47 }
48
49 return parent::save($element);
50 }
51
52 public function getConditionsByStepId(int $id): array
53 {
54 $conditions = acym_loadObjectList(
55 'SELECT *
56 FROM #__acym_condition
57 WHERE `step_id` = '.intval($id)
58 );
59
60 foreach ($conditions as $condition) {
61 $condition->conditions = empty($condition->conditions) ? [] : json_decode($condition->conditions, true);
62 }
63
64 return $conditions;
65 }
66 }
67