# acymailing/11.0.3/back/Classes/StepClass.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 11.0.3. 84 lines.

- Page: https://pluginprobe.com/plugins/acymailing/11.0.3/code/back/Classes/StepClass.php
- Raw: https://pluginprobe.com/plugins/acymailing/11.0.3/raw/back/Classes/StepClass.php
- Modified: 2026-08-03T10:18:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/11.0.3/code/back/Classes/StepClass.php#L10-L20`.

```php
<?php

namespace AcyMailing\Classes;

use AcyMailing\Core\AcymClass;

class StepClass extends AcymClass
{
    public function __construct()
    {
        parent::__construct();

        $this->table = 'step';
        $this->pkey = 'id';
    }

    public function save(object $step): ?int
    {
        foreach ($step as $oneAttribute => $value) {
            if (empty($value)) continue;

            $step->$oneAttribute = is_array($value) ? json_encode($value) : acym_stripTags($value);
        }

        //Some of the database need a name for the column name, they add an index and the name need to be unique
        if (empty($step->name)) {
            $step->name = 'step_'.time();
        }

        return parent::save($step);
    }

    public function getOneStepByAutomationId(int $automationId): ?object
    {
        $step = acym_loadObject('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));

        return empty($step) ? null : $step;
    }

    public function getStepsByAutomationId(int $automationId): array
    {
        return acym_loadObjectList('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
    }

    public function getActiveStepByTrigger(array $triggers): array
    {
        if (empty($triggers)) {
            return [];
        }

        $query = 'SELECT step.* 
            FROM #__acym_step AS step 
            JOIN #__acym_automation AS automation ON step.automation_id = automation.id 
            WHERE automation.active = 1';

        foreach ($triggers as $i => $oneTrigger) {
            $triggers[$i] = 'step.triggers LIKE '.acym_escapeDB('%"'.$oneTrigger.'"%');
        }
        $query .= ' AND ('.implode(' OR ', $triggers).')';
        $query .= ' ORDER BY automation.ordering ASC';

        $steps = acym_loadObjectList($query);

        foreach ($steps as $i => $oneStep) {
            if (!empty($oneStep->triggers)) $steps[$i]->triggers = json_decode($oneStep->triggers, true);
        }

        return $steps;
    }

    public function delete(array $elements): int
    {
        if (empty($elements)) return 0;

        acym_arrayToInteger($elements);

        $conditions = acym_loadResultArray('SELECT id FROM #__acym_condition WHERE step_id IN ('.implode(',', $elements).')');
        $conditionClass = new ConditionClass();
        $conditionClass->delete($conditions);

        return parent::delete($elements);
    }
}

```
