From bffb57626da92aecf5cfc8652933d7fedc85cd42 Mon Sep 17 00:00:00 2001 From: Igor Neyman Date: Thu, 5 Jan 2023 11:58:48 +0100 Subject: [PATCH] run php-cs-fixer --- Classes/Command/AnalyzeBounceMailCommand.php | 35 +-- Classes/Command/DirectmailCommand.php | 1 + Classes/Command/InvokeMailerEngineCommand.php | 7 +- Classes/Container.php | 8 +- Classes/DirectMailUtility.php | 63 ++-- Classes/DmQueryGenerator.php | 5 +- Classes/Dmailer.php | 137 +++----- .../Hooks/TypoScriptFrontendController.php | 3 - Classes/Importer.php | 129 +++----- Classes/Middleware/JumpurlController.php | 26 +- Classes/Module/ConfigurationController.php | 19 +- Classes/Module/DmailController.php | 289 ++++++++--------- Classes/Module/MailerEngineController.php | 48 ++- Classes/Module/MainController.php | 50 +-- Classes/Module/NavFrameController.php | 20 +- Classes/Module/RecipientListController.php | 117 ++++--- Classes/Module/StatisticsController.php | 292 +++++++++--------- Classes/Plugin/DirectMail.php | 52 ++-- Classes/Repository/FeUsersRepository.php | 10 +- Classes/Repository/MainRepository.php | 4 +- Classes/Repository/PagesRepository.php | 21 +- .../Repository/SysDmailCategoryRepository.php | 8 +- .../Repository/SysDmailGroupRepository.php | 26 +- .../Repository/SysDmailMaillogRepository.php | 34 +- Classes/Repository/SysDmailRepository.php | 17 +- .../SysDmailTtAddressCategoryMmRepository.php | 4 +- .../SysDmailTtContentCategoryMmRepository.php | 4 +- Classes/Repository/SysLanguageRepository.php | 4 +- Classes/Repository/TempRepository.php | 70 ++--- Classes/Repository/TtAddressRepository.php | 21 +- .../TtContentCategoryMmRepository.php | 4 +- Classes/Repository/TtContentRepository.php | 4 +- Classes/Scheduler/AnalyzeBounceMail.php | 16 +- .../AnalyzeBounceMailAdditionalFields.php | 8 +- Classes/Scheduler/DirectmailScheduler.php | 5 +- Classes/Scheduler/MailFromDraft.php | 23 +- .../MailFromDraftAdditionalFields.php | 10 +- .../Scheduler/MailFromDraftHookInterface.php | 9 +- Classes/SelectCategories.php | 8 +- Classes/Utility/AuthCodeUtility.php | 8 +- Classes/Utility/DmCsvUtility.php | 15 +- Classes/Utility/DmRegistryUtility.php | 1 + Classes/Utility/ReadmailUtility.php | 37 +-- Classes/Utility/TsUtility.php | 7 +- Classes/Utility/Typo3ConfVarsUtility.php | 5 +- Configuration/Icons.php | 25 +- Configuration/RequestMiddlewares.php | 2 +- Configuration/TCA/Overrides/fe_users.php | 15 +- Configuration/TCA/Overrides/pages.php | 1 + Configuration/TCA/Overrides/sys_template.php | 1 + Configuration/TCA/Overrides/tt_address.php | 11 +- Configuration/TCA/Overrides/tt_content.php | 5 +- Configuration/TCA/sys_dmail.php | 123 ++++---- Configuration/TCA/sys_dmail_category.php | 21 +- Configuration/TCA/sys_dmail_group.php | 61 ++-- Tests/Unit/Dmailer/DirectMailEngineTest.php | 29 +- ext_emconf.php | 6 +- ext_localconf.php | 5 +- ext_tables.php | 3 +- 59 files changed, 898 insertions(+), 1094 deletions(-) diff --git a/Classes/Command/AnalyzeBounceMailCommand.php b/Classes/Command/AnalyzeBounceMailCommand.php index 998e7f875..f9a7d34fa 100644 --- a/Classes/Command/AnalyzeBounceMailCommand.php +++ b/Classes/Command/AnalyzeBounceMailCommand.php @@ -1,7 +1,7 @@ getOption('type')) { $type = $input->getOption('type'); //$io->writeln($type); - if(!in_array($type, ['imap', 'pop3'])) { + if (!in_array($type, ['imap', 'pop3'])) { $io->warning('Type: only imap or pop3'); return Command::FAILURE; } @@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // we are connected to mail server // get unread mails $messages = $mailServer->search('UNSEEN', $count); - if(count($messages)) { + if (count($messages)) { /** @var Message $message The message object */ foreach ($messages as $message) { // process the mail @@ -130,8 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output) //$io->writeln($message->getSubject()); // set delete $message->delete(); - } - else { + } else { $message->setFlag('SEEN'); } } @@ -141,9 +140,8 @@ protected function execute(InputInterface $input, OutputInterface $output) imap_close($mailServer->getImapStream()); return Command::SUCCESS; } - else { - return Command::FAILURE; - } + + return Command::FAILURE; return Command::SUCCESS; } @@ -167,13 +165,12 @@ private function processBounceMail($message) $bouncedMail = $attachment->getData(); // Find mail id $midArray = $readMail->find_XTypo3MID($bouncedMail); - if (false === empty($midArray)) { + if (empty($midArray) === false) { // if mid, rid and rtbl are found, then stop looping break; } } - } - else { + } else { // search in MessageBody (see rfc822-headers as Attachments placed ) $midArray = $readMail->find_XTypo3MID($message->getMessageBody()); } @@ -191,7 +188,6 @@ private function processBounceMail($message) // only write to log table, if we found a corresponding recipient record if (!empty($row)) { - $midArray['email'] = $row['email']; try { return $sysDmailMaillogRepository->analyzeBounceMailAddToMailLog( @@ -204,8 +200,7 @@ private function processBounceMail($message) // Log $e->getMessage(); return false; } - } - else { + } else { return false; } } @@ -240,24 +235,22 @@ private function connectMailServer(string $server, int $port, string $type, stri $imapStream = $mailServer->getImapStream(); return $mailServer; } catch (\Exception $e) { - $io->error($this->languageService->getLL('scheduler.bounceMail.dataVerification').$e->getMessage()); + $io->error($this->languageService->getLL('scheduler.bounceMail.dataVerification') . $e->getMessage()); return false; } } /** - * * @return int */ - private function getTimestampFromAspect(): int { + private function getTimestampFromAspect(): int + { $context = GeneralUtility::makeInstance(Context::class); return $context->getPropertyFromAspect('date', 'timestamp'); } - /** - * @return void - */ - private function setLanguageService(): void { + private function setLanguageService(): void + { $languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class); $this->languageService = $languageServiceFactory->create('en'); //@TODO $this->languageService->includeLLFile('EXT:direct_mail/Resources/Private/Language/locallang_mod2-6.xlf'); diff --git a/Classes/Command/DirectmailCommand.php b/Classes/Command/DirectmailCommand.php index 0ff004a51..03800a4b9 100644 --- a/Classes/Command/DirectmailCommand.php +++ b/Classes/Command/DirectmailCommand.php @@ -1,4 +1,5 @@ (time() - (60 * 60 * 24))) { $io->warning('TYPO3 Direct Mail Cron: Aborting, another process is already running!'); return Command::FAILURE; - } else { - $io->writeln('TYPO3 Direct Mail Cron: A .lock file was found but it is older than 1 day! Processing mails ...'); } + $io->writeln('TYPO3 Direct Mail Cron: A .lock file was found but it is older than 1 day! Processing mails ...'); } touch($lockfile); diff --git a/Classes/Container.php b/Classes/Container.php index 97ec7ff1a..e943eafd0 100644 --- a/Classes/Container.php +++ b/Classes/Container.php @@ -1,4 +1,5 @@ @typo3.com> * @author Thorsten Kahler - * - * @package TYPO3 - * @subpackage tx_directmail */ class Container { @@ -71,7 +69,7 @@ public function insert_dMailer_boundaries($content, $conf = []) if ($content != '') { // setting the default $categoryList = ''; - if (intval($this->cObj->data['module_sys_dmail_category']) >= 1) { + if ((int)($this->cObj->data['module_sys_dmail_category']) >= 1) { // if content type "RECORDS" we have to strip off // boundaries from indcluded records if ($this->cObj->data['CType'] == 'shortcut') { @@ -122,7 +120,7 @@ public function stripInnerBoundaries($content) public function breakLines($content, array $conf) { $linebreak = $GLOBALS['TSFE']->cObj->stdWrap(($conf['linebreak'] ? $conf['linebreak'] : chr(32) . LF), $conf['linebreak.']); - $charWidth = $GLOBALS['TSFE']->cObj->stdWrap(($conf['charWidth'] ? intval($conf['charWidth']) : 76), $conf['charWidth.']); + $charWidth = $GLOBALS['TSFE']->cObj->stdWrap(($conf['charWidth'] ? (int)($conf['charWidth']) : 76), $conf['charWidth.']); return MailUtility::breakLinesForEmail($content, $linebreak, $charWidth); } diff --git a/Classes/DirectMailUtility.php b/Classes/DirectMailUtility.php index daab8cf49..0e2efad83 100644 --- a/Classes/DirectMailUtility.php +++ b/Classes/DirectMailUtility.php @@ -1,4 +1,5 @@ * @author Stanislas Rolland * @author Ivan-Dharma Kartolo - * - * @package TYPO3 - * @subpackage tx_directmail */ class DirectMailUtility { @@ -64,7 +62,7 @@ public static function getLanguageService(): LanguageService * * @param string $url * - * @return string & or ? + * @return string&or ? */ public static function getURLGlue(string $url): string { @@ -80,15 +78,14 @@ public static function getTypolinkURL( string $parameter, bool $forceAbsoluteUrl = true, bool $linkAccessRestrictedPages = true - ): string - { + ): string { $typolinkPageUrl = 't3://page?uid='; $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); return $cObj->typolink_URL([ 'parameter' => $typolinkPageUrl . $parameter, 'forceAbsoluteUrl' => $forceAbsoluteUrl, - 'linkAccessRestrictedPages' => $linkAccessRestrictedPages + 'linkAccessRestrictedPages' => $linkAccessRestrictedPages, ]); } @@ -120,7 +117,7 @@ public static function fetchUrlContentsForDirectMailRecord(array $row, array $pa $htmlmail->setJumperURLPrefix( $urls['baseUrl'] . $glue . 'mid=###SYS_MAIL_ID###' . - (intval($params['jumpurl_tracking_privacy']) ? '' : '&rid=###SYS_TABLE_NAME###_###USER_uid###') . + ((int)($params['jumpurl_tracking_privacy']) ? '' : '&rid=###SYS_TABLE_NAME###_###USER_uid###') . '&aC=###SYS_AUTHCODE###' . '&jumpurl=' ); @@ -141,8 +138,7 @@ public static function fetchUrlContentsForDirectMailRecord(array $row, array $pa $htmlmail->addPlain($mailContent); if (!$mailContent || !$htmlmail->getPartPlainConfig('content')) { $errorMsg[] = $lang->getLL('dmail_no_plain_content'); - } - elseif (!strstr($htmlmail->getPartPlainConfig('content'), '' . $indata['message'] . ''; if (trim($this->params['use_rdct'])) { @@ -818,9 +810,8 @@ protected function createDMailQuick(array $indata) } // fetch functions $theOutput = $this->compileQuickMail($row, $message); - // end fetch function - } - else { + // end fetch function + } else { if (!$dmail['sys_dmail']['NEW']['sendOptions']) { $this->error = 'no_valid_url'; } @@ -845,7 +836,7 @@ protected function linkDMailRecord($uid) 'id' => $this->id, 'sys_dmail_uid' => $uid, 'fetchAtOnce' => 1, - 'cmd' => 'info' + 'cmd' => 'info', ] ); } @@ -868,7 +859,7 @@ protected function deleteLink($uid) [ 'id' => $this->id, 'uid' => $uid, - 'cmd' => 'delete' + 'cmd' => 'delete', ] ); } @@ -880,8 +871,6 @@ protected function deleteLink($uid) * Delete existing dmail record * * @param int $uid record uid to be deleted - * - * @return void */ protected function deleteDMail(int $uid) { @@ -917,8 +906,7 @@ protected function compileQuickMail(array $row, $message) if (!$message || !$htmlmail->getPartPlainConfig('content')) { $erg['errorTitle'] = $this->getLanguageService()->getLL('dmail_error'); $erg['errorText'] = $this->getLanguageService()->getLL('dmail_no_plain_content'); - } - elseif (!strstr(base64_decode($htmlmail->getPartPlainConfig('content')), '