| @@ -1,0 +1,72 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AcyMailing\Controllers; | |
| 4 | + | |
| 5 | +use AcyMailing\Core\AcymController; | |
| 6 | +use AcyMailing\Controllers\Bounces\Listing as BouncesListing; | |
| 7 | +use AcyMailing\Controllers\Bounces\Rule; | |
| 8 | +use AcyMailing\Controllers\MailboxActions\Listing as MailboxActionsListing; | |
| 9 | +use AcyMailing\Controllers\MailboxActions\Edition as MailboxActionsEdition; | |
| 10 | + | |
| 11 | +class BouncesController extends AcymController | |
| 12 | +{ | |
| 13 | + use BouncesListing; | |
| 14 | + use Rule; | |
| 15 | + use MailboxActionsListing; | |
| 16 | + use MailboxActionsEdition; | |
| 17 | + | |
| 18 | + private bool $runBounce = false; | |
| 19 | + private array $mailboxReport = []; | |
| 20 | + | |
| 21 | + public function __construct() | |
| 22 | + { | |
| 23 | + parent::__construct(); | |
| 24 | + | |
| 25 | + $this->defaulttask = 'bounces'; | |
| 26 | + $this->breadcrumb[acym_translation('ACYM_MAILBOX_ACTIONS')] = acym_completeLink('bounces'); | |
| 27 | + $this->storeRedirectListing(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + public function storeRedirectListing(bool $fromListing = false): void | |
| 31 | + { | |
| 32 | + $variableName = 'ctrl_mailboxes_stored'; | |
| 33 | + $taskToStore = [ | |
| 34 | + '', | |
| 35 | + 'bounces', | |
| 36 | + 'mailboxes', | |
| 37 | + ]; | |
| 38 | + $currentTask = acym_getVar('string', 'task', ''); | |
| 39 | + if (!in_array($currentTask, $taskToStore) && !$fromListing) { | |
| 40 | + return; | |
| 41 | + } | |
| 42 | + | |
| 43 | + $controller = acym_getVar('RAW', $variableName, null, 'SESSION'); | |
| 44 | + if ((empty($currentTask) || !in_array($currentTask, $taskToStore)) && !empty($controller)) { | |
| 45 | + $taskToGo = is_array($controller) ? $controller['task'] : $controller; | |
| 46 | + $link = acym_completeLink('bounces&task='.$taskToGo, false, true); | |
| 47 | + if ($this->runBounce) { | |
| 48 | + $link .= '&runBounce=1'; | |
| 49 | + } | |
| 50 | + | |
| 51 | + acym_redirect($link); | |
| 52 | + } else { | |
| 53 | + if (empty($currentTask) || !in_array($currentTask, $taskToStore)) { | |
| 54 | + $currentTask = 'bounces'; | |
| 55 | + } | |
| 56 | + acym_setSession($variableName, $currentTask); | |
| 57 | + } | |
| 58 | + | |
| 59 | + $taskToCall = is_array($currentTask) ? $currentTask['task'] : $currentTask; | |
| 60 | + if ($fromListing && method_exists($this, $taskToCall)) { | |
| 61 | + $this->$taskToCall(); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + private function getAllParamsRequest(array &$data): void | |
| 66 | + { | |
| 67 | + $data['search'] = $this->getVarFiltersListing('string', 'mailboxes_search', ''); | |
| 68 | + $data['status'] = $this->getVarFiltersListing('string', 'mailboxes_status', ''); | |
| 69 | + $data['ordering'] = $this->getVarFiltersListing('cmd', 'mailboxes_ordering', 'id'); | |
| 70 | + $data['orderingSortOrder'] = $this->getVarFiltersListing('cmd', 'mailboxes_ordering_sort_order', 'desc'); | |
| 71 | + } | |
| 72 | +} | |