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

[TASK] Updating mail queue with more infos on queue entry date and last sent timestamp

parent 562a1fe4
......@@ -109,6 +109,11 @@ class Mail extends AbstractEntity {
*/
protected $sendingTime = 0;
/**
* @var int
*/
protected $lastSendingTime = 0;
/**
* @return string
*/
......@@ -297,6 +302,20 @@ class Mail extends AbstractEntity {
$this->sendingTime = $sendingTime;
}
/**
* @return int
*/
public function getLastSendingTime() {
return $this->lastSendingTime;
}
/**
* @param int $sendingTime
*/
public function setLastSendingTime($sendingTime) {
$this->lastSendingTime = $sendingTime;
}
/**
* @return int
*/
......
......@@ -334,7 +334,7 @@ class MailTemplateService {
$temporaryMarkerArray[$markerPathSegment] = $marker['value'];
}
} else {
$temporaryMarkerArray = [ $markerPathSegment => $temporaryMarkerArray];
$temporaryMarkerArray = [$markerPathSegment => $temporaryMarkerArray];
}
}
$previewMarker = array_merge_recursive($previewMarker, $temporaryMarkerArray);
......@@ -375,9 +375,10 @@ class MailTemplateService {
$this->mailMessage->setBody($emailBody, 'text/html');
$this->mailMessage->send();
$dateTime = new DateTime();
$currentTimestamp = $dateTime->getTimestamp();
$this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority,
$dateTime->getTimestamp(), TRUE
$currentTimestamp, TRUE, $currentTimestamp
);
} else {
......@@ -396,11 +397,13 @@ class MailTemplateService {
* @param string $emailBody
* @param int $sendingTime
* @param int $priority
* @param int $lastSendingTime
* @param bool $sent
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/
private function addMailToMailQueue(
$extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE
$extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE,
$lastSendingTime = 0
) {
$mail = $this->objectManager->get(Mail::class);
$mail->setExtensionKey($extensionKey);
......@@ -415,6 +418,7 @@ class MailTemplateService {
$mail->setCcAddresses($this->ccAddresses);
$mail->setSent($sent);
$mail->setSendingTime($sendingTime);
$mail->setLastSendingTime($lastSendingTime);
$mail->setReplyTo($this->replyToAddress);
$pageUid = (int) GeneralUtility::_GP('id');
......@@ -439,7 +443,6 @@ class MailTemplateService {
$mailToSend = $mailRepository->findOneByUid($uid);
if ($mailToSend) {
$this->mailMessage->setBody($mailToSend->getMailBody(), 'text/html');
$this->mailMessage->setTo($mailToSend->getToAddress());
$this->mailMessage->setFrom($mailToSend->getFromAddress(), $mailToSend->getFromName());
......@@ -457,12 +460,13 @@ class MailTemplateService {
$this->mailMessage->setReplyTo($mailToSend->getReplyTo());
}
$dateTime = new DateTime();
$mailToSend->setLastSendingTime($dateTime->getTimestamp());
$this->mailMessage->send();
if (!$mailToSend->getSent()) {
$mailToSend->setSent(TRUE);
$mailRepository->update($mailToSend);
}
$mailRepository->update($mailToSend);
}
}
......
......@@ -32,7 +32,7 @@ return [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'searchFields' => 'mail_subject, mail_body, to_address, from_address, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id',
'searchFields' => 'mail_subject, mail_body, to_address, from_address, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id, sending_time, last_sending_time',
'dividers2tabs' => TRUE,
'delete' => 'deleted',
'enablecolumns' => [
......@@ -42,11 +42,11 @@ return [
'iconfile' => 'EXT:sg_mail/Resources/Public/Icons/ModuleIconTCA.svg'
],
'interface' => [
'showRecordFieldList' => 'hidden, mail_subject, mail_body, to_address, from_address, sent, priority, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id',
'showRecordFieldList' => 'hidden, mail_subject, mail_body, to_address, from_address, sent, priority, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id, sending_time, last_sending_time',
],
'types' => [
'1' => [
'showitem' => 'hidden;;1, sent, priority, to_address, from_address, mail_subject, mail_body, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id'
'showitem' => 'hidden;;1, sent, priority, to_address, from_address, mail_subject, mail_body, from_name, bcc_addresses, cc_addresses, extension_key, template_name, site_root_id, sending_time, last_sending_time'
],
],
'columns' => [
......@@ -151,6 +151,13 @@ return [
'type' => 'input'
],
],
'last_sending_time' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_mail.last_sending_time',
'config' => [
'type' => 'input'
],
],
'reply_to' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_mail.reply_to',
......
......@@ -41,10 +41,18 @@
<source>Email</source>
<target>E-Mail</target>
</trans-unit>
<trans-unit id="backend.entry_date" approved="yes">
<source>Queue entry date</source>
<target>Erstellungsdatum</target>
</trans-unit>
<trans-unit id="backend.failure_mail" approved="yes">
<source>There was an error when sending the preview email. Please check your configuration.</source>
<target>Ein Fehler ist aufgetreten. Bitte überprüfen Sie die Konfiguration.</target>
</trans-unit>
<trans-unit id="backend.from" approved="yes">
<source>from</source>
<target>Absender</target>
</trans-unit>
<trans-unit id="backend.fromAddress" approved="yes">
<source>Sender Email Address</source>
<target>Absender-E-Mail-Adresse</target>
......@@ -57,6 +65,10 @@
<source>Sender Name</source>
<target>Absender-Name</target>
</trans-unit>
<trans-unit id="backend.last_sent" approved="yes">
<source>Last sent</source>
<target>Letzter Versand</target>
</trans-unit>
<trans-unit id="backend.mail_queue" approved="yes">
<source>Mail Queue</source>
<target>Mail-Queue</target>
......@@ -161,6 +173,10 @@
<source>The template was resetted successfully.</source>
<target>Das Template erfolgreich zurückgesetzt.</target>
</trans-unit>
<trans-unit id="backend.to" approved="yes">
<source>to</source>
<target>Empfänger</target>
</trans-unit>
<trans-unit id="backend.toAddress" approved="yes">
<source>Receiver</source>
<target>Empfänger</target>
......
......@@ -33,6 +33,10 @@
<source>Sender Name</source>
<target>Absender-Name</target>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_mail.last_sending_time" approved="yes">
<source>Last sent</source>
<target>Letzer Versand</target>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_mail.mail_body" approved="yes">
<source>Mail text</source>
<target>Mail-Text</target>
......
......@@ -33,9 +33,15 @@
<trans-unit id="backend.email">
<source>Email</source>
</trans-unit>
<trans-unit id="backend.entry_date">
<source>Queue entry date</source>
</trans-unit>
<trans-unit id="backend.failure_mail">
<source>There was an error when sending the preview email. Please check your configuration.</source>
</trans-unit>
<trans-unit id="backend.from">
<source>from</source>
</trans-unit>
<trans-unit id="backend.fromAddress">
<source>Sender Email Address</source>
</trans-unit>
......@@ -45,6 +51,9 @@
<trans-unit id="backend.fromName">
<source>Sender Name</source>
</trans-unit>
<trans-unit id="backend.last_sent">
<source>Last sent</source>
</trans-unit>
<trans-unit id="backend.mail_queue">
<source>Mail Queue</source>
</trans-unit>
......@@ -123,6 +132,9 @@
<trans-unit id="backend.template_reset">
<source>The template was resetted successfully.</source>
</trans-unit>
<trans-unit id="backend.to">
<source>to</source>
</trans-unit>
<trans-unit id="backend.toAddress">
<source>Receiver</source>
</trans-unit>
......
......@@ -27,6 +27,9 @@
<trans-unit id="tx_sgmail_domain_model_mail.from_name">
<source>Sender Name</source>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_mail.last_sending_time">
<source>Last sent</source>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_mail.mail_body">
<source>Mail text</source>
</trans-unit>
......
......@@ -6,13 +6,27 @@
</f:section>
<f:section name="content">
<f:flashMessages/>
<f:flashMessages />
<f:if condition="{queue -> f:count()} > 0">
<f:then>
<div class="panel panel-default recordlist">
<div class="table-fit">
<table data-table="tx_sgmail_domain_model_mail" class="table table-striped table-hover">
<sgm:backend.widget.paginate objects="{queue}" as="paginatedMails" configuration="{insertAbove: 1, itemsPerPage: 20}">
<thead>
<tr>
<th></th>
<th><f:translate key="backend.from" /></th>
<th><f:translate key="backend.to" /></th>
<th><f:translate key="backend.subject" /></th>
<th><f:translate key="backend.entry_date" /></th>
<th><f:translate key="backend.sending_time" /></th>
<th><f:translate key="backend.last_sent" /></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<f:for each="{paginatedMails}" as="mail">
{sgm:backend.editOnClick(table: 'tx_sgmail_domain_model_mail', uid: mail.uid) -> sgm:set(name: 'editOnClick') -> f:format.raw()}
......@@ -24,9 +38,24 @@
</td>
<td nowrap="nowrap">
<a href="#" onclick="{editOnClick}">
<span>{mail.from_address} -> {mail.to_address}, {mail.mail_subject}</span>
<span>{mail.from_address}</span>
</a>
</td>
<td>
<span>{mail.to_address}</span>
</td>
<td>
<span>{mail.mail_subject}</span>
</td>
<td>
<span><f:format.date format="d.m.Y h:i">{mail.tstamp}</f:format.date></span>
</td>
<td>
<span><f:format.date format="d.m.Y h:i">{mail.sending_time}</f:format.date></span>
</td>
<td>
<span><f:format.date format="d.m.Y h:i">{mail.last_sending_time}</f:format.date></span>
</td>
<td nowrap="nowrap" class="col-control">
<f:format.raw>
<sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" />
......
......@@ -15,6 +15,7 @@ CREATE TABLE tx_sgmail_domain_model_mail (
template_name varchar(30) DEFAULT '' NOT NULL,
reply_to varchar(30) DEFAULT '' NOT NULL,
sending_time int(11) unsigned DEFAULT '0' NOT NULL,
last_sending_time int(11) unsigned DEFAULT '0' NOT NULL,
site_root_id int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment