| @@ -1,0 +1,47 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AcyMailing\Controllers\Mails; | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\MailClass; | |
| 6 | + | |
| 7 | +trait Automation | |
| 8 | +{ | |
| 9 | + public function deleteMailAutomation(): void | |
| 10 | + { | |
| 11 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 12 | + | |
| 13 | + $mailClass = new MailClass(); | |
| 14 | + $mailId = acym_getVar('int', 'id', 0); | |
| 15 | + | |
| 16 | + if (!empty($mailId)) { | |
| 17 | + $mailClass->delete([$mailId]); | |
| 18 | + } | |
| 19 | + | |
| 20 | + exit; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public function duplicateMailAutomation(): void | |
| 24 | + { | |
| 25 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 26 | + | |
| 27 | + $mailClass = new MailClass(); | |
| 28 | + $mailId = acym_getVar('int', 'id', 0); | |
| 29 | + $prevMail = acym_getVar('int', 'previousId'); | |
| 30 | + | |
| 31 | + if (!empty($prevMail)) { | |
| 32 | + $mailClass->delete([$prevMail]); | |
| 33 | + } | |
| 34 | + | |
| 35 | + if (empty($mailId)) { | |
| 36 | + acym_sendAjaxResponse(acym_translationSprintf('ACYM_NOT_FOUND', acym_translation('ACYM_ID')), [], false); | |
| 37 | + } | |
| 38 | + | |
| 39 | + $newMail = $mailClass->duplicateMail($mailId, MailClass::TYPE_AUTOMATION); | |
| 40 | + | |
| 41 | + if (empty($newMail)) { | |
| 42 | + acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_DUPLICATE_EMAIL'), [], false); | |
| 43 | + } | |
| 44 | + | |
| 45 | + acym_sendAjaxResponse('', ['newMail' => $newMail]); | |
| 46 | + } | |
| 47 | +} | |