PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.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
← All changes | back/Classes/StepClass.php +0 -83 11.1.0 → 11.1.1 View file →
@@ -1,83 +1,0 @@
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(object $step): ?int
18 - {
19 - foreach ($step as $oneAttribute => $value) {
20 - if (empty($value)) continue;
21 -
22 - $step->$oneAttribute = is_array($value) ? json_encode($value) : acym_stripTags($value);
23 - }
24 -
25 - //Some of the database need a name for the column name, they add an index and the name need to be unique
26 - if (empty($step->name)) {
27 - $step->name = 'step_'.time();
28 - }
29 -
30 - return parent::save($step);
31 - }
32 -
33 - public function getOneStepByAutomationId(int $automationId): ?object
34 - {
35 - $step = acym_loadObject('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
36 -
37 - return empty($step) ? null : $step;
38 - }
39 -
40 - public function getStepsByAutomationId(int $automationId): array
41 - {
42 - return acym_loadObjectList('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
43 - }
44 -
45 - public function getActiveStepByTrigger(array $triggers): array
46 - {
47 - if (empty($triggers)) {
48 - return [];
49 - }
50 -
51 - $query = 'SELECT step.*
52 - FROM #__acym_step AS step
53 - JOIN #__acym_automation AS automation ON step.automation_id = automation.id
54 - WHERE automation.active = 1';
55 -
56 - foreach ($triggers as $i => $oneTrigger) {
57 - $triggers[$i] = 'step.triggers LIKE '.acym_escapeDB('%"'.$oneTrigger.'"%');
58 - }
59 - $query .= ' AND ('.implode(' OR ', $triggers).')';
60 - $query .= ' ORDER BY automation.ordering ASC';
61 -
62 - $steps = acym_loadObjectList($query);
63 -
64 - foreach ($steps as $i => $oneStep) {
65 - if (!empty($oneStep->triggers)) $steps[$i]->triggers = json_decode($oneStep->triggers, true);
66 - }
67 -
68 - return $steps;
69 - }
70 -
71 - public function delete(array $elements): int
72 - {
73 - if (empty($elements)) return 0;
74 -
75 - acym_arrayToInteger($elements);
76 -
77 - $conditions = acym_loadResultArray('SELECT id FROM #__acym_condition WHERE step_id IN ('.implode(',', $elements).')');
78 - $conditionClass = new ConditionClass();
79 - $conditionClass->delete($conditions);
80 -
81 - return parent::delete($elements);
82 - }
83 -}