Skip to content

Commit

Permalink
use array instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Neyman committed Dec 31, 2022
1 parent 9016190 commit 6c824ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
11 changes: 5 additions & 6 deletions Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,15 @@ public function sendAdvanced(array $recipRow, string $tableNameChar): int
/**
* Send a simple email (without personalizing)
*
* @param string $addressList list of recipient address, comma list of emails
* @param array $recipients list of recipient address
*
* @return bool
*/
public function sendSimple(string $addressList): bool
public function sendSimple(array $recipients): bool
{
$this->theParts['html']['content'] = ($this->theParts['html']['content'] ?? false) ? $this->getBoundaryParts($this->dmailer['boundaryParts_html'], -1) : '';
$this->theParts['plain']['content'] = ($this->theParts['plain']['content'] ?? false) ? $this->getBoundaryParts($this->dmailer['boundaryParts_plain'], -1) : '';

$recipients = explode(',', $addressList);
if(count($recipients)) {
foreach ($recipients as $recipient) {
$this->sendTheMail($recipient);
Expand Down Expand Up @@ -830,7 +829,7 @@ public function start(): void
if (!$this->nonCron) {
$this->logger->debug('Starting directmail cronjob');
// write this temp file for checking the engine in the status module
$this->dmailer_log('starting directmail cronjob');
$this->dmailerLog('starting directmail cronjob');
}
}

Expand All @@ -849,7 +848,7 @@ protected function setContent(&$mailer): void
$this->extractMediaLinks();
foreach ($this->theParts['html']['media'] as $media) {
// TODO: why are there table related tags here?
if (($media['tag'] === 'img' || $media['tag'] === 'table' || $media['tag'] === 'tr' || $media['tag'] === 'td') && !$media['use_jumpurl'] && !$media['do_not_embed']) {
if (in_array($media['tag'], ['img', 'table', 'tr', 'td'], true) && !$media['use_jumpurl'] && !$media['do_not_embed']) {
if (ini_get('allow_url_fopen')) {
$context = null;
$applicationContext = Environment::getContext();
Expand Down Expand Up @@ -1076,7 +1075,7 @@ protected function substHREFsInHTML(): void
*
* @param string $logMsg Log message
*/
protected function dmailer_log(string $logMsg): void
protected function dmailerLog(string $logMsg): void
{
$content = time() . ' => ' . $logMsg . LF;
$logfilePath = Environment::getPublicPath() . '/typo3temp/tx_directmail_dmailer_log.txt';
Expand Down
17 changes: 11 additions & 6 deletions Classes/Module/DmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1150,15 +1150,14 @@ protected function sendMail($row)
}
$hash = array_flip($addresses);
$addresses = array_keys($hash);
$addressList = implode(',', $addresses);

if ($addressList) {
if (count($addresses)) {
// Sending the same mail to lots of recipients
$htmlmail->sendSimple($addressList);
$htmlmail->sendSimple($addresses);
$sentFlag = true;
$message = $this->createFlashMessage(
$this->getLanguageService()->getLL('send_was_sent') . ' ' .
$this->getLanguageService()->getLL('send_recipients') . ' ' . htmlspecialchars($addressList),
$this->getLanguageService()->getLL('send_recipients') . ' ' . htmlspecialchars(implode(',', $addresses)),
$this->getLanguageService()->getLL('send_sending'),
0,
false
Expand Down Expand Up @@ -1257,7 +1256,10 @@ protected function sendMail($row)
$sectionTitle = $this->getLanguageService()->getLL('send_was_scheduled');
}
$sentFlag = true;
$done = GeneralUtility::makeInstance(SysDmailRepository::class)->updateSysDmailRecord((int)$this->sys_dmail_uid, $updateFields);
$done = GeneralUtility::makeInstance(SysDmailRepository::class)->updateSysDmailRecord(
(int)$this->sys_dmail_uid,
$updateFields
);

$message = $this->createFlashMessage(
$sectionTitle . ' ' . $content,
Expand All @@ -1271,7 +1273,10 @@ protected function sendMail($row)

// Setting flags and update the record:
if ($sentFlag && $this->cmd == 'send_mail_final') {
$done = GeneralUtility::makeInstance(SysDmailRepository::class)->updateSysDmailRecord((int)$this->sys_dmail_uid, ['issent' => 1]);
$done = GeneralUtility::makeInstance(SysDmailRepository::class)->updateSysDmailRecord(
(int)$this->sys_dmail_uid,
['issent' => 1]
);
}
}

Expand Down

0 comments on commit 6c824ec

Please sign in to comment.