diff --git a/Classes/Command/SendMailCommandController.php b/Classes/Command/SendMailCommandController.php index f2a00570c85f7ded371214a238d5294faf3a429b..e8b858698bb4336a785518563e9993f9f4edc088 100644 --- a/Classes/Command/SendMailCommandController.php +++ b/Classes/Command/SendMailCommandController.php @@ -29,54 +29,49 @@ namespace SGalinski\SgMail\Command; use SGalinski\SgMail\Domain\Model\Mail; use SGalinski\SgMail\Domain\Repository\MailRepository; use SGalinski\SgMail\Service\PlaintextService; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Mail\MailMessage; +use TYPO3\CMS\Core\Resource\FileInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; -use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; +use Symfony\Component\Console\Command\Command; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Command controller for the mailing feature */ -class SendMailCommandController extends CommandController { +class SendMailCommandController extends Command { /** - * @var MailRepository + * Configure command */ - protected $mailRepository; - - /** - * Inject the MailRepository - * - * @param MailRepository $mailRepository - */ - public function injectMailRepository(MailRepository $mailRepository) { - $this->mailRepository = $mailRepository; + public function configure() { + $this->setDescription('Executes the sending of mails with a maximum of the given sentCount.') + ->addArgument('sendCount', InputArgument::OPTIONAL, 'Send count', 50); } /** - * @var PersistenceManager - */ - protected $persistenceManager; - - /** - * Inject the PersistenceManager + * Execute the command * - * @param PersistenceManager $persistenceManager - */ - public function injectPersistenceManager(PersistenceManager $persistenceManager) { - $this->persistenceManager = $persistenceManager; - } - - /** - * Executes the sending of mails with a maximum of the given sentCount. - * - * @param int $sendCount - * @return void - * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException + * @param InputInterface $input + * @param OutputInterface $output + * @return int + * @throws \TYPO3\CMS\Extbase\Object\Exception * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException + * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException */ - public function runSendMailsCommand($sendCount = 50) { - $mailsToSend = $this->mailRepository->findMailsToSend($sendCount); + public function execute(InputInterface $input, OutputInterface $output) { + $sendCount = $input->getArgument('sendCount'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var MailRepository $mailRepository */ + $mailRepository = $objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } + $mailsToSend = $mailRepository->findMailsToSend($sendCount); foreach ($mailsToSend as $mailToSend) { /** @var Mail $mailToSend */ $fromAddress = $mailToSend->getFromAddress(); @@ -96,9 +91,9 @@ class SendMailCommandController extends CommandController { if (empty($fromAddress) || empty($toAddresses)) { continue; } - $this->mailRepository->update($mailToSend); + $mailRepository->update($mailToSend); - $mailMessage = $this->objectManager->get(MailMessage::class); + $mailMessage = GeneralUtility::makeInstance(MailMessage::class); $mailMessage->setFrom($fromAddress, $mailToSend->getFromName()); $mailMessage->setTo($toAddresses); $mailMessage->setSubject($mailSubject); @@ -115,15 +110,21 @@ class SendMailCommandController extends CommandController { $mailMessage->setReplyTo($replyTo); } - $mailMessage->setBody($mailBody, 'text/html'); $plaintextService = GeneralUtility::makeInstance(PlaintextService::class); $plaintextBody = $plaintextService->makePlain($mailBody); - $mailMessage->addPart($plaintextBody, 'text/plain'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $mailMessage->setBody($mailBody, 'text/html'); + $mailMessage->addPart($plaintextBody, 'text/plain'); + } else { + $mailMessage->html($mailBody); + $mailMessage->text($plaintextBody); + } $attachments = $mailToSend->getAttachments(); if ($attachments->count() > 0) { foreach ($attachments as $attachment) { try { + /** @var FileInterface $file */ $file = $attachment->getOriginalResource(); if (!$file) { continue; @@ -133,17 +134,21 @@ class SendMailCommandController extends CommandController { if (!$file) { continue; } - - $mailMessage->attach( - \Swift_Attachment::newInstance( - $file->getContents(), $file->getName(), $file->getMimeType() - ) - ); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $mailMessage->attach( + \Swift_Attachment::newInstance( + $file->getContents(), $file->getName(), $file->getMimeType() + ) + ); + } else { + $mailMessage->attach($file->getContents(), $file->getName(), $file->getMimeType()); + } } catch (\Exception $exception) { continue; } } } + try { $mailMessage->send(); } catch (\Exception $exception) { @@ -152,6 +157,7 @@ class SendMailCommandController extends CommandController { } // Important for command controllers that change data - $this->persistenceManager->persistAll(); + $mailRepository->persist(); + return 0; } } diff --git a/Classes/Controller/ConfigurationController.php b/Classes/Controller/ConfigurationController.php index 9235c5477b663d3c714b236ba7accb50ce0fa1b3..bb8d44e58ffebe5247be9776d11975fb58591a9b 100644 --- a/Classes/Controller/ConfigurationController.php +++ b/Classes/Controller/ConfigurationController.php @@ -129,7 +129,6 @@ class ConfigurationController extends ActionController { 'docHeader' => $this->docHeaderComponent->docHeaderContent(), 'selectedTemplateFilter' => $filters['filterTemplate'], 'selectedExtensionFilter' => $filters['filterExtension'], - 'typo3Version' => VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version), 'selectedTemplateKey' => $selectedTemplate, 'selectedExtensionKey' => $selectedExtension, 'mode' => 'editor' @@ -181,24 +180,33 @@ class ConfigurationController extends ActionController { 'markerLabel' => $markerLabel ]; } + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registerService */ + $registerService = $this->objectManager->get(RegisterService::class); + } else { + $registerService = GeneralUtility::makeInstance(RegisterService::class); + } - $registerService = $this->objectManager->get(RegisterService::class); $registerService->writeRegisterFile( $templateName, $extensionKey, $markers, $subject, $description ); - $registerService->clearCaches(); - // store selected template & extension key in the session if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); } + $this->session->setDataByKey('selectedTemplate', $templateName); $this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY); - $this->redirect( 'index', 'Mail', NULL, ['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')] @@ -251,7 +259,13 @@ class ConfigurationController extends ActionController { ]; } - $registerService = $this->objectManager->get(RegisterService::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registerService */ + $registerService = $this->objectManager->get(RegisterService::class); + } else { + $registerService = GeneralUtility::makeInstance(RegisterService::class); + } + $registerService->migrateTemplateEntries($oldTemplateName, $oldExtensionKey, $templateName, $extensionKey); $registerService->deleteRegisterFile($oldTemplateName); $registerService->writeRegisterFile( @@ -262,7 +276,13 @@ class ConfigurationController extends ActionController { // store selected template & extension key in the session if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); @@ -286,7 +306,13 @@ class ConfigurationController extends ActionController { * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException */ public function deleteAction(string $selectedTemplate, string $selectedExtension) { - $registerService = $this->objectManager->get(RegisterService::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registerService */ + $registerService = $this->objectManager->get(RegisterService::class); + } else { + $registerService = GeneralUtility::makeInstance(RegisterService::class); + } + $registerService->deleteTemplate($selectedExtension, $selectedTemplate); $this->redirect( 'index', 'Mail', NULL, diff --git a/Classes/Controller/LayoutController.php b/Classes/Controller/LayoutController.php index 8a580475d16c59d435d6622618f0c3c3757c1683..adfc3cd146a1c40a53c2cc3233f513d2060f359c 100644 --- a/Classes/Controller/LayoutController.php +++ b/Classes/Controller/LayoutController.php @@ -32,7 +32,6 @@ use SGalinski\SgMail\Session\PhpSession; use TYPO3\CMS\Backend\Clipboard\Clipboard; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -104,15 +103,6 @@ class LayoutController extends ActionController { */ public function initializeView(ViewInterface $view) { parent::initializeView($view); - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addJsInlineCode( - 'typo3_version', 'TYPO3.version=' - . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) - . ';' - ); - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $pageRenderer->loadExtJS(); - } $this->initClipboard(); $view->assign('controller', 'Layout'); } @@ -124,7 +114,13 @@ class LayoutController extends ActionController { $pageUid = (int) GeneralUtility::_GP('id'); if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); @@ -158,7 +154,6 @@ class LayoutController extends ActionController { BackendService::makeButtons($this->docHeaderComponent, $this->request); $this->view->assign('pageUid', $pageUid); $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); - $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); } /** diff --git a/Classes/Controller/MailController.php b/Classes/Controller/MailController.php index b8efdc69086442f505ca275558104e9265ebddaf..a8611da1b0d5a7d12006d9ea73b669a3e9227a01 100644 --- a/Classes/Controller/MailController.php +++ b/Classes/Controller/MailController.php @@ -36,7 +36,6 @@ use SGalinski\SgMail\Session\PhpSession; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Messaging\FlashMessage; -use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -93,15 +92,6 @@ class MailController extends ActionController { */ public function initializeView(ViewInterface $view) { parent::initializeView($view); - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addJsInlineCode( - 'typo3_version', 'TYPO3.version=' - . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) - . ';' - ); - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $pageRenderer->loadExtJS(); - } $view->assign('controller', 'Mail'); } @@ -125,7 +115,13 @@ class MailController extends ActionController { $pid = (int) GeneralUtility::_GP('id'); if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); @@ -231,8 +227,13 @@ class MailController extends ActionController { $this->view->assign('languageTemplates', $templates); $this->view->assign('languageLabels', BackendService::getLanguageLabels($languages)); $this->view->assign('templates', $registerArray); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registerService */ + $registerService = $this->objectManager->get(RegisterService::class); + } else { + $registerService = GeneralUtility::makeInstance(RegisterService::class); + } - $registerService = $this->objectManager->get(RegisterService::class); $this->view->assign( 'isManual', $registerService->isManuallyRegisteredTemplate($parameters['selectedTemplate']) ); @@ -283,21 +284,14 @@ class MailController extends ActionController { BackendService::makeButtons($this->docHeaderComponent, $this->request); $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); - $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); /** @noinspection PhpInternalEntityUsedInspection */ $this->view->assign('beUserMail', $GLOBALS['BE_USER']->user['email']); // get the default language label and pass it to the view $pageTsConfig = BackendUtility::getPagesTSconfig($pageUid); - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $defaultLanguageLabel = LocalizationUtility::translate( - 'LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage' - ); - } else { - $defaultLanguageLabel = LocalizationUtility::translate( - 'lll:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage' - ); - } + $defaultLanguageLabel = LocalizationUtility::translate( + 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage' + ); if (isset($pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'])) { $defaultLanguageLabel = $pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel']; @@ -373,13 +367,19 @@ class MailController extends ActionController { $this->redirect('index', NULL, NULL, $arguments); } - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - /** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */ - $mailTemplateService = $objectManager->get( - MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] - ); - $mailIsSend = FALSE; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */ + $mailTemplateService = $objectManager->get( + MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] + ); + } else { + $mailTemplateService = GeneralUtility::makeInstance( + MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] + ); + } + $mailIsSend = FALSE; foreach ((array) $parameters['templates'] as $key => $template) { $mailTemplateService->setLanguage($key); $mailTemplateService->setToAddresses($parameters['emailAddress']); diff --git a/Classes/Controller/NewsletterController.php b/Classes/Controller/NewsletterController.php index e26083b1157475960c5d3378fc96eb56a35870a5..7ea0b858277d68819be6e94dcc9c7957406184fd 100644 --- a/Classes/Controller/NewsletterController.php +++ b/Classes/Controller/NewsletterController.php @@ -37,7 +37,6 @@ use SGalinski\SgMail\Session\PhpSession; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Messaging\FlashMessage; -use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -108,15 +107,6 @@ class NewsletterController extends ActionController { */ public function initializeView(ViewInterface $view) { parent::initializeView($view); - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addJsInlineCode( - 'typo3_version', 'TYPO3.version=' - . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) - . ';' - ); - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $pageRenderer->loadExtJS(); - } $view->assign('controller', 'Newsletter'); } @@ -140,7 +130,13 @@ class NewsletterController extends ActionController { $pid = (int) GeneralUtility::_GP('id'); if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); @@ -277,14 +273,17 @@ class NewsletterController extends ActionController { $this->view->assign('languageTemplates', $templates); $this->view->assign('languageLabels', BackendService::getLanguageLabels($languages)); $this->view->assign('templates', $registerArray); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registerService */ + $registerService = $this->objectManager->get(RegisterService::class); + } else { + $registerService = GeneralUtility::makeInstance(RegisterService::class); + } - $registerService = $this->objectManager->get(RegisterService::class); $this->view->assign( 'isManual', $registerService->isManuallyRegisteredTemplate($parameters['selectedTemplate']) ); - $templateDescription = $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['description']; - if (\is_array($templateDescription)) { if ($languages[0]['isocode']) { $templateDescription = $templateDescription[$languages[0]['isocode']]; @@ -329,23 +328,15 @@ class NewsletterController extends ActionController { BackendService::makeButtons($this->docHeaderComponent, $this->request); $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); - $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); /** @noinspection PhpInternalEntityUsedInspection */ $beUserMail = (!empty($arguments['emailAddress'])?$arguments['emailAddress']:$GLOBALS['BE_USER']->user['email']); $this->view->assign('beUserMail', $beUserMail); // get the default language label and pass it to the view $pageTsConfig = BackendUtility::getPagesTSconfig($pageUid); - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $defaultLanguageLabel = LocalizationUtility::translate( - 'LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage' - ); - } else { - $defaultLanguageLabel = LocalizationUtility::translate( - 'lll:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage' - ); - } - + $defaultLanguageLabel = LocalizationUtility::translate( + 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage' + ); if (isset($pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'])) { $defaultLanguageLabel = $pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel']; } @@ -418,20 +409,25 @@ class NewsletterController extends ActionController { } } - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - /** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */ - $mailTemplateService = $objectManager->get( - MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] - ); - $mailIsSend = FALSE; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */ + $mailTemplateService = $objectManager->get( + MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] + ); + } else { + $mailTemplateService = GeneralUtility::makeInstance( + MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension'] + ); + } + $mailIsSend = FALSE; $mailTemplateService->setTemplateName($parameters['selectedTemplate']); $mailTemplateService->setExtensionKey($parameters['selectedExtension']); $mailTemplateService->setFromName($parameter['fromName']); $mailTemplateService->setFromAddress($parameter['fromMail']); $mailTemplateService->setSubject($parameter['subject']); $mailTemplateService->setReplyToAddress($parameter['replyTo']); - if (!$this->request->getArgument('sendRealEmails')) { // Send test emails $message = LocalizationUtility::translate('backend.success_mail', 'sg_mail'); diff --git a/Classes/Controller/QueueController.php b/Classes/Controller/QueueController.php index 0f581230150bc6f6d51c0bf09209e7fced70caad..9b1178d491cdbfd3c10091c3706ead290e13a56e 100644 --- a/Classes/Controller/QueueController.php +++ b/Classes/Controller/QueueController.php @@ -33,7 +33,6 @@ use SGalinski\SgMail\Session\PhpSession; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Messaging\FlashMessage; -use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -75,15 +74,6 @@ class QueueController extends ActionController { */ public function initializeView(ViewInterface $view) { parent::initializeView($view); - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addJsInlineCode( - 'typo3_version', 'TYPO3.version=' - . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) - . ';' - ); - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $pageRenderer->loadExtJS(); - } $view->assign('controller', 'Queue'); } @@ -161,7 +151,6 @@ class QueueController extends ActionController { $this->docHeaderComponent->setMetaInformation($pageInfo); BackendService::makeButtons($this->docHeaderComponent, $this->request); $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); - $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); } @@ -218,7 +207,13 @@ class QueueController extends ActionController { */ protected function initSessionAndTemplateFilter(array &$filters) { if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var PhpSession session */ + $this->session = $this->objectManager->get(PhpSession::class); + } else { + $this->session = GeneralUtility::makeInstance(PhpSession::class); + } + $this->session->setSessionKey('sg_mail_controller_session'); } else { $this->session->setSessionKey('sg_mail_controller_session'); diff --git a/Classes/Domain/Repository/AbstractRepository.php b/Classes/Domain/Repository/AbstractRepository.php index fd76ce5911a308b515c9ef284a5d54c2670ad216..1975202ca63855367924ca84f3e07b8cc8ac20e3 100644 --- a/Classes/Domain/Repository/AbstractRepository.php +++ b/Classes/Domain/Repository/AbstractRepository.php @@ -26,55 +26,42 @@ namespace SGalinski\SgMail\Domain\Repository; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; -use TYPO3\CMS\Frontend\Page\PageRepository; /** * Abstract Repository */ abstract class AbstractRepository extends Repository { /** - * Initializes the repository default settings + * AbstractRepository constructor. * - * @return void + * @param ObjectManagerInterface $objectManager */ - public function initializeObject() { - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + public function __construct(ObjectManagerInterface $objectManager) { + parent::__construct($objectManager); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var Typo3QuerySettings $querySettings */ + $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + } else { + $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); + } + $querySettings->setRespectStoragePage(FALSE); if (TYPO3_MODE === 'BE') { $querySettings->setIgnoreEnableFields(TRUE); } + $this->setDefaultQuerySettings($querySettings); } /** - * Method creates a statement string of the enableFields for the given database table. - * - * @param string $table - * @param string $alias - * @param bool $ignoreEnableFields - * @return string + * Persist changes to database */ - protected function getEnableFieldsStatement($table, $alias = '', $ignoreEnableFields = FALSE): string { - if (TYPO3_MODE === 'FE' && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { - /** @var PageRepository $pageRepository */ - $pageRepository = $GLOBALS['TSFE']->sys_page; - $statement = $pageRepository->enableFields($table); - } else { - $statement = BackendUtility::deleteClause($table); - - if (!$ignoreEnableFields) { - $statement .= BackendUtility::BEenableFields($table); - } - } - - if ($alias !== '') { - $statement = str_replace($table, $alias, $statement); - } - - return $statement; + public function persist() { + $this->persistenceManager->persistAll(); } } diff --git a/Classes/Domain/Repository/FrontendUserGroupRepository.php b/Classes/Domain/Repository/FrontendUserGroupRepository.php index 4d814fcbe01c294f1ade328cc52191e9eceab90c..ee1019f0b627693b2e50b846772854977bf1554f 100644 --- a/Classes/Domain/Repository/FrontendUserGroupRepository.php +++ b/Classes/Domain/Repository/FrontendUserGroupRepository.php @@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Domain\Repository; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup; +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; /** * Frontend User Group Repository @@ -35,9 +36,12 @@ use TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup; class FrontendUserGroupRepository extends \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository { /** - * initializes the object + * FrontendUserGroupRepository constructor. + * + * @param ObjectManagerInterface $objectManager */ - public function initializeObject() { + public function __construct(ObjectManagerInterface $objectManager) { + parent::__construct($objectManager); $this->objectType = FrontendUserGroup::class; $querySettings = $this->createQuery()->getQuerySettings(); $querySettings->setRespectStoragePage(FALSE); diff --git a/Classes/Domain/Repository/LayoutRepository.php b/Classes/Domain/Repository/LayoutRepository.php index 14f90c81a9de5f95b00d81d776afd06859c9f0e8..38e77b67878f931c5e265816e235882580e1fdcc 100644 --- a/Classes/Domain/Repository/LayoutRepository.php +++ b/Classes/Domain/Repository/LayoutRepository.php @@ -31,6 +31,8 @@ use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; @@ -41,13 +43,19 @@ class LayoutRepository extends Repository { const LAYOUT_TABLE_NAME = 'tx_sgmail_domain_model_layout'; /** - * Initializes the repository default settings + * LayoutRepository constructor. * - * @return void + * @param ObjectManagerInterface $objectManager */ - public function initializeObject() { - /** @var $querySettings Typo3QuerySettings */ - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + public function __construct(ObjectManagerInterface $objectManager) { + parent::__construct($objectManager); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var $querySettings Typo3QuerySettings */ + $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + } else { + $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); + } + $querySettings->setRespectStoragePage(FALSE); $querySettings->setLanguageOverlayMode(TRUE); $querySettings->setLanguageMode('content_fallback'); diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index 19378a3726fdd32188d06752cf880a4984c8ab01..14cc20d1bd187eca8ebbfac4c04f4a99391def5d 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -45,7 +45,7 @@ class MailRepository extends AbstractRepository { * @param int $limit * @return array|QueryResultInterface */ - public function findMailsToSend($limit = NULL) { + public function findMailsToSend(int $limit = NULL) { $query = $this->createQuery(); if ($limit) { $query->setLimit($limit); diff --git a/Classes/Domain/Repository/TemplateRepository.php b/Classes/Domain/Repository/TemplateRepository.php index 42af546234d69bff516526d223cc798c41aaa849..d01f8b430e0f249d7ebea8ed1265306a0b5463f6 100644 --- a/Classes/Domain/Repository/TemplateRepository.php +++ b/Classes/Domain/Repository/TemplateRepository.php @@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Domain\Repository; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; /** @@ -44,15 +45,18 @@ class TemplateRepository extends AbstractRepository { */ public function findOneByTemplate($extensionKey, $templateName, $language, $pid = 0) { $query = $this->createQuery(); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var Typo3QuerySettings $querySettings */ + $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + } else { + $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); + } - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); $querySettings->setRespectStoragePage(FALSE); - $constraintsAnd[] = $query->equals('extension_key', $extensionKey); $constraintsAnd[] = $query->equals('template_name', $templateName); $constraintsAnd[] = $query->equals('language', $language); $constraintsAnd[] = $query->equals('pid', (int) $pid); - $query->matching( $query->logicalAnd($constraintsAnd) ); diff --git a/Classes/Finisher/Forms/FormsFinisher.php b/Classes/Finisher/Forms/FormsFinisher.php index 6c96497c7a50915d552f47a1c273e003686c3b93..af4f5f800597cb3431c2f12ddd1bd6eb5cbe8eb9 100644 --- a/Classes/Finisher/Forms/FormsFinisher.php +++ b/Classes/Finisher/Forms/FormsFinisher.php @@ -29,7 +29,10 @@ namespace SGalinski\SgMail\Finisher\Forms; use SGalinski\SgMail\Service\MailTemplateService; use SGalinski\SgMail\Service\RegisterService; +use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; @@ -105,13 +108,23 @@ class FormsFinisher extends AbstractFinisher { $extensionKey = trim((string) $this->parseOption('extension')); $extensionKey = $extensionKey ?: 'sg_mail'; - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $mailTemplateService = $objectManager->get( - MailTemplateService::class, $templateName, $extensionKey, $markers, $markerLabels - ); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var MailTemplateService $mailTemplateService */ + $mailTemplateService = $objectManager->get( + MailTemplateService::class, $templateName, $extensionKey, $markers, $markerLabels + ); + } else { + $mailTemplateService = GeneralUtility::makeInstance( + MailTemplateService::class, $templateName, $extensionKey, $markers, $markerLabels + ); + } $mailTemplateService->setIgnoreMailQueue(TRUE); - $mailTemplateService->setLanguage($GLOBALS['TSFE']->config['config']['language']); + $languageId = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0); + $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int) $GLOBALS['TSFE']->id); + $siteLanguage = $site->getLanguageById($languageId); + $mailTemplateService->setLanguage($siteLanguage->getTypo3Language()); $mailToAddresses = trim((string) $this->parseOption('mailTo')); if ($mailToAddresses !== '') { diff --git a/Classes/Service/BackendService.php b/Classes/Service/BackendService.php index 466f8fc4f21d90cacd8c32f9cf01a69bb3a70f53..f0e7708f81dfc19af396711f0cd48d873ac0d926 100644 --- a/Classes/Service/BackendService.php +++ b/Classes/Service/BackendService.php @@ -26,14 +26,11 @@ namespace SGalinski\SgMail\Service; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use Doctrine\DBAL\Driver\Mysqli\MysqliStatement; -use Doctrine\DBAL\Statement; use SGalinski\SgMail\Domain\Model\Template; use SGalinski\SgMail\Domain\Repository\FrontendUserGroupRepository; use SGalinski\SgMail\Domain\Repository\MailRepository; use SGalinski\SgMail\Domain\Repository\TemplateRepository; use SGalinski\SgMail\Utility\ExtensionUtility; -use Symfony\Component\HttpFoundation\StreamedResponse; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; @@ -93,16 +90,6 @@ class BackendService { 1 ) ); - - if (!version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $queryBuilder->andWhere( - $queryBuilder->expr()->eq( - 'sys_language_uid', - 0 - ) - ); - } - $rows = $queryBuilder->execute()->fetchAll(); foreach ($rows as $row) { @@ -132,16 +119,9 @@ class BackendService { public static function makeButtons($docHeaderComponent, $request) { /** @var ButtonBar $buttonBar */ $buttonBar = $docHeaderComponent->getButtonBar(); - /** @var IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); - - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $locallangPath = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:'; - } else { - $locallangPath = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:'; - } - + $locallangPath = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:'; // Refresh $refreshButton = $buttonBar->makeLinkButton() ->setHref(GeneralUtility::getIndpEnv('REQUEST_URI')) @@ -201,10 +181,13 @@ class BackendService { $selectedExtension, $selectedTemplate, array $languages, $pid ): array { $selectedTemplates = []; - - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - /** @var TemplateRepository $templateRepository */ - $templateRepository = $objectManager->get(TemplateRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var TemplateRepository $templateRepository */ + $templateRepository = $objectManager->get(TemplateRepository::class); + } else { + $templateRepository = GeneralUtility::makeInstance(TemplateRepository::class); + } foreach ($languages as $language) { $selectedTemplates[$language['isocode']] = $templateRepository->findOneByTemplate( @@ -339,8 +322,13 @@ class BackendService { */ public static function saveTemplate($pid, $selectedExtension, $selectedTemplate, $language, $templateData ): Template { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $templateRepository = $objectManager->get(TemplateRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var TemplateRepository $templateRepository */ + $templateRepository = $objectManager->get(TemplateRepository::class); + } else { + $templateRepository = GeneralUtility::makeInstance(TemplateRepository::class); + } /** @var Template $template */ $template = $templateRepository->findOneByTemplate( @@ -348,10 +336,14 @@ class BackendService { ); $templateAlreadyExists = TRUE; - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); if ($template === NULL) { $templateAlreadyExists = FALSE; - $template = $objectManager->get(Template::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var Template $template */ + $template = $objectManager->get(Template::class); + } else { + $template = GeneralUtility::makeInstance(Template::class); + } } $template->setExtensionKey($selectedExtension); @@ -373,10 +365,7 @@ class BackendService { $templateRepository->add($template); } - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $persistenceManager = $objectManager->get(PersistenceManager::class); - $persistenceManager->persistAll(); - + $templateRepository->persist(); return $template; } @@ -389,8 +378,13 @@ class BackendService { * @throws \InvalidArgumentException */ public static function writeCsvFromQueue(array $filters = []) { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $mailRepository = $objectManager->get(MailRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var MailRepository $mailRepository */ + $mailRepository = $objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } $pageUid = (int) GeneralUtility::_GP('id'); $ignoreFields = ['uid', 'pid', 'tstamp', @@ -423,7 +417,7 @@ class BackendService { $row[] = '"' . ($label ?: $field) . '"'; } } - + fwrite( $handle, trim( preg_replace( @@ -434,7 +428,7 @@ class BackendService { ) ); } - + $row = []; foreach ($mail as $field => $value) { if (!\in_array($field, $ignoreFields, TRUE)) { @@ -445,7 +439,7 @@ class BackendService { } } } - + fwrite( $handle, trim( preg_replace( @@ -456,7 +450,7 @@ class BackendService { ) ); } - + $offset += self::CSV_EXPORT_BATCH_SIZE; } } @@ -475,7 +469,7 @@ class BackendService { $registerService = GeneralUtility::makeInstance(RegisterService::class); $registerArray = $registerService->getRegisterArray(); - $extensionConfiguration = ExtensionUtility::getExtensionConfiguration(); + $extensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_mail'] ?? []; if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') { $excludedTemplatesWithSiteId = GeneralUtility::trimExplode( ';', $extensionConfiguration['excludeTemplates'], TRUE @@ -485,7 +479,7 @@ class BackendService { $currentSiteBlacklist = GeneralUtility::trimExplode(',', $currentSite, TRUE); if ((int) $currentSiteBlacklist[0] === $siteRootId) { foreach ($currentSiteBlacklist as $excludedTemplate) { - list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate); + [$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate); if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) { unset($registerArray[$extensionKey][$templateName]); } @@ -502,7 +496,7 @@ class BackendService { ',', $extensionConfiguration['excludeTemplatesAllDomains'], TRUE ); foreach ($excludedTemplates as $excludedTemplate) { - list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate); + [$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate); if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) { unset($registerArray[$extensionKey][$templateName]); } diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index a08a3678179b316361e7cc1ca111a0829b4bac94..83676e37fb1f933936cd83e47a76eab3811be098 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -33,8 +33,6 @@ use SGalinski\SgMail\Domain\Model\Template; use SGalinski\SgMail\Domain\Repository\LayoutRepository; use SGalinski\SgMail\Domain\Repository\MailRepository; use SGalinski\SgMail\Domain\Repository\TemplateRepository; -use Swift_Attachment; -use Swift_OutputByteStream; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Resource\File; @@ -44,7 +42,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; @@ -81,16 +78,13 @@ class MailTemplateService { * @var \SGalinski\SgMail\Domain\Repository\LayoutRepository */ protected $layoutRepository; - /** - * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager - */ - protected $persistenceManager; /** * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @deprecated Not used since TYPO3 10 */ protected $objectManager; /** - * @var TYPO3\CMS\Core\Resource\ResourceFactory + * @var \TYPO3\CMS\Core\Resource\ResourceFactory */ protected $resourceFactory; /** @@ -116,7 +110,7 @@ class MailTemplateService { /** * @var boolean $ignoreMailQueue */ - private $ignoreMailQueue = FALSE; + private $ignoreMailQueue = TRUE; /** * @var \TYPO3\CMS\Core\Mail\MailMessage $mailMessage */ @@ -196,16 +190,24 @@ class MailTemplateService { $this->markers = $markers; $this->markerLabels = $markerLabels; - /** @var ObjectManager objectManager */ - $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $this->mailMessage = $this->objectManager->get(MailMessage::class); - $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); - $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); - $this->templateRepository = $this->objectManager->get(TemplateRepository::class); - $this->layoutRepository = $this->objectManager->get(LayoutRepository::class); - $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); - $this->resourceFactory = $this->objectManager->get(ResourceFactory::class); + $this->resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); + $this->mailMessage = GeneralUtility::makeInstance(MailMessage::class); + + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0')) { + $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var TypoScriptSettingsService $typoScriptSettingsService */ + $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + /** @var TemplateRepository templateRepository */ + $this->templateRepository = $this->objectManager->get(TemplateRepository::class); + /** @var LayoutRepository layoutRepository */ + $this->layoutRepository = $this->objectManager->get(LayoutRepository::class); + } else { + $typoScriptSettingsService = GeneralUtility::makeInstance(TypoScriptSettingsService::class); + $this->templateRepository = GeneralUtility::makeInstance(TemplateRepository::class); + $this->layoutRepository = GeneralUtility::makeInstance(LayoutRepository::class); + } + $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); // use defaultMailFromAddress if it is provided in LocalConfiguration.php; use the sg_mail TS setting as fallback if (\filter_var($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'], FILTER_VALIDATE_EMAIL)) { $this->fromAddress = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; @@ -364,24 +366,6 @@ class MailTemplateService { return $this; } - /** - * IMPORTANT: make sure to set $this->>ignoreMailQueue(TRUE), if you're using this method to add an attachment! - * Otherwise the attachment is ignored when sending the mail via mail queue. - * - * @param Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - * @return MailTemplateService - */ - public function addAttachment($data, $filename, $contentType): MailTemplateService { - $attachment = Swift_Attachment::newInstance() - ->setFilename($filename) - ->setContentType($contentType) - ->setBody($data); - $this->mailMessage->attach($attachment); - return $this; - } - /** * Adds a file resource as attachment * @@ -552,9 +536,15 @@ class MailTemplateService { //TODO: this can be avoided if the sending logic is decoupled from this function if ($isPreview) { - $mailRepository = $this->objectManager->get(MailRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var MailRepository $mailRepository */ + $mailRepository = $this->objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } + $mailRepository->remove($mail); - $this->persistenceManager->persistAll(); + $mailRepository->persist(); } return $success; @@ -586,9 +576,7 @@ class MailTemplateService { */ protected function getPageUid(): int { if (TYPO3_MODE === 'FE') { - /** @var TypoScriptFrontendController $typoscriptFrontendController */ - $typoscriptFrontendController = $GLOBALS['TSFE']; - $pageUid = (int) $typoscriptFrontendController->id; + $pageUid = (int) $GLOBALS['TSFE']->id; } else { $pageUid = (int) GeneralUtility::_GP('id'); } @@ -825,8 +813,13 @@ class MailTemplateService { $defaultTemplateContent = \file_get_contents($defaultTemplateFile); } else { // use configured default html template - /** @var TypoScriptSettingsService $typoScriptSettingsService */ - $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var TypoScriptSettingsService $typoScriptSettingsService */ + $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + } else { + $typoScriptSettingsService = GeneralUtility::makeInstance(TypoScriptSettingsService::class); + } + $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); $defaultTemplateFile = GeneralUtility::getFileAbsFileName( $tsSettings['mail']['defaultHtmlTemplate'] @@ -872,8 +865,13 @@ class MailTemplateService { $template, RegisterService $registerService, $defaultTemplateContent, $siteRootId ) { - /** @var StandaloneView $emailView */ - $emailView = $this->objectManager->get(StandaloneView::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var StandaloneView $emailView */ + $emailView = $this->objectManager->get(StandaloneView::class); + } else { + $emailView = GeneralUtility::makeInstance(StandaloneView::class); + } + $emailView->assignMultiple($this->markers); $emailView->assign('all_fields', $this->getAllMarker($this->markers)); @@ -1046,31 +1044,19 @@ class MailTemplateService { */ private function getAvailableLanguages(): array { $out = [0 => '']; - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( - 'sys_language' - ); - $rows = $queryBuilder->select('*') - ->from('sys_language')->execute()->fetchAll(); - - foreach ($rows as $row) { - $out[(int) $row['uid']] = $row['language_isocode']; - } - } else { - try { - $site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId(0); - } catch (\Exception $exception) { - return [0 => '']; - } - $availableLanguages = $site->getLanguages(); - $out = []; - foreach ($availableLanguages as $language) { - $languageId = $language->getLanguageId(); - if ($languageId < 0) { - continue; - } - $out[$language->getLanguageId()] = strtolower($language->getTwoLetterIsoCode()); + try { + $site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId(0); + } catch (\Exception $exception) { + return [0 => '']; + } + $availableLanguages = $site->getLanguages(); + $out = []; + foreach ($availableLanguages as $language) { + $languageId = $language->getLanguageId(); + if ($languageId < 0) { + continue; } + $out[$language->getLanguageId()] = strtolower($language->getTwoLetterIsoCode()); } return $out; } @@ -1097,7 +1083,7 @@ class MailTemplateService { $extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $lastSendingTime = 0, $language = self::DEFAULT_LANGUAGE, $pid = 0 ): Mail { - $mail = $this->objectManager->get(Mail::class); + $mail = new Mail(); $mail->setPid($pid); $mail->setExtensionKey($extensionKey); $mail->setTemplateName($templateName); @@ -1129,16 +1115,22 @@ class MailTemplateService { 'uid' => uniqid('NEW_MAIL', TRUE) ] ); - $newFileReference = GeneralUtility::makeInstance(FileReference::class); + $newFileReference = new FileReference(); $newFileReference->setOriginalResource($coreFileReferenceMailFile); $mail->addAttachment($newFileReference); } } } - $mailRepository = $this->objectManager->get(MailRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var MailRepository $mailRepository */ + $mailRepository = $this->objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } + $mailRepository->add($mail); - $this->persistenceManager->persistAll(); + $mailRepository->persist(); return $mail; } @@ -1180,7 +1172,13 @@ class MailTemplateService { * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException */ public function sendMailFromQueue($uid): bool { - $mailRepository = $this->objectManager->get(MailRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var MailRepository $mailRepository */ + $mailRepository = $this->objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } + /** @var Mail $mailToSend */ if (!isset(self::$mailObjectCache[$uid]) || !self::$mailObjectCache[$uid] instanceof Mail) { $mailToSend = $this->getMailObjectByUid($uid); @@ -1191,19 +1189,25 @@ class MailTemplateService { $mailToSend = self::$mailObjectCache[$uid]; } - $this->mailMessage->setBody($mailToSend->getMailBody(), 'text/html'); $plaintextService = GeneralUtility::makeInstance(PlaintextService::class); $plaintextBody = $plaintextService->makePlain($mailToSend->getMailBody()); - $this->mailMessage->addPart($plaintextBody, 'text/plain'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $this->mailMessage->setBody($mailToSend->getMailBody(), 'text/html'); + $this->mailMessage->addPart($plaintextBody, 'text/plain'); + } else { + $this->mailMessage->html($mailToSend->getMailBody()); + $this->mailMessage->text($plaintextBody); + } + $toAddresses = \trim($mailToSend->getToAddress()); $addressesArray = GeneralUtility::trimExplode(',', $toAddresses, TRUE); if (\count($addressesArray) > 1) { $toAddresses = $addressesArray; } + $this->mailMessage->setTo($toAddresses); $this->mailMessage->setFrom($mailToSend->getFromAddress(), $mailToSend->getFromName()); $this->mailMessage->setSubject($mailToSend->getMailSubject()); - if ($mailToSend->getBccAddresses()) { $this->mailMessage->setBcc(GeneralUtility::trimExplode(',', $mailToSend->getBccAddresses())); } @@ -1215,6 +1219,7 @@ class MailTemplateService { if ($mailToSend->getReplyTo()) { $this->mailMessage->setReplyTo($mailToSend->getReplyTo()); } + $attachments = $mailToSend->getAttachments(); if ($attachments->count() > 0) { foreach ($attachments as $attachment) { @@ -1222,23 +1227,32 @@ class MailTemplateService { * @var FileReference $attachment */ $file = $attachment->getOriginalResource()->getOriginalFile(); - $this->mailMessage->attach( - \Swift_Attachment::newInstance($file->getContents(), $file->getName(), $file->getMimeType()) - ); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $this->mailMessage->attach( + \Swift_Attachment::newInstance($file->getContents(), $file->getName(), $file->getMimeType()) + ); + } else { + $this->mailMessage->attach( + $file->getContents(), $file->getName(), $file->getMimeType() + ); + } } } + $dateTime = new DateTime(); if ((int) $mailToSend->getSendingTime() === 0) { $mailToSend->setSendingTime($dateTime->getTimestamp()); } + $mailToSend->setLastSendingTime($dateTime->getTimestamp()); $success = $this->mailMessage->send(); if ($success) { $mailRepository->update($mailToSend); - $this->persistenceManager->persistAll(); + $mailRepository->persist(); } else { $this->mailMessage->getFailedRecipients(); } + unset(self::$mailObjectCache[$uid]); // free the memory return $success; } @@ -1250,7 +1264,13 @@ class MailTemplateService { * @return bool|object */ private function getMailObjectByUid($uid) { - $mailRepository = $this->objectManager->get(MailRepository::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var MailRepository $mailRepository */ + $mailRepository = $this->objectManager->get(MailRepository::class); + } else { + $mailRepository = GeneralUtility::makeInstance(MailRepository::class); + } + $mailObject = $mailRepository->findOneByUid($uid); if (!$mailObject || $mailObject->getBlacklisted()) { return FALSE; diff --git a/Classes/Service/RegisterService.php b/Classes/Service/RegisterService.php index 8f32de8c5c442c64d3800861ec0a75082bc13f7d..f1bd7b307568c76e8260c9bb969dd9cbc5e959be 100644 --- a/Classes/Service/RegisterService.php +++ b/Classes/Service/RegisterService.php @@ -33,6 +33,7 @@ use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; /** @@ -216,8 +217,13 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface { * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException */ public function clearCaches() { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $cacheManager = $objectManager->get(CacheManager::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var CacheManager $cacheManager */ + $cacheManager = $objectManager->get(CacheManager::class); + } else { + $cacheManager = GeneralUtility::makeInstance(CacheManager::class); + } /** @var FrontendInterface $cache */ $cache = $cacheManager->getCache(self::CACHE_NAME); diff --git a/Classes/Service/TypoScriptSettingsService.php b/Classes/Service/TypoScriptSettingsService.php index 96a179ea760920a12754542b3bfd43402d199274..2c9c2614891b499e45ec970d2f3ee83e9cfc303c 100644 --- a/Classes/Service/TypoScriptSettingsService.php +++ b/Classes/Service/TypoScriptSettingsService.php @@ -29,6 +29,7 @@ namespace SGalinski\SgMail\Service; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -37,23 +38,11 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; * */ class TypoScriptSettingsService implements SingletonInterface { - /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface - */ - protected $objectManager; - /** * @var array */ protected static $typoScriptCache = []; - /** - * Initializes the class - */ - public function __construct() { - $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); - } - /** * Returns the typoscript settings of a given page and extension * @@ -67,9 +56,17 @@ class TypoScriptSettingsService implements SingletonInterface { if (!isset(self::$typoScriptCache[$cacheHash])) { $tmpId = $_POST['id']; $_POST['id'] = $pageId; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var TypoScriptService $typoScriptService */ + $typoScriptService = $objectManager->get(TypoScriptService::class); + /** @var BackendConfigurationManager $configurationManager */ + $configurationManager = $objectManager->get(BackendConfigurationManager::class); + } else { + $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); + $configurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class); + } - $typoScriptService = $this->objectManager->get(TypoScriptService::class); - $configurationManager = $this->objectManager->get(BackendConfigurationManager::class); self::$typoScriptCache[$cacheHash] = $typoScriptService->convertTypoScriptArrayToPlainArray( (array) $configurationManager->getTypoScriptSetup()['module.'][$extensionKey . '.']['settings.'] ); diff --git a/Classes/Updates/MigrateData.php b/Classes/Updates/MigrateData.php deleted file mode 100644 index a1bb8feb070b73f114da1f857a1e9d22b4f8c01a..0000000000000000000000000000000000000000 --- a/Classes/Updates/MigrateData.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php - -namespace SGalinski\SgMail\Updates; - -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use SGalinski\SgMail\Service\BackendService; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Updates\AbstractUpdate; - -/** - * Migrate template db entries to the correct root pages - */ -class MigrateData extends AbstractUpdate { - - protected $identifier = ''; - /** - * @var string - */ - protected $title = 'Find all templates & queue entries without site root and assign the correct site root id'; - - /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager - */ - protected $objectManager; - - /** - * @var array - */ - protected $tables = [ - 'tx_sgmail_domain_model_mail', 'tx_sgmail_domain_model_template' - ]; - - /** - * Checks whether updates are required. - * - * @param string &$description The description for the update - * @return bool Whether an update is required (TRUE) or not (FALSE) - */ - public function checkForUpdate(&$description) { - $description = 'Set the site_root_id for all the queue entries and templates if not set or pid = 0'; - $oldRowsFound = FALSE; - - foreach ($this->tables as $table) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); - $queryBuilder->getRestrictions()->removeAll(); - $rowCount = $queryBuilder->select('*') - ->from($table) - ->where( - $queryBuilder->expr()->eq('site_root_id', 0) - )->execute()->rowCount(); - if ($rowCount > 0) { - $oldRowsFound = TRUE; - break; - } - } - - return !(!$oldRowsFound || $this->isWizardDone()); - } - - /** - * Performs the accordant updates. - * - * @param array &$dbQueries Queries done in this update - * @param mixed &$customMessages Custom messages - * @return bool Whether everything went smoothly or not - */ - public function performUpdate(array &$dbQueries, &$customMessages) { - foreach ($this->tables as $table) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); - $queryBuilder->getRestrictions()->removeAll(); - $rows = $queryBuilder->select('uid', 'pid') - ->from($table) - ->where( - $queryBuilder->expr()->eq('site_root_id', 0) - )->execute()->fetchAll(); - $dbQueries[] = $queryBuilder->getSQL(); - - /** @var array $result */ - foreach ($rows as $row) { - $siteRootId = BackendService::getSiteRoot($row[1]); - if ($siteRootId === NULL) { - $this->retrieveFirstSiteRoot(); - } - $queryBuilder->update($table) - ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($row[0])) - ) - ->set('site_root_id', (int) $siteRootId); - $dbQueries[] = $queryBuilder->getSQL(); - } - } - - $this->markWizardAsDone(); - return TRUE; - } - - /** - * Get the first site root that is not pid = 0 - * - * @return int - */ - private function retrieveFirstSiteRoot() { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); - $queryBuilder->getRestrictions()->removeAll(); - $pagesResult = $queryBuilder->select('uid') - ->from('pages') - ->where( - $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('is_siteroot', 1), - $queryBuilder->expr()->neq('uid', 0) - ) - ) - ->setMaxResults(1) - ->execute()->fetch(); - $dbQueries[] = $queryBuilder->getSQL(); - - if (empty($pagesResult)) { - return 0; - } - - return $pagesResult[0][0]; - } -} diff --git a/Classes/Updates/MigrateSchedulerTasks.php b/Classes/Updates/MigrateSchedulerTasks.php new file mode 100644 index 0000000000000000000000000000000000000000..3c1421281feef13b53aceef5ed4b5829795c28ef --- /dev/null +++ b/Classes/Updates/MigrateSchedulerTasks.php @@ -0,0 +1,170 @@ +<?php +/*************************************************************** + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +namespace SGalinski\SgMail\Updates; + +use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; +use TYPO3\CMS\Scheduler\Scheduler; +use TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask; + +/** + * Class MigrateSchedulerTasks + * + * @package SGalinski\SgMail\Updates + */ +class MigrateSchedulerTasks implements UpgradeWizardInterface { + /** + * Identifier of the upgrade + */ + const IDENTIFIER = 'tx_sgmail_migrateschedulertasks'; + + /** + * @inheritDoc + */ + public function getIdentifier(): string { + return self::IDENTIFIER; + } + + /** + * @inheritDoc + */ + public function getTitle(): string { + return 'Migrate sg_mail scheduler tasks to symfony commands API'; + } + + /** + * @inheritDoc + */ + public function getDescription(): string { + return 'This upgrade migrates all sg_mail scheduler tasks, created with the old CommandController API to the new Symfony Commands API'; + } + + /** + * @inheritDoc + */ + public function executeUpdate(): bool { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( + 'tx_scheduler_task' + ); + $tasks = $queryBuilder->select('serialized_task_object') + ->from('tx_scheduler_task') + ->where( + $queryBuilder->expr()->eq('disable', 0) + )->execute()->fetchAll(); + foreach ($tasks as $_task) { + $task = unserialize($_task['serialized_task_object'], [\__PHP_Incomplete_Class::class]); + $taskVars = $this->cleanArrayKeys((array)$task); + $identifier = $taskVars['*commandIdentifier']; + if ( + $identifier === 'sg_mail:sendmail:runsendmails' + ) { + $this->replaceTask($taskVars); + } + } + return TRUE; + } + + /** + * Replace the given extbase task implementation with the new Symfony Commands API one + * + * @param array $task + */ + protected function replaceTask(array $task) { + $commandTask = GeneralUtility::makeInstance(ExecuteSchedulableCommandTask::class); + switch ($task['*commandIdentifier']) { + case 'sg_mail:sendmail:runsendmails': + $commandTask->setCommandIdentifier('sg_mail:sendMail'); + break; + } + + if (is_array($task['*arguments'])) { + $commandTask->setArguments($task['*arguments']); + } + + if (is_array($task['*defaults'])) { + foreach ($task['*defaults'] as $key => $default) { + $commandTask->addDefaultValue($key, $default); + } + } + + $commandTask->setTaskGroup($task['*taskGroup']); + $commandTask->setExecution($task['*execution']); + $commandTask->setExecutionTime($task['*executionTime']); + $commandTask->setRunOnNextCronJob($task['*runOnNextCronJob']); + $commandTask->setTaskUid($task['*taskUid']); + GeneralUtility::makeInstance(Scheduler::class)->saveTask($commandTask); + } + + /** + * @inheritDoc + */ + public function updateNecessary(): bool { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( + 'tx_scheduler_task' + ); + $tasks = $queryBuilder->select('serialized_task_object') + ->from('tx_scheduler_task') + ->where( + $queryBuilder->expr()->eq('disable', 0) + )->execute()->fetchAll(); + foreach ($tasks as $_task) { + $task = unserialize($_task['serialized_task_object'], [\__PHP_Incomplete_Class::class]); + $taskVars = $this->cleanArrayKeys((array)$task); + $identifier = $taskVars['*commandIdentifier']; + if ( + $identifier === 'sg_mail:sendmail:runsendmails' + ) { + return TRUE; + } + } + return FALSE; + } + + /** + * Cleans array keys from their hidden \0 + * + * @param array $array + * @return array + */ + protected function cleanArrayKeys(array $array) { + $newArray = []; + foreach($array as $key => $value) { + $newArray[str_replace("\0", '', $key)] = $value; + } + return $newArray; + } + + /** + * @inheritDoc + */ + public function getPrerequisites(): array { + return [ + DatabaseUpdatedPrerequisite::class + ]; + } +} diff --git a/Classes/Updates/UpdateGermanAsDefault.php b/Classes/Updates/UpdateGermanAsDefault.php index 1593200e27545c819f6d967af3c57d2cbd3cd20e..8b843a0624f52d6adbcb65fd509015b7e5d48e45 100644 --- a/Classes/Updates/UpdateGermanAsDefault.php +++ b/Classes/Updates/UpdateGermanAsDefault.php @@ -28,66 +28,48 @@ namespace SGalinski\SgMail\Updates; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Updates\AbstractUpdate; +use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Makes german templates the default and former default as english templates */ -class UpdateGermanAsDefault extends AbstractUpdate { - +class UpdateGermanAsDefault implements UpgradeWizardInterface { /** - * @var string + * The wizard identifier */ - protected $identifier = 'tx_sgmail_update_german_as_default'; + const IDENTIFIER = 'tx_sgmail_update_german_as_default'; /** * @var string */ - protected $title = 'Makes german templates the default and former default as english templates. WARNING: ONLY EXECUTE THIS IF IT MAKES SENSE FOR YOUR TYPO3 INSTANCE'; + protected $table = 'tx_sgmail_domain_model_template'; /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @return string */ - protected $objectManager; + public function getIdentifier(): string { + return self::IDENTIFIER; + } /** - * @var string + * @return string */ - protected $table = 'tx_sgmail_domain_model_template'; + public function getTitle(): string { + return 'Makes german templates the default and former default as english templates. WARNING: ONLY EXECUTE THIS IF IT MAKES SENSE FOR YOUR TYPO3 INSTANCE'; + } /** - * Checks whether updates are required. - * - * @param string &$description The description for the update - * @return bool Whether an update is required (TRUE) or not (FALSE) + * @return string */ - public function checkForUpdate(&$description) { - $description = 'Update if there are german templates'; - - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); - $queryBuilder->getRestrictions()->removeAll(); - $rowCount = $queryBuilder->select('*') - ->from($this->table) - ->where( - $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter('de')) - ) - ->execute()->rowCount(); - if ($rowCount > 0) { - return TRUE; - } - - return !(!FALSE || $this->isWizardDone()); + public function getDescription(): string { + return ''; } /** - * Performs the according updates. - * - * @param array &$dbQueries Queries done in this update - * @param mixed &$customMessages Custom messages - * @return bool Whether everything went smoothly or not + * @return bool */ - public function performUpdate(array &$dbQueries, &$customMessages) { - $dbQueries = []; + public function executeUpdate(): bool { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); $queryBuilder->getRestrictions()->removeAll(); $resultGerman = $queryBuilder->select('uid') @@ -96,7 +78,6 @@ class UpdateGermanAsDefault extends AbstractUpdate { $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter('de')) ) ->execute()->fetchAll(); - $dbQueries[] = $queryBuilder->getSQL(); $resultDefault = $queryBuilder->select('uid') ->from($this->table) @@ -104,7 +85,6 @@ class UpdateGermanAsDefault extends AbstractUpdate { $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter('default')) ) ->execute()->fetchAll(); - $dbQueries[] = $queryBuilder->getSQL(); /** @var array $resultGerman */ foreach ($resultGerman as $row) { @@ -114,7 +94,6 @@ class UpdateGermanAsDefault extends AbstractUpdate { ) ->set('language', 'default', TRUE) ->execute(); - $dbQueries[] = $queryBuilder->getSQL(); } /** @var array $resultGerman */ @@ -125,10 +104,32 @@ class UpdateGermanAsDefault extends AbstractUpdate { ) ->set('language', 'en', TRUE) ->execute(); - $dbQueries[] = $queryBuilder->getSQL(); } - $this->markWizardAsDone(); return TRUE; } + + /** + * @return bool + */ + public function updateNecessary(): bool { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); + $queryBuilder->getRestrictions()->removeAll(); + $rowCount = $queryBuilder->select('*') + ->from($this->table) + ->where( + $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter('de')) + ) + ->execute()->rowCount(); + return $rowCount > 0; + } + + /** + * @return array|string[] + */ + public function getPrerequisites(): array { + return [ + DatabaseUpdatedPrerequisite::class + ]; + } } diff --git a/Classes/Updates/UpdateLanguages.php b/Classes/Updates/UpdateLanguages.php index 0e9a5416eca54136b5926a7221da01206337e317..28b048698bbbc91830c439f730fa4b493feb9b8d 100644 --- a/Classes/Updates/UpdateLanguages.php +++ b/Classes/Updates/UpdateLanguages.php @@ -30,27 +30,17 @@ use SGalinski\SgMail\Service\BackendService; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Updates\AbstractUpdate; +use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Fix all incorrect / deprecated language codes (be languages instead of sys languages) in the database */ -class UpdateLanguages extends AbstractUpdate { - - /** - * @var string - */ - protected $identifier = 'tx_sgmail_update_languages'; - - /** - * @var string - */ - protected $title = 'Find all templates & queue entries with an incorrect (be languages instead of sys languages) language code and fix it'; - +class UpdateLanguages implements UpgradeWizardInterface { /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * The wizard identifier */ - protected $objectManager; + const IDENTIFIER = 'tx_sgmail_update_languages'; /** * @var array @@ -73,19 +63,54 @@ class UpdateLanguages extends AbstractUpdate { ]; /** - * Checks whether updates are required. - * - * @param string &$description The description for the update - * @return bool Whether an update is required (TRUE) or not (FALSE) - * @throws \InvalidArgumentException + * @return string + */ + public function getIdentifier(): string { + return self::IDENTIFIER; + } + + /** + * @return string + */ + public function getTitle(): string { + return 'Find all templates & queue entries with an incorrect (be languages instead of sys languages) language code and fix it'; + } + + /** + * @return string */ - public function checkForUpdate(&$description) { + public function getDescription(): string { + return ''; + } + + /** + * @return bool + */ + public function executeUpdate(): bool { + foreach ($this->tables as $table) { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); + $queryBuilder->getRestrictions()->removeAll(); + foreach ($this->languageMap as $origin => $target) { + $queryBuilder->update($table) + ->where( + $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter($origin)) + ) + ->set('language', $target, TRUE) + ->execute(); + } + } + + return TRUE; + } + + /** + * @return bool + */ + public function updateNecessary(): bool { $upgradeNecessary = FALSE; if (count($this->languageMap) > 0) { - $languages = BackendService::getLanguages();; - - $description = 'Check all the language codes in the database'; + $languages = BackendService::getLanguages(); foreach ($this->tables as $table) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); @@ -109,34 +134,15 @@ class UpdateLanguages extends AbstractUpdate { } } - return !(!$upgradeNecessary || $this->isWizardDone()); + return $upgradeNecessary; } /** - * Performs the accordant updates. - * - * @param array &$dbQueries Queries done in this update - * @param mixed &$customMessages Custom messages - * @return bool Whether everything went smoothly or not + * @return array|string[] */ - public function performUpdate(array &$dbQueries, &$customMessages) { - $dbQueries = []; - - foreach ($this->tables as $table) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); - $queryBuilder->getRestrictions()->removeAll(); - foreach ($this->languageMap as $origin => $target) { - $queryBuilder->update($table) - ->where( - $queryBuilder->expr()->eq('language', $queryBuilder->createNamedParameter($origin)) - ) - ->set('language', $target, TRUE) - ->execute(); - $dbQueries[] = $queryBuilder->getSQL(); - } - } - - $this->markWizardAsDone(); - return TRUE; + public function getPrerequisites(): array { + return [ + DatabaseUpdatedPrerequisite::class + ]; } } diff --git a/Classes/Updates/UpdatePidToSiteRoot.php b/Classes/Updates/UpdatePidToSiteRoot.php index d4087c58f465a6e8a4e28ab11130e522573aceaf..1c65b07215e3d10f36a55996fba5fce82703de5b 100644 --- a/Classes/Updates/UpdatePidToSiteRoot.php +++ b/Classes/Updates/UpdatePidToSiteRoot.php @@ -30,27 +30,17 @@ use SGalinski\SgMail\Service\BackendService; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Updates\AbstractUpdate; +use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Migrate template db entries to the correct root pages */ -class UpdatePidToSiteRoot extends AbstractUpdate { - - /** - * @var string - */ - protected $identifier = 'tx_sgmail_update_pid_to_site_root'; - - /** - * @var string - */ - protected $title = 'Find all templates & queue entries with site root and assign the correct site root id as pid. Also check if the pids are actually site roots and update them accordingly'; - +class UpdatePidToSiteRoot implements UpgradeWizardInterface { /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * The wizard identifier */ - protected $objectManager; + const IDENTIFIER = 'tx_sgmail_update_pid_to_site_root'; /** * @var array @@ -60,61 +50,48 @@ class UpdatePidToSiteRoot extends AbstractUpdate { ]; /** - * Checks whether updates are required. + * check if site_root columns actually exist * - * @param string &$description The description for the update - * @return bool Whether an update is required (TRUE) or not (FALSE) + * @param string $table + * @return bool */ - public function checkForUpdate(&$description) { - $description = 'Move site root ids to pid & update pids to their correspondent site root ids'; + private function siteRootColumnExists($table) { + $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); + $result = $connection->getSchemaManager()->listTableColumns($table); + return \array_key_exists('site_root_id', $result); + } - // are there site root columns differing from pids? - foreach ($this->tables as $table) { - if (!$this->siteRootColumnExists($table)) { - continue; - } - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); - $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); - $rowCount = $queryBuilder->select('*') - ->from($table) - ->where($queryBuilder->expr()->neq('site_root_id', 'pid')) - ->execute()->rowCount(); - if ($rowCount > 0) { - return TRUE; - } - } + /** + * @return string + */ + public function getIdentifier(): string { + return self::IDENTIFIER; + } - // are the pids not belonging to site root pages ? - foreach ($this->tables as $table) { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); - $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); - $result = $queryBuilder->select('pid')->from($table)->groupBy('pid')->execute(); - foreach ($result as $row) { - $siteRootId = BackendService::getSiteRoot($row['pid']); - if ($siteRootId !== $row['pid']) { - return TRUE; - } - } - } + /** + * @return string + */ + public function getTitle(): string { + return 'Find all templates & queue entries with site root and assign the correct site root id as pid. Also check if the pids are actually site roots and update them accordingly'; + } - return !(!FALSE || $this->isWizardDone()); + /** + * @return string + */ + public function getDescription(): string { + return 'Move site root ids to pid & update pids to their correspondent site root ids'; } /** - * Performs the according updates. - * - * @param array &$dbQueries Queries done in this update - * @param mixed &$customMessages Custom messages - * @return bool Whether everything went smoothly or not + * @return bool * @throws \Doctrine\DBAL\DBALException */ - public function performUpdate(array &$dbQueries, &$customMessages) { + public function executeUpdate(): bool { foreach ($this->tables as $table) { if ($this->siteRootColumnExists($table)) { $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); $sql = 'UPDATE ' . $table . ' SET pid = site_root_id'; $connection->executeQuery($sql); - $dbQueries[] = $sql; } else { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); $queryBuilder->getRestrictions()->removeAll()->add( @@ -129,24 +106,55 @@ class UpdatePidToSiteRoot extends AbstractUpdate { $siteRootId = 1; } $queryBuilder->update($table)->set('pid', $siteRootId)->where('pid = ' . $row['pid'])->execute(); - $dbQueries[] = $queryBuilder->getSQL(); } } } - $this->markWizardAsDone(); return TRUE; } /** - * check if site_root columns actually exist - * - * @param string $table * @return bool */ - private function siteRootColumnExists($table) { - $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); - $result = $connection->getSchemaManager()->listTableColumns($table); - return \array_key_exists('site_root_id', $result); + public function updateNecessary(): bool { + // are there site root columns differing from pids? + foreach ($this->tables as $table) { + if (!$this->siteRootColumnExists($table)) { + continue; + } + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + $rowCount = $queryBuilder->select('*') + ->from($table) + ->where($queryBuilder->expr()->neq('site_root_id', 'pid')) + ->execute()->rowCount(); + if ($rowCount > 0) { + return TRUE; + } + } + + // are the pids not belonging to site root pages ? + foreach ($this->tables as $table) { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + $result = $queryBuilder->select('pid')->from($table)->groupBy('pid')->execute(); + foreach ($result as $row) { + $siteRootId = BackendService::getSiteRoot($row['pid']); + if ($siteRootId !== $row['pid']) { + return TRUE; + } + } + } + + return FALSE; + } + + /** + * @return array|string[] + */ + public function getPrerequisites(): array { + return [ + DatabaseUpdatedPrerequisite::class + ]; } } diff --git a/Classes/Updates/UpdateSendingTimes.php b/Classes/Updates/UpdateSendingTimes.php index dd620a76cf5a09e91d8f5d3a903dc6d5e50fcd4c..2b7e7ab824b46521d95dd1e75006e8448e03a970 100644 --- a/Classes/Updates/UpdateSendingTimes.php +++ b/Classes/Updates/UpdateSendingTimes.php @@ -28,68 +28,48 @@ namespace SGalinski\SgMail\Updates; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Updates\AbstractUpdate; +use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; +use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Update the correct sending times (if any) */ -class UpdateSendingTimes extends AbstractUpdate { +class UpdateSendingTimes implements UpgradeWizardInterface { /** - * @var string + * The wizard identifier */ - protected $identifier = 'tx_sgmail_update_sending_times'; + const IDENTIFIER = 'tx_sgmail_update_sending_times'; /** * @var string */ - protected $title = 'Find all sent mails and set the sending time to the tstamp field'; + protected $table = 'tx_sgmail_domain_model_mail'; /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @return string */ - protected $objectManager; + public function getIdentifier(): string { + return 'tx_sgmail_update_sending_times'; + } /** - * @var string + * @return string */ - protected $table = 'tx_sgmail_domain_model_mail'; + public function getTitle(): string { + return 'Find all sent mails and set the sending time to the tstamp field'; + } /** - * Checks whether updates are required. - * - * @param string &$description The description for the update - * @return bool Whether an update is required (TRUE) or not (FALSE) + * @return string */ - public function checkForUpdate(&$description) { - $description = 'Update the sending times if mails have been sent'; - - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); - $queryBuilder->getRestrictions()->removeAll(); - $rowCount = $queryBuilder->select('*') - ->from($this->table) - ->where( - $queryBuilder->expr()->andX( - $queryBuilder->expr()->gt('sending_time', 0), - $queryBuilder->expr()->eq('last_sending_time', 0) - ) - ) - ->execute()->rowCount(); - if ($rowCount > 0) { - return TRUE; - } - - return !(!FALSE || $this->isWizardDone()); + public function getDescription(): string { + return 'Update the sending times if mails have been sent'; } /** - * Performs the according updates. - * - * @param array &$dbQueries Queries done in this update - * @param mixed &$customMessages Custom messages - * @return bool Whether everything went smoothly or not + * @return bool */ - public function performUpdate(array &$dbQueries, &$customMessages) { - $dbQueries = []; + public function executeUpdate(): bool { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); $queryBuilder->getRestrictions()->removeAll(); $result = $queryBuilder->select('uid', 'sending_time') @@ -101,7 +81,6 @@ class UpdateSendingTimes extends AbstractUpdate { ) ) ->execute()->fetchAll(); - $dbQueries[] = $queryBuilder->getSQL(); /** @var array $result */ foreach ($result as $row) { @@ -111,10 +90,35 @@ class UpdateSendingTimes extends AbstractUpdate { ) ->set('last_sending_time', (int) $row['sending_time']) ->execute(); - $dbQueries[] = $queryBuilder->getSQL(); } - $this->markWizardAsDone(); return TRUE; } + + /** + * @return bool + */ + public function updateNecessary(): bool { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table); + $queryBuilder->getRestrictions()->removeAll(); + $rowCount = $queryBuilder->select('*') + ->from($this->table) + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->gt('sending_time', 0), + $queryBuilder->expr()->eq('last_sending_time', 0) + ) + ) + ->execute()->rowCount(); + return $rowCount > 0; + } + + /** + * @return array|string[] + */ + public function getPrerequisites(): array { + return [ + DatabaseUpdatedPrerequisite::class + ]; + } } diff --git a/Classes/UserFunc/ExtensionConfiguration.php b/Classes/UserFunc/ExtensionConfiguration.php deleted file mode 100644 index ee7ef0bae7b962e926f937c1d5f5a142ffff7a60..0000000000000000000000000000000000000000 --- a/Classes/UserFunc/ExtensionConfiguration.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php - -namespace SGalinski\SgMail\UserFunc; - -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use SGalinski\SgMail\Service\RegisterService; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -/** - * Class ExtensionConfiguration - * - * @package SGalinski\SgMail\UserFunc - */ -class ExtensionConfiguration { - - /** - * Displays all registered sg mail templates for easy use with the blacklist feature - * - * @return string - */ - public function displayTemplates(): string { - $result = ''; - - try { - // These are internal methods that can vanish at any moment - // TODO: We need to change this whole TypoScript fetching at these early stages - ExtensionManagementUtility::loadExtLocalconf(); - ExtensionManagementUtility::loadBaseTca(); - $registerService = GeneralUtility::makeInstance(RegisterService::class); - $registerArray = $registerService->getRegisterArray(); - foreach ($registerArray as $extensionKey => $extension) { - /** @var array $extension */ - foreach ($extension as $templateKey => $template) { - $result .= $extensionKey . '.' . $templateKey . '<br>'; - } - } - - } catch (\Exception $exception) { - return 'The template list could not be loaded!'; - } - - return $result; - } -} diff --git a/Classes/Utility/ExtensionUtility.php b/Classes/Utility/ExtensionUtility.php deleted file mode 100644 index 969dc8e5edb09cd93b6e30dd00522f6e7c4cedcb..0000000000000000000000000000000000000000 --- a/Classes/Utility/ExtensionUtility.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace SGalinski\SgMail\Utility; - -/** - * - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - */ - -use TYPO3\CMS\Core\Utility\VersionNumberUtility; - -/** - * Class ExtensionUtility - * - * @package SGalinski\SgMail\Utility - * @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de> - */ -class ExtensionUtility { - /** - * Get the extension configuration - * - * @return array - */ - public static function getExtensionConfiguration(): array { - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $extConf = \unserialize( - $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail'], ['allowed_classes' => FALSE] - ); - return is_array($extConf) ? $extConf : []; - } - - return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_mail'] ?? []; - } -} diff --git a/Classes/ViewHelpers/Widget/UriViewHelper.php b/Classes/ViewHelpers/Widget/UriViewHelper.php index 3e3e6ecfec93c7fbeece9bfe45af6a3b834f7e04..b1ce42bfe10ec6d611c6e76f6e28e7bfebcfecfb 100644 --- a/Classes/ViewHelpers/Widget/UriViewHelper.php +++ b/Classes/ViewHelpers/Widget/UriViewHelper.php @@ -27,6 +27,7 @@ namespace SGalinski\SgMail\ViewHelpers\Widget; ***************************************************************/ use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -52,9 +53,6 @@ class UriViewHelper extends AbstractViewHelper { * Initialize arguments */ public function initializeArguments() { - $this->registerArgument( - 'useCacheHash', 'bool', 'True whether the cache hash should be appended to the URL', FALSE, FALSE - ); $this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string'); $this->registerArgument('action', 'string', 'Target action'); $this->registerArgument('arguments', 'array', 'Arguments', FALSE, []); @@ -89,6 +87,7 @@ class UriViewHelper extends AbstractViewHelper { * @return string the AJAX URI */ protected static function getAjaxUri(RenderingContextInterface $renderingContext, array $arguments) { + /** @var ControllerContext $controllerContext */ $controllerContext = $renderingContext->getControllerContext(); $action = $arguments['action']; $arguments = $arguments['arguments']; @@ -111,6 +110,7 @@ class UriViewHelper extends AbstractViewHelper { * @return string the Widget URI */ protected static function getWidgetUri(RenderingContextInterface $renderingContext, array $arguments) { + /** @var ControllerContext $controllerContext */ $controllerContext = $renderingContext->getControllerContext(); $uriBuilder = $controllerContext->getUriBuilder(); $argumentPrefix = $controllerContext->getRequest()->getArgumentPrefix(); diff --git a/Classes/XClass/Form/FormEditorController.php b/Classes/XClass/Form/FormEditorController.php index e286baf6d35fc99384865593f6677d724e681c3c..cfe5abfe4f0a19f90a640bd25176ed5aabd4b273 100644 --- a/Classes/XClass/Form/FormEditorController.php +++ b/Classes/XClass/Form/FormEditorController.php @@ -28,9 +28,11 @@ namespace SGalinski\SgMail\XClass\Form; use SGalinski\SgMail\Service\MailTemplateService; use SGalinski\SgMail\Service\RegisterService; use Symfony\Component\Yaml\Yaml; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Resource\ResourceStorage; use TYPO3\CMS\Core\Resource\StorageRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Form\Type\FormDefinitionArray; /** @noinspection LongInheritanceChainInspection */ @@ -67,7 +69,12 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll * @internal */ public function saveFormAction(string $formPersistenceIdentifier, FormDefinitionArray $formDefinition) { - $registrationService = $this->objectManager->get(RegisterService::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registrationService */ + $registrationService = $this->objectManager->get(RegisterService::class); + } else { + $registrationService = GeneralUtility::makeInstance(RegisterService::class); + } // immediately exit when no finisher is defined (that means no sgmail integration anyway) // call the parent saveFormAction here, otherwise it wouldn't be called at all in this case @@ -106,15 +113,21 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll if (strpos($formPersistenceIdentifier, 'EXT:') === 0) { $absoluteFilePath = GeneralUtility::getFileAbsFileName($formPersistenceIdentifier); } else { - list($storageUid, $fileIdentifier) = explode(':', $formPersistenceIdentifier, 2); - $storageRepository = $this->objectManager->get(StorageRepository::class); + [$storageUid, $fileIdentifier] = explode(':', $formPersistenceIdentifier, 2); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var StorageRepository $storageRepository */ + $storageRepository = $this->objectManager->get(StorageRepository::class); + } else { + $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); + } + $storage = $storageRepository->findByUid($storageUid); if (!$storage instanceof ResourceStorage || !$storage->isBrowsable()) { throw new \InvalidArgumentException( sprintf('Could not access storage with uid "%d".', $storageUid) ); } - $absoluteFilePath = PATH_site . $storage->getFile($fileIdentifier)->getPublicUrl(); + $absoluteFilePath = Environment::getPublicPath() . '/' . $storage->getFile($fileIdentifier)->getPublicUrl(); } try { @@ -167,8 +180,13 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll 'markerLabel' => $markerLabel ]; } + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var RegisterService $registrationService */ + $registrationService = $this->objectManager->get(RegisterService::class); + } else { + $registrationService = GeneralUtility::makeInstance(RegisterService::class); + } - $registrationService = $this->objectManager->get(RegisterService::class); return $registrationService->writeRegisterFile($templateKey, $extensionKey, $markers, $templateKey); } diff --git a/Classes/XClass/Form/FormManagerController.php b/Classes/XClass/Form/FormManagerController.php index 83c5856ca7dc9784a998940f7eaa839c1bf09061..eada50d8a78d9ce149edfe6b7800ef691b905c3a 100644 --- a/Classes/XClass/Form/FormManagerController.php +++ b/Classes/XClass/Form/FormManagerController.php @@ -32,6 +32,7 @@ use SGalinski\SgMail\Service\TypoScriptSettingsService; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; /** @@ -70,10 +71,14 @@ class FormManagerController extends \TYPO3\CMS\Form\Controller\FormManagerContro */ private function getRegistrationPath(): string { // get typoscript settings from sg mail - /** @var TypoScriptSettingsService $typoScriptSettingsService */ - $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); - $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + /** @var TypoScriptSettingsService $typoScriptSettingsService */ + $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + } else { + $typoScriptSettingsService = GeneralUtility::makeInstance(TypoScriptSettingsService::class); + } + $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); // get the location where automatic registrations should be stored return 'EXT:' . $tsSettings['mail']['configurationLocation'] . '/' . MailTemplateService::CONFIG_PATH; } @@ -84,12 +89,15 @@ class FormManagerController extends \TYPO3\CMS\Form\Controller\FormManagerContro * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException */ private function clearCaches() { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $cacheManager = $objectManager->get(CacheManager::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var CacheManager $cacheManager */ + $cacheManager = $objectManager->get(CacheManager::class); + } else { + $cacheManager = GeneralUtility::makeInstance(CacheManager::class); + } - /** @var FrontendInterface $cache */ $cache = $cacheManager->getCache(MailTemplateService::CACHE_NAME); - /** @var FrontendInterface $cache */ $cache->flush(); } } diff --git a/Configuration/Commands.php b/Configuration/Commands.php new file mode 100644 index 0000000000000000000000000000000000000000..0d05fb42eec64f87d120fea40764d057850d787d --- /dev/null +++ b/Configuration/Commands.php @@ -0,0 +1,6 @@ +<?php +return [ + 'sg_mail:sendMail' => [ + 'class' => \SGalinski\SgMail\Command\SendMailCommandController::class + ] +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0422e6f4d82aeeb78ab37598c6dcc01241a73e41 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,20 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + SGalinski\SgMail\: + resource: '../Classes/*' + + SGalinski\SgMail\Domain\Repository\FrontendUserGroupRepository: + public: true + + SGalinski\SgMail\Domain\Repository\LayoutRepository: + public: true + + SGalinski\SgMail\Domain\Repository\MailRepository: + public: true + + SGalinski\SgMail\Domain\Repository\TemplateRepository: + public: true diff --git a/Configuration/TCA/tx_sgmail_domain_model_layout.php b/Configuration/TCA/tx_sgmail_domain_model_layout.php index d9eaf50ee15a04af9249aee8abbe7514a025568a..ffc409bf77114b37ac68221b60860822f71847d9 100644 --- a/Configuration/TCA/tx_sgmail_domain_model_layout.php +++ b/Configuration/TCA/tx_sgmail_domain_model_layout.php @@ -24,7 +24,7 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -return [ +$columns = [ 'ctrl' => [ 'title' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout', 'label' => 'name', @@ -44,9 +44,7 @@ return [ 'hideTable' => TRUE, 'iconfile' => 'EXT:sg_mail/Resources/Public/Icons/ModuleIconTCA.svg' ], - 'interface' => [ - 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, name, head_content, content, default' - ], + 'interface' => [], 'types' => [ '1' => [ 'showitem' => 'hidden, --palette--;;name, head_content, content, ' @@ -87,7 +85,6 @@ return [ ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', - 'exclude' => true, 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', 'config' => [ 'type' => 'select', @@ -143,3 +140,8 @@ return [ ], ] ]; +if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '10.3.0', '<')) { + $columns['interface']['showRecordFieldList'] = 'sys_language_uid, l10n_parent, l10n_diffsource, name, head_content, content, default'; +} + +return $columns; diff --git a/Configuration/TCA/tx_sgmail_domain_model_mail.php b/Configuration/TCA/tx_sgmail_domain_model_mail.php index 5dc158491e754c065230aad12e816a4e2ade8fba..1895df9b3193ff1dcfba105bb5271f0421847752 100644 --- a/Configuration/TCA/tx_sgmail_domain_model_mail.php +++ b/Configuration/TCA/tx_sgmail_domain_model_mail.php @@ -24,7 +24,7 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -return [ +$columns = [ 'ctrl' => [ 'title' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_mail', 'label' => 'mail_subject', @@ -41,9 +41,7 @@ return [ 'default_sortby' => 'ORDER BY priority DESC', 'iconfile' => 'EXT:sg_mail/Resources/Public/Icons/ModuleIconTCA.svg' ], - 'interface' => [ - 'showRecordFieldList' => 'hidden, blacklisted, mail_subject, mail_body, to_address, from_address, priority, from_name, bcc_addresses, cc_addresses, extension_key, template_name, sending_time, last_sending_time, language', - ], + 'interface' => [], 'types' => [ '1' => [ 'showitem' => 'hidden;;1, blacklisted, priority, to_address, from_address, mail_subject, mail_body, from_name, bcc_addresses, cc_addresses, extension_key, template_name, sending_time, last_sending_time, language, attachments' @@ -199,3 +197,8 @@ return [ ] ] ]; +if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '10.3.0', '<')) { + $columns['interface']['showRecordFieldList'] = 'hidden, blacklisted, mail_subject, mail_body, to_address, from_address, priority, from_name, bcc_addresses, cc_addresses, extension_key, template_name, sending_time, last_sending_time, language'; +} + +return $columns; diff --git a/Configuration/TCA/tx_sgmail_domain_model_template.php b/Configuration/TCA/tx_sgmail_domain_model_template.php index 9b42cee13069c2d877bb326631c03efd7cb14b47..7bf38f6fa2911fbc53ba7c7338198314e0862d55 100644 --- a/Configuration/TCA/tx_sgmail_domain_model_template.php +++ b/Configuration/TCA/tx_sgmail_domain_model_template.php @@ -24,7 +24,7 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -return [ +$columns = [ 'ctrl' => [ 'title' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_template', 'label' => 'extension_key', @@ -42,9 +42,7 @@ return [ 'default_sortby' => 'ORDER BY extension_key ASC, template_name ASC', 'iconfile' => 'EXT:sg_mail/Resources/Public/Icons/ModuleIconTCA.svg' ], - 'interface' => [ - 'showRecordFieldList' => 'layout, extension_key, template_name, language, content, subject, fromName, fromMail, cc, bcc, replyTo, to_address' - ], + 'interface' => [], 'types' => [ '1' => [ 'showitem' => 'hidden;;1, extension_key, template_name, language, content, subject, fromName, fromMail, cc, bcc, replyTo, to_address' @@ -157,3 +155,8 @@ return [ ] ] ]; +if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '10.3.0', '<')) { + $columns['interface']['showRecordFieldList'] = 'layout, extension_key, template_name, language, content, subject, fromName, fromMail, cc, bcc, replyTo, to_address'; +} + +return $columns; diff --git a/README.md b/README.md index f747a922cb5b9090a337ec7112334b5c0f0e5efa..25f2a5b719e54095317209eba672acfdddb72910 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Repository: https://gitlab.sgalinski.de/typo3/sg_mail Please report bugs here: https://gitlab.sgalinski.de/typo3/sg_mail -TYPO3 version: >7.6 +TYPO3 version: >9.5 ## About @@ -116,7 +116,7 @@ Example: // get an instance of the service /** @var MailTemplateService $mailService */ - $mailService = $this->objectManager->get(MailTemplateService::class, 'confirm_mail', 'sg_example', ['username' => $username]); + $mailService = GeneralUtility::makeInstance(MailTemplateService::class, 'confirm_mail', 'sg_example', ['username' => $username]); $mailService->setFromName($this->settings['fromName']); $mailService->setFromAddress($this->settings['fromEmail']); @@ -283,9 +283,6 @@ Sends your mail or adds it to the mailing queue, depending on the settings. You ###### function sendMailFromQueue Forces the sending of an E-Mail from within the queue. If it has already been sent, it gets send again. -###### function addAttachment -With this function you can add attachments to your mail. The attachment must be of type *Swift_OutputByteStream*. You must also specify the content-type of the attachment. - ###### function getMailMessage You can get the instance of **\TYPO3\CMS\Core\Mail\MailMessage** that is internally used by the service, if you want a more direct interaction with the mail object. @@ -329,4 +326,3 @@ You can customize the TypoScript settings in the **setup.ts** in order to have c This Service enables you to access your typoscript settings outside of your controller classes. You simply need to supply your page id and the extension key. If you have no page id specific settings, set the page id to 0. - diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html index 8ad6677e2abc29fbe2e63aa9f7df4e58dcb3a89e..5cf0fc3d6c922369b4a5678d91e24ffd2afdfc5b 100644 --- a/Resources/Private/Layouts/Default.html +++ b/Resources/Private/Layouts/Default.html @@ -11,7 +11,7 @@ <f:render partial="Module/DocHeader" section="main" - arguments="{docHeader: docHeader, pages: pages, selectedTemplateKey: selectedTemplateKey, selectedExtensionKey: selectedExtensionKey,typo3Version: typo3Version}" /> + arguments="{docHeader: docHeader, pages: pages, selectedTemplateKey: selectedTemplateKey, selectedExtensionKey: selectedExtensionKey}" /> <f:if condition="{pages}"> <f:then></f:then> <f:else> diff --git a/Resources/Private/Layouts/Newsletter.html b/Resources/Private/Layouts/Newsletter.html index 5dc57493a4cb751c021155ff680e67d0ec0b3af7..ee7edd43670e7cbc6f46cee480a683a08d6c4084 100644 --- a/Resources/Private/Layouts/Newsletter.html +++ b/Resources/Private/Layouts/Newsletter.html @@ -19,7 +19,7 @@ <f:render partial="Module/DocHeader" section="main" - arguments="{docHeader: docHeader, pages: pages, selectedTemplateKey: selectedTemplateKey, selectedExtensionKey: selectedExtensionKey,typo3Version: typo3Version}" /> + arguments="{docHeader: docHeader, pages: pages, selectedTemplateKey: selectedTemplateKey, selectedExtensionKey: selectedExtensionKey}" /> <f:if condition="{pages}"> <f:then></f:then> <f:else> diff --git a/Resources/Private/Partials/Module/DocHeader.html b/Resources/Private/Partials/Module/DocHeader.html index f17fe37bc7197a04bb4f91456efdbcf3854c0043..549a53ade7d49d868fe93729d983c4f785974671 100644 --- a/Resources/Private/Partials/Module/DocHeader.html +++ b/Resources/Private/Partials/Module/DocHeader.html @@ -37,21 +37,14 @@ <f:render partial="Module/DocHeader" section="path" - arguments="{docHeader: docHeader, typo3Version: typo3Version}" /> + arguments="{docHeader: docHeader}" /> </div> </f:section> <f:section name="path"> <div class="module-docheader-bar-column-right"> <span class="typo3-docheader-pagePath"> - <f:if condition="{typo3Version} < 9000000"> - <f:then> - <f:translate key="LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw> - </f:then> - <f:else> - <f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw> - </f:else> - </f:if> + <f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw> </span> <f:format.raw>{docHeader.metaInformation.recordInformation}</f:format.raw> </div> diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 0000000000000000000000000000000000000000..3b524358317f4107360e299eb0753847e98ffe25 --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,4 @@ +## Version 6 Breaking Changes + +- Dropped TYPO3 8 support +- set ignoreMailQueue to TRUE by default diff --git a/composer.json b/composer.json index 4132f8f3990e3654d70f14626a6e44da244c7800..9ca4e6afbb88f8a1db388c886b26cf246aa51a35 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": [ "GPL-2.0-or-later" ], - "version": "5.7.11", + "version": "6.0.0-dev", "repositories": [ { "type": "composer", @@ -14,8 +14,7 @@ } ], "require": { - "php": "^7.0", - "typo3/cms-core": "^8.7.0 || ^9.5.1" + "typo3/cms-core": "^9.5.1 || ^10.4.0" }, "require-dev": { "roave/security-advisories": "dev-master" diff --git a/ext_emconf.php b/ext_emconf.php index a307298ce99d956d0223368ea10aaeb7b2e436c2..47c4c6b2e502cd935a7d18b11a6733a394603163 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,8 +8,8 @@ $EM_CONF['sg_mail'] = [ 'title' => 'Mail Templates', 'description' => 'Mail Templates', 'category' => 'module', - 'version' => '5.7.11', - 'state' => 'stable', + 'version' => '6.0.0-dev', + 'state' => 'experimental', 'uploadfolder' => FALSE, 'createDirs' => '', 'clearcacheonload' => FALSE, @@ -18,8 +18,8 @@ $EM_CONF['sg_mail'] = [ 'author_company' => 'sgalinski Internet Services (https://www.sgalinski.de)', 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-9.5.99', - 'php' => '7.0.0-', + 'typo3' => '9.5.0-10.4.99', + 'php' => '7.3.0-7.4.99', ], 'conflicts' => [ ], diff --git a/ext_localconf.php b/ext_localconf.php index 106edb59ffc7bfbb2f4f6038676112e50a870b18..3850223f92b8655b4a101715d8234a0fbd550717 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -25,20 +25,16 @@ call_user_func( function ($extKey) { - - // register command controllers - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = - \SGalinski\SgMail\Command\SendMailCommandController::class; - // add upgrade wizard for moving all db entries to their respected siteroot - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tx_sgmail_update_pid_to_site_root'] = \SGalinski\SgMail\Updates\UpdatePidToSiteRoot::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tx_sgmail_update_sending_times'] = \SGalinski\SgMail\Updates\UpdateSendingTimes::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tx_sgmail_update_languages'] = \SGalinski\SgMail\Updates\UpdateLanguages::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tx_sgmail_update_german_as_default'] = \SGalinski\SgMail\Updates\UpdateGermanAsDefault::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgMail\Updates\UpdatePidToSiteRoot::IDENTIFIER] = \SGalinski\SgMail\Updates\UpdatePidToSiteRoot::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgMail\Updates\UpdateSendingTimes::IDENTIFIER] = \SGalinski\SgMail\Updates\UpdateSendingTimes::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgMail\Updates\UpdateLanguages::IDENTIFIER] = \SGalinski\SgMail\Updates\UpdateLanguages::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgMail\Updates\UpdateGermanAsDefault::IDENTIFIER] = \SGalinski\SgMail\Updates\UpdateGermanAsDefault::class; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgMail\Updates\MigrateSchedulerTasks::IDENTIFIER] = \SGalinski\SgMail\Updates\MigrateSchedulerTasks::class; if (TYPO3_MODE === 'BE') { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup( - '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/TypoScript/setup.typoscript">' + '@import "EXT:' . $extKey . '/Configuration/TypoScript/setup.typoscript"' ); } diff --git a/ext_tables.sql b/ext_tables.sql index ae075763a6c650f12a4a1ee173753dc60493fac4..c8b4ccf5be61092e4be69fbbaf9c8c5729fea475 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -1,7 +1,4 @@ CREATE TABLE tx_sgmail_domain_model_mail ( - uid int(11) NOT NULL auto_increment, - pid int(11) DEFAULT '0' NOT NULL, - mail_subject text NOT NULL, mail_body text NOT NULL, to_address varchar(255) DEFAULT '' NOT NULL, @@ -17,24 +14,10 @@ CREATE TABLE tx_sgmail_domain_model_mail ( last_sending_time int(11) unsigned DEFAULT '0' NOT NULL, language varchar(255) DEFAULT '' NOT NULL, blacklisted tinyint(4) unsigned DEFAULT '0' NOT NULL, - attachments int(11) unsigned DEFAULT '0' NOT NULL, - - tstamp int(11) unsigned DEFAULT '0' NOT NULL, - crdate int(11) unsigned DEFAULT '0' NOT NULL, - cruser_id int(11) unsigned DEFAULT '0' NOT NULL, - deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, - hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, - starttime int(11) unsigned DEFAULT '0' NOT NULL, - endtime int(11) unsigned DEFAULT '0' NOT NULL, - - PRIMARY KEY (uid), - KEY parent (pid) + attachments int(11) unsigned DEFAULT '0' NOT NULL ); CREATE TABLE tx_sgmail_domain_model_template ( - uid int(11) NOT NULL auto_increment, - pid int(11) DEFAULT '0' NOT NULL, - layout int(11) DEFAULT '0' NOT NULL, subject text NOT NULL, extension_key varchar(255) DEFAULT '' NOT NULL, @@ -46,37 +29,12 @@ CREATE TABLE tx_sgmail_domain_model_template ( bcc varchar(255) DEFAULT '' NOT NULL, reply_to varchar(255) DEFAULT '' NOT NULL, language varchar(30) DEFAULT '' NOT NULL, - content text NOT NULL, - tstamp int(11) unsigned DEFAULT '0' NOT NULL, - crdate int(11) unsigned DEFAULT '0' NOT NULL, - cruser_id int(11) unsigned DEFAULT '0' NOT NULL, - deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, - hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, - starttime int(11) unsigned DEFAULT '0' NOT NULL, - endtime int(11) unsigned DEFAULT '0' NOT NULL, - - PRIMARY KEY (uid), - KEY parent (pid) + content text NOT NULL ); CREATE TABLE tx_sgmail_domain_model_layout ( - uid int(11) NOT NULL auto_increment, - pid int(11) DEFAULT '0' NOT NULL, - tstamp int(11) DEFAULT '0' NOT NULL, - crdate int(11) DEFAULT '0' NOT NULL, - cruser_id int(11) DEFAULT '0' NOT NULL, - deleted tinyint(4) DEFAULT '0' NOT NULL, - hidden tinyint(4) DEFAULT '0' NOT NULL, default tinyint(4) DEFAULT '0' NOT NULL, - - sys_language_uid int(11) DEFAULT '0' NOT NULL, - l10n_parent int(11) DEFAULT '0' NOT NULL, - l10n_diffsource mediumblob, - name tinytext NOT NULL, content text, - head_content text, - - PRIMARY KEY (uid), - KEY layout_list (pid,deleted,sys_language_uid) + head_content text );