PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.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 / StepClass.php

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

80 lines 2.2 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 StepClass extends AcymClass
8 {
9 public function __construct()
10 {
11 parent::__construct();
12
13 $this->table = 'step';
14 $this->pkey = 'id';
15 }
16
17 public function save($step)
18 {
19 foreach ($step as $oneAttribute => $value) {
20 if (empty($value)) continue;
21 if (is_array($value)) $value = json_encode($value);
22
23 $step->$oneAttribute = strip_tags($value);
24 }
25
26 if (empty($step->name)) $step->name = 'step_'.time();
27
28 return parent::save($step);
29 }
30
31 public function getOneStepByAutomationId($automationId)
32 {
33 return acym_loadObject('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
34 }
35
36 public function getStepsByAutomationId($automationId)
37 {
38 return acym_loadObjectList('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
39 }
40
41 public function getActiveStepByTrigger($triggers)
42 {
43 if (empty($triggers)) return [];
44
45 if (!is_array($triggers)) $triggers = [$triggers];
46
47 $query = 'SELECT step.*
48 FROM #__acym_step AS step
49 LEFT JOIN #__acym_automation AS automation ON step.automation_id = automation.id
50 WHERE automation.active = 1';
51
52 foreach ($triggers as $i => $oneTrigger) {
53 $triggers[$i] = 'step.triggers LIKE '.acym_escapeDB('%"'.$oneTrigger.'"%');
54 }
55 $query .= ' AND ('.implode(' OR ', $triggers).')';
56
57 $steps = acym_loadObjectList($query);
58
59 foreach ($steps as $i => $oneStep) {
60 if (!empty($oneStep->triggers)) $steps[$i]->triggers = json_decode($oneStep->triggers, true);
61 }
62
63 return $steps;
64 }
65
66 public function delete($elements)
67 {
68 if (empty($elements)) return 0;
69
70 if (!is_array($elements)) $elements = [$elements];
71 acym_arrayToInteger($elements);
72
73 $conditions = acym_loadResultArray('SELECT id FROM #__acym_condition WHERE step_id IN ('.implode(',', $elements).')');
74 $conditionClass = new ConditionClass();
75 $conditionsDeleted = $conditionClass->delete($conditions);
76
77 return parent::delete($elements);
78 }
79 }
80