Skip to content
Snippets Groups Projects
Commit 854d86aa authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Use session to save selected options in backend

parent 52eafbe2
No related branches found
No related tags found
1 merge request!6Feature 4 3
......@@ -77,6 +77,7 @@ class MailController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction(array $parameters = []) {
$pid = (int) GeneralUtility::_GP('id');
......@@ -84,6 +85,15 @@ class MailController extends ActionController {
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
}
if ($this->request->hasArgument('controller')) {
$this->session->setDataByKey('mode', $this->request->getArgument('controller'));
}
if ($this->session->getDataByKey('mode') !== BackendService::BACKEND_MODE_EDITOR_CONTROLLER) {
$this->redirect('index', $this->session->getDataByKey('mode'));
}
$registerArray = MailTemplateService::getRegisterArray();
......@@ -93,11 +103,25 @@ class MailController extends ActionController {
$this->redirect('empty');
}
// if no template & extensionKey is selected look for them in the session
if ($parameters['selectedTemplate'] === NULL || $parameters['selectedTemplate'] === '') {
$parameters['selectedExtension'] = key($registerArray);
$parameters['selectedTemplate'] = key($registerArray[$parameters['selectedExtension']]);
if (
$this->session->getDataByKey('selectedTemplate') !== NULL &&
$this->session->getDataByKey('selectedExtension') !== NULL
) {
$parameters['selectedTemplate'] = $this->session->getDataByKey('selectedTemplate');
$parameters['selectedExtension'] = $this->session->getDataByKey('selectedExtension');
} else {
// if nothing is set in the session, use the first entries from the register array
$parameters['selectedExtension'] = key($registerArray);
$parameters['selectedTemplate'] = key($registerArray[$parameters['selectedExtension']]);
}
}
// store selected template & extension key in the session
$this->session->setDataByKey('selectedTemplate', $parameters['selectedTemplate']);
$this->session->setDataByKey('selectedExtension', $parameters['selectedExtension']);
$languages = BackendService::getLanguages();
$templatesFromDb = BackendService::getSelectedTemplates(
......
......@@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Controller;
use SGalinski\SgMail\Service\BackendService;
use SGalinski\SgMail\Service\MailTemplateService;
use SGalinski\SgMail\Session\PhpSession;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -67,8 +68,20 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) {
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
}
if ($this->request->hasArgument('controller')) {
$this->session->setDataByKey('mode', $this->request->getArgument('controller'));
}
$filterTemplate = $_POST['filterTemplate'];
$filters['filterExtension'] = $filterTemplate;
$filters['filterTemplate'] = $filterTemplate;
......
......@@ -58,6 +58,12 @@ class BackendService {
const FROM_NAME_FILTER_OPTION = 6;
const REPLY_TO_NAME_FILTER_OPTION = 7;
// constants for deetermining the backend mode
const BACKEND_MODE_EDITOR = 'editor';
const BACKEND_MODE_EDITOR_CONTROLLER = 'Mail';
const BACKEND_MODE_QUEUE = 'queue';
const BACKEND_MODE_QUEUE_CONTROLLER = 'Queue';
/**
* Get all pages the be user has access to
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment