← All changes
|
back/dynamics/subscription/SubscriptionAutomationTriggers.php
+0
-74
10.0.1
→
11.1.1
View file →
| @@ -1,74 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -use AcyMailing\Classes\FollowupClass; | |
| 4 | -use AcyMailing\Classes\AutomationClass; | |
| 5 | -use AcyMailing\Helpers\ScenarioHelper; | |
| 6 | - | |
| 7 | -trait SubscriptionAutomationTriggers | |
| 8 | -{ | |
| 9 | - private $subscribeTrigger = 'user_subscribe'; | |
| 10 | - private $unsubscribeTrigger = 'user_unsubscribe'; | |
| 11 | - | |
| 12 | - private $triggers = [ | |
| 13 | - 'user_subscribe' => 'ACYM_WHEN_USER_SUBSCRIBES', | |
| 14 | - 'user_unsubscribe' => 'ACYM_WHEN_USER_UNSUBSCRIBES', | |
| 15 | - ]; | |
| 16 | - | |
| 17 | - public function onAcymDeclareTriggers(&$triggers, &$defaultValues) | |
| 18 | - { | |
| 19 | - foreach ($this->triggers as $key => $name) { | |
| 20 | - $triggers['user'][$key] = new stdClass(); | |
| 21 | - $triggers['user'][$key]->name = '<div class="cell shrink">'.acym_translation($name).'</div>'; | |
| 22 | - $triggers['user'][$key]->option = '<input type="hidden" name="[triggers][user]['.$key.'][]" value="">'; | |
| 23 | - } | |
| 24 | - } | |
| 25 | - | |
| 26 | - public function onAcymDeclareTriggersScenario(&$triggers, &$defaultValues) | |
| 27 | - { | |
| 28 | - $this->onAcymDeclareTriggers($triggers, $defaultValues); | |
| 29 | - } | |
| 30 | - | |
| 31 | - public function onAcymExecuteTrigger(&$step, &$execute, &$data) | |
| 32 | - { | |
| 33 | - if (empty($data['userId'])) return; | |
| 34 | - | |
| 35 | - foreach ($this->triggers as $identifier => $name) { | |
| 36 | - if (empty($step->triggers[$identifier])) continue; | |
| 37 | - | |
| 38 | - $execute = true; | |
| 39 | - break; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - | |
| 43 | - public function onAcymDeclareSummary_triggers(&$automation) | |
| 44 | - { | |
| 45 | - if (!empty($automation->triggers[$this->subscribeTrigger])) { | |
| 46 | - $automation->triggers[$this->subscribeTrigger] = acym_translation('ACYM_WHEN_USER_SUBSCRIBES'); | |
| 47 | - } | |
| 48 | - | |
| 49 | - if (!empty($automation->triggers[$this->unsubscribeTrigger])) { | |
| 50 | - $automation->triggers[$this->unsubscribeTrigger] = acym_translation('ACYM_WHEN_USER_UNSUBSCRIBES'); | |
| 51 | - } | |
| 52 | - } | |
| 53 | - | |
| 54 | - public function onAcymAfterUserSubscribe(&$user, $lists) | |
| 55 | - { | |
| 56 | - $automationClass = new AutomationClass(); | |
| 57 | - $automationClass->trigger($this->subscribeTrigger, ['userId' => $user->id]); | |
| 58 | - | |
| 59 | - $scenarioHelper = new ScenarioHelper(); | |
| 60 | - $scenarioHelper->trigger($this->subscribeTrigger, ['userId' => $user->id]); | |
| 61 | - | |
| 62 | - $followupClass = new FollowupClass(); | |
| 63 | - $followupClass->addFollowupEmailsQueue($this->subscribeTrigger, $user->id, ['sub_lists' => $lists]); | |
| 64 | - } | |
| 65 | - | |
| 66 | - public function onAcymAfterUserUnsubscribe(&$user, $lists) | |
| 67 | - { | |
| 68 | - $automationClass = new AutomationClass(); | |
| 69 | - $automationClass->trigger($this->unsubscribeTrigger, ['userId' => $user->id]); | |
| 70 | - | |
| 71 | - $scenarioHelper = new ScenarioHelper(); | |
| 72 | - $scenarioHelper->trigger($this->unsubscribeTrigger, ['userId' => $user->id]); | |
| 73 | - } | |
| 74 | -} | |