Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/Command/AnalyzeBounceMailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AnalyzeBounceMailCommand extends Command
/**
* Configure the command by defining the name, options and arguments
*/
public function configure()
public function configure(): void
{
$this->setDescription('This command will get bounce mail from the configured mailbox')
->addOption(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/DirectmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DirectmailCommand extends Command
/**
* Configure the command by defining the name, options and arguments
*/
public function configure()
public function configure(): void
{
$this->setDescription('This command invokes dmailer in order to process queued messages.');
//$this->setHelp('');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/InvokeMailerEngineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class InvokeMailerEngineCommand extends Command
/**
* Configure the command by defining the name, options and arguments
*/
public function configure()
public function configure(): void
{
$this->setDescription('Invoke Mailer Engine of EXT:directmail');
$this->setHelp('
Expand Down
4 changes: 2 additions & 2 deletions Classes/DirectMailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public static function getFullUrlsForDirectMailRecord(array $row): array
$result['plainTextUrl'] = '';
} else {
$urlParts = @parse_url($result['plainTextUrl']);
if (!$urlParts['scheme']) {
if (!($urlParts['scheme'] ?? null)) {
$result['plainTextUrl'] = 'http://' . $result['plainTextUrl'];
}
}
Expand All @@ -344,7 +344,7 @@ public static function getFullUrlsForDirectMailRecord(array $row): array
$result['htmlUrl'] = '';
} else {
$urlParts = @parse_url($result['htmlUrl']);
if (!$urlParts['scheme']) {
if (!($urlParts['scheme'] ?? null)) {
$result['htmlUrl'] = 'http://' . $result['htmlUrl'];
}
}
Expand Down
12 changes: 8 additions & 4 deletions Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ public function sendAdvanced(array $recipientRow, string $tableNameChar): int

$this->theParts['html']['content'] = '';
if ($this->flagHtml && (($recipientRow['module_sys_dmail_html'] ?? false) || $tableNameChar == 'P')) {
if(!isset($recipientRow['sys_dmail_categories_list'])){
$recipientRow['sys_dmail_categories_list'] = '';
}
$tempContentHTML = $this->getBoundaryParts($this->dmailer['boundaryParts_html'], $recipientRow['sys_dmail_categories_list']);
if ($this->mailHasContent) {
$this->theParts['html']['content'] = $this->replaceMailMarkers($tempContentHTML, $recipientRow, $additionalMarkers);
Expand Down Expand Up @@ -462,7 +465,7 @@ public function sendSimple(array $recipients): bool
* filters out the elements that are inteded for categories not subscribed to.
*
* @param array $cArray Array of content split by dmail boundary
* @param string $userCategories The list of categories the user is subscribing to.
* @param mixed $userCategories The list of categories the user is subscribing to.
*
* @return string Content of the email, which the recipient subscribed
*/
Expand All @@ -475,7 +478,7 @@ protected function getBoundaryParts($cArray, $userCategories): string
$key = substr($cP[0], 1);
$isSubscribed = false;
$cP['mediaList'] = $cP['mediaList'] ?? '';
if (!$key || ((int)$userCategories == -1)) {
if (!$key || ($userCategories === -1)) {
$returnVal .= $cP[1];
//$this->mediaList .= $cP['mediaList'];
if ($cP[1]) {
Expand Down Expand Up @@ -685,11 +688,12 @@ public function convertFields(array $recipRow): array
}

// Firstname must be more that 1 character
$recipRow['firstname'] = trim(strtok(trim($recipRow['name']), ' '));
$name = $recipRow['name'] ?? ''; // use empty string if null
$recipRow['firstname'] = trim(strtok(trim($name), ' '));
if (strlen($recipRow['firstname']) < 2 || preg_match('|[^[:alnum:]]$|', $recipRow['firstname'])) {
$recipRow['firstname'] = $recipRow['name'];
}
if (!trim($recipRow['firstname'])) {
if (isset($recipRow['firstname']) && !trim($recipRow['firstname'])) {
$recipRow['firstname'] = $recipRow['email'];
}
return $recipRow;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Hooks/TypoScriptFrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class TypoScriptFrontendController
* a frontend usergroup is specified in the GET parameters, use this
* group to simulate access to an access protected page with content to be sent
*/
public function simulateUsergroup($parameters, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $typoScriptFrontendController)
public function simulateUsergroup($parameters, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $typoScriptFrontendController): void
{
$directMailFeGroup = (int)GeneralUtility::_GET('dmail_fe_group');
$accessToken = (string)GeneralUtility::_GET('access_token');
$directMailFeGroup = (int)($GLOBALS['TYPO3_REQUEST']->getQueryParams()['dmail_fe_group'] ?? null);
$accessToken = (string)($GLOBALS['TYPO3_REQUEST']->getQueryParams()['access_token'] ?? null);
if ($directMailFeGroup > 0 && GeneralUtility::makeInstance(DmRegistryUtility::class)->validateAndRemoveAccessToken($accessToken)) {
/** @var UserAspect $userAspect */
$userAspect = $typoScriptFrontendController->getContext()->getAspect('frontend.user');
Expand Down
3 changes: 2 additions & 1 deletion Classes/Middleware/JumpurlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Crypto\HashService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;

Expand Down Expand Up @@ -325,7 +326,7 @@ protected function performFeUserAutoLogin()
*/
protected function calculateJumpUrlHash(string $targetUrl): string
{
return GeneralUtility::hmac($targetUrl, 'jumpurl');
return GeneralUtility::makeInstance(HashService::class)->hmac($targetUrl, 'jumpurl');
}

/**
Expand Down
16 changes: 5 additions & 11 deletions Classes/Module/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,15 @@
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\Controller;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Imaging\IconFactory;
use DirectMailTeam\DirectMail\Repository\PagesRepository;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Type\Bitmask\Permission;

final class ConfigurationController extends MainController
Expand Down Expand Up @@ -83,7 +76,6 @@ public function handleRequest(ServerRequestInterface $request): ResponseInterfac
public function indexAction(ModuleTemplate $view): ResponseInterface
{
// Load JavaScript via PageRenderer
$this->pageRenderer->loadRequireJs();
$this->pageRenderer->loadJavaScriptModule('@directmailteam/diractmail/Configuration.js');
if (($this->id && $this->access) || ($this->isAdmin() && !$this->id)) {

Expand Down Expand Up @@ -138,20 +130,20 @@ public function indexAction(ModuleTemplate $view): ResponseInterface
}

/**
* @return ResponseFactory
* @return ResponseFactoryInterface
*/
protected function getResponseFactory(): ResponseFactoryInterface
{
return GeneralUtility::makeInstance(ResponseFactoryInterface::class);
}

public function updateConfigAction(ServerRequestInterface $request): ResponseInterface
public function updateConfigAction(ServerRequestInterface $request): ?ResponseInterface
{
$this->id = (int)($request->getParsedBody()['uid'] ?? 0);
$permsClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$pageAccess = BackendUtility::readPageAccess($this->id, $permsClause);
$this->pageinfo = is_array($pageAccess) ? $pageAccess : [];
$this->access = is_array($this->pageinfo) ? true : false;
$this->access = is_array($this->pageinfo);


if (($this->id && $this->access) || ($this->isAdmin() && !$this->id)) {
Expand Down Expand Up @@ -192,6 +184,8 @@ public function updateConfigAction(ServerRequestInterface $request): ResponseInt

}
}

return null;
}

protected function setDefaultValues(): void
Expand Down
38 changes: 18 additions & 20 deletions Classes/Module/DmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\PreviewUriBuilder;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\ImmediateResponseException;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\ArrayUtility;
Expand All @@ -41,10 +42,7 @@
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Backend\Attribute\Controller;
// the module template will be initialized in handleRequest()
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Core\Page\PageRenderer;
Expand Down Expand Up @@ -125,7 +123,7 @@ public function handleRequest(ServerRequestInterface $request): ResponseInterfac
$permsClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$pageAccess = BackendUtility::readPageAccess($this->id, $permsClause);
$this->pageinfo = is_array($pageAccess) ? $pageAccess : [];
$this->access = is_array($this->pageinfo) ? true : false;
$this->access = is_array($this->pageinfo);

// get the config from pageTS
$this->params = BackendUtility::getPagesTSconfig($this->id)['mod.']['web_modules.']['dmail.'] ?? [];
Expand Down Expand Up @@ -602,7 +600,7 @@ protected function getNewsletterTabIcon(bool $expand = false)
{
// opened - closes
$icon = $expand ? 'apps-pagetree-expand' : 'apps-pagetree-collapse';
return $this->iconFactory->getIcon($icon, Icon::SIZE_SMALL);
return $this->iconFactory->getIcon($icon, IconSize::SMALL);
}

/**
Expand Down Expand Up @@ -635,11 +633,11 @@ protected function getNews(): array
$langTitle = (count($languages) > 1 ? ' - ' . $lang['title'] : '');
$plainParams = $this->implodedParams['plainParams'] ?? '' . $langParam;
$htmlParams = $this->implodedParams['HTMLParams'] ?? '' . $langParam;
$htmlIcon = $this->iconFactory->getIcon('directmail-dmail-preview-html', Icon::SIZE_SMALL, $langIconOverlay);
$plainIcon = $this->iconFactory->getIcon('directmail-dmail-preview-text', Icon::SIZE_SMALL, $langIconOverlay);
$createIcon = $this->iconFactory->getIcon('directmail-dmail-new', Icon::SIZE_SMALL, $langIconOverlay);
$htmlIcon = $this->iconFactory->getIcon('directmail-dmail-preview-html', IconSize::SMALL, $langIconOverlay);
$plainIcon = $this->iconFactory->getIcon('directmail-dmail-preview-text', IconSize::SMALL, $langIconOverlay);
$createIcon = $this->iconFactory->getIcon('directmail-dmail-new', IconSize::SMALL, $langIconOverlay);

$attributes = \TYPO3\CMS\Backend\Routing\PreviewUriBuilder::create($row['uid'], '')
$attributes = PreviewUriBuilder::create($row['uid'], '')
->withRootLine(BackendUtility::BEgetRootLine($row['uid']))
//->withSection('')
->withAdditionalQueryParameters($htmlParams)
Expand All @@ -654,7 +652,7 @@ protected function getNews(): array

$previewHTMLLink .= '<a ' . $serializedAttributes . '>' . $htmlIcon . '</a>';

$attributes = \TYPO3\CMS\Backend\Routing\PreviewUriBuilder::create($row['uid'], '')
$attributes = PreviewUriBuilder::create($row['uid'], '')
->withRootLine(BackendUtility::BEgetRootLine($row['uid']))
//->withSection('')
->withAdditionalQueryParameters($plainParams)
Expand Down Expand Up @@ -695,7 +693,7 @@ protected function getNews(): array

$data[] = [
'id' => $row['uid'],
'pageIcon' => $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL),
'pageIcon' => $this->iconFactory->getIconForRecord('pages', $row, IconSize::SMALL),
'title' => htmlspecialchars($row['title']),
'createDmailLink' => $createDmailLink,
'createLink' => $createLink,
Expand Down Expand Up @@ -800,13 +798,13 @@ protected function getConfigFormDMail(): array
foreach ($rows as $row) {
$data[] = [
'id' => $row['uid'],
'icon' => $this->iconFactory->getIconForRecord('sys_dmail', $row, Icon::SIZE_SMALL)->render(),
'icon' => $this->iconFactory->getIconForRecord('sys_dmail', $row, IconSize::SMALL)->render(),
'link' => $this->linkDMailRecord($row['uid']),
'linkText' => htmlspecialchars($row['subject'] ?: '_'),
'tstamp' => BackendUtility::date($row['tstamp']),
'issent' => ($row['issent'] ? $this->languageService->sL($this->lllFile . ':dmail_yes') : $this->languageService->sL($this->lllFile . ':dmail_no')),
'renderedsize' => ($row['renderedsize'] ? GeneralUtility::formatSize($row['renderedsize']) : ''),
'attachment' => ($row['attachment'] ? $this->iconFactory->getIcon('directmail-attachment', Icon::SIZE_SMALL) : ''),
'attachment' => ($row['attachment'] ? $this->iconFactory->getIcon('directmail-attachment', IconSize::SMALL) : ''),
'type' => ($row['type'] & 0x1 ? $this->languageService->sL($this->lllFile . ':nl_l_tUrl') : $this->languageService->sL($this->lllFile . ':nl_l_tPage')) . ($row['type'] & 0x2 ? ' (' . $this->languageService->sL($this->lllFile . ':nl_l_tDraft') . ')' : ''),
'deleteLink' => $this->deleteLink($row['uid']),
];
Expand Down Expand Up @@ -1062,7 +1060,7 @@ protected function renderRecordDetailsTable(array $row): array
];

return [
'icon' => $this->iconFactory->getIconForRecord('sys_dmail', $row, Icon::SIZE_SMALL),
'icon' => $this->iconFactory->getIconForRecord('sys_dmail', $row, IconSize::SMALL),
'title' => htmlspecialchars($row['subject'] ?? ''),
'theadTitle1' => DirectMailUtility::fName('subject'),
'theadTitle2' => GeneralUtility::fixed_lgd_cs(htmlspecialchars($row['subject'] ?? ''), 60),
Expand Down Expand Up @@ -1117,7 +1115,7 @@ protected function getTestMailConfig(): array

$data['test_dmail_group_table'][] = [
'moduleUrl' => $moduleUrl,
'iconFactory' => $this->iconFactory->getIconForRecord('sys_dmail_group', $row, Icon::SIZE_SMALL),
'iconFactory' => $this->iconFactory->getIconForRecord('sys_dmail_group', $row, IconSize::SMALL),
'title' => htmlspecialchars($row['title']),
'uid' => $row['uid'],
'tds' => $this->displayMailGroupTest($result),
Expand Down Expand Up @@ -1173,7 +1171,7 @@ public function displayMailGroupTest(array $result): array
* @return string Messages if the mail is sent or planned to sent
* @todo remove htmlmail. sending test mail
*/
protected function sendMail($row)
protected function sendMail($row): void
{
// Preparing mailer
/* @var $htmlmail Dmailer */
Expand Down Expand Up @@ -1384,7 +1382,7 @@ public function getRecordList(
$moduleUrl = '';
$editOnClick = '';
if ($row['uid']) {
$tableIcon = $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL);
$tableIcon = $this->iconFactory->getIconForRecord($table, $row, IconSize::SMALL);
if ($editLinkFlag) {
$params = [
'edit' => [
Expand Down Expand Up @@ -1829,7 +1827,7 @@ public function makeCategoriesForm(array $row, $indata): array

$output['rows'][] = [
'uid' => $row['uid'],
'icon' => $this->iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL),
'icon' => $this->iconFactory->getIconForRecord('tt_content', $row, IconSize::SMALL),
'header' => $row['header'],
'CType' => $row['CType'],
'list_type' => $row['list_type'],
Expand Down
Loading