Commit cbd7b406 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Respecting root page id when sending mails (and test) + smaller refactorings

parent 77ea4e48
...@@ -80,8 +80,7 @@ class MailController extends ActionController { ...@@ -80,8 +80,7 @@ class MailController extends ActionController {
$selectedTemplate = NULL, $selectedExtension = NULL, $selectedLanguageLeft = NULL, $selectedTemplate = NULL, $selectedExtension = NULL, $selectedLanguageLeft = NULL,
$selectedLanguageRight = NULL $selectedLanguageRight = NULL
) { ) {
$siteRoot = BackendService::getSiteRoot((int) GeneralUtility::_GP('id')); $siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = $siteRoot['uid'];
if (!($this->session instanceof PhpSession)) { if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get('SGalinski\SgMail\Session\PhpSession'); $this->session = $this->objectManager->get('SGalinski\SgMail\Session\PhpSession');
...@@ -323,8 +322,8 @@ class MailController extends ActionController { ...@@ -323,8 +322,8 @@ class MailController extends ActionController {
$selectedExtension, $selectedTemplate, $selectedLanguage, $selectedContent, $selectedSubject, $selectedExtension, $selectedTemplate, $selectedLanguage, $selectedContent, $selectedSubject,
$selectedFromName, $selectedFromMail, $selectedCc, $selectedBcc, $selectedReplyTo $selectedFromName, $selectedFromMail, $selectedCc, $selectedBcc, $selectedReplyTo
) { ) {
$pageUid = (int) GeneralUtility::_GP('id'); $pageUid = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = BackendService::getSiteRoot($pageUid)['uid']; $siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */ /** @var Template $template */
$template = $this->templateRepository->findOneByTemplate( $template = $this->templateRepository->findOneByTemplate(
......
...@@ -70,9 +70,8 @@ class QueueController extends ActionController { ...@@ -70,9 +70,8 @@ class QueueController extends ActionController {
$selectedTemplate = key($registerArray[$selectedExtension]); $selectedTemplate = key($registerArray[$selectedExtension]);
} }
$pageUid = (int) GeneralUtility::_GP('id'); $pageUid = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = BackendService::getSiteRoot($pageUid)['uid']; $siteRootId = BackendService::getSiteRoot($pageUid);
debug($siteRootId);
$queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId); $queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId);
// create doc header component // create doc header component
......
...@@ -99,7 +99,7 @@ class BackendService { ...@@ -99,7 +99,7 @@ class BackendService {
* Retrieves the next site root in the page hierarchy from the current page * Retrieves the next site root in the page hierarchy from the current page
* *
* @param $currentPid * @param $currentPid
* @return array * @return int
*/ */
public static function getSiteRoot($currentPid) { public static function getSiteRoot($currentPid) {
$rootLine = BackendUtility::BEgetRootLine((int) GeneralUtility::_GP('id')); $rootLine = BackendUtility::BEgetRootLine((int) GeneralUtility::_GP('id'));
...@@ -111,6 +111,6 @@ class BackendService { ...@@ -111,6 +111,6 @@ class BackendService {
} }
} }
return $siteRoot; return $siteRoot['uid'];
} }
} }
...@@ -292,9 +292,12 @@ class MailTemplateService { ...@@ -292,9 +292,12 @@ class MailTemplateService {
* @return bool * @return bool
*/ */
public function loadPredefinedValuesForTemplate($extensionKey, $templateName, $language) { public function loadPredefinedValuesForTemplate($extensionKey, $templateName, $language) {
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */ /** @var Template $template */
$template = $this->templateRepository->findOneByTemplate( $template = $this->templateRepository->findOneByTemplate(
$this->extensionKey, $this->templateName, $this->language $this->extensionKey, $this->templateName, $this->language, $siteRootId
); );
if ($template !== NULL) { if ($template !== NULL) {
...@@ -316,9 +319,12 @@ class MailTemplateService { ...@@ -316,9 +319,12 @@ class MailTemplateService {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/ */
public function sendEmail($isPreview = FALSE) { public function sendEmail($isPreview = FALSE) {
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */ /** @var Template $template */
$template = $this->templateRepository->findOneByTemplate( $template = $this->templateRepository->findOneByTemplate(
$this->extensionKey, $this->templateName, $this->language $this->extensionKey, $this->templateName, $this->language, $siteRootId
); );
// if there is a template, prefer those values // if there is a template, prefer those values
...@@ -365,7 +371,7 @@ class MailTemplateService { ...@@ -365,7 +371,7 @@ class MailTemplateService {
/** @var StandaloneView $emailView */ /** @var StandaloneView $emailView */
$emailView = $this->objectManager->get(StandaloneView::class); $emailView = $this->objectManager->get(StandaloneView::class);
if (null === $defaultTemplateContent) { if (NULL === $defaultTemplateContent) {
$emailView->setTemplateSource($template->getContent()); $emailView->setTemplateSource($template->getContent());
$subject = $template->getSubject(); $subject = $template->getSubject();
} else { } else {
...@@ -437,7 +443,7 @@ class MailTemplateService { ...@@ -437,7 +443,7 @@ class MailTemplateService {
$mail->setReplyTo($this->replyToAddress); $mail->setReplyTo($this->replyToAddress);
$pageUid = (int) GeneralUtility::_GP('id'); $pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid)['uid']; $siteRootId = BackendService::getSiteRoot($pageUid);
$mail->setSiteRootId($siteRootId); $mail->setSiteRootId($siteRootId);
$mailRepository = $this->objectManager->get(MailRepository::class); $mailRepository = $this->objectManager->get(MailRepository::class);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment