Commit 8b0c74f7 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Removing sent field, only using sending time

parent 59ab03a7
......@@ -64,11 +64,6 @@ class Mail extends AbstractEntity {
*/
protected $fromAddress = '';
/**
* @var bool
*/
protected $sent = FALSE;
/**
* @var int
*/
......@@ -174,21 +169,6 @@ class Mail extends AbstractEntity {
$this->fromAddress = $fromAddress;
}
/**
* @return bool
*/
public function getSent() {
return $this->sent;
}
/**
* @param bool $sent
* @return void
*/
public function setSent($sent) {
$this->sent = ($sent === TRUE);
}
/**
* @return int
*/
......
......@@ -87,20 +87,9 @@ class MailRepository extends AbstractRepository {
$constraintsAnd[] = $query->equals('language', $filters['filterLanguage']);
}
if ($filters['filterSent']) {
switch ($filters['filterSent']) {
case self::SENT:
$constraintsAnd[] = $query->equals('sent', TRUE);
break;
case self::NOT_SENT:
$constraintsAnd[] = $query->equals('sent', FALSE);
break;
}
}
$constraintsOr = [];
$search = '%' . $filters['filterSearch'] . '%';
if ($filters['filterFields'] && trim($filters['filterFields'] !== '')) {
if ($filters['filterFields'] && trim('' !== $filters['filterFields'])) {
foreach ($filters['filterFields'] as $field) {
switch ($field) {
case BackendService::SENDER_FILTER_OPTION :
......@@ -151,13 +140,13 @@ class MailRepository extends AbstractRepository {
$constraintsAnd[] = $query->lessThanOrEqual('last_sending_time', $toTime);
}
if ($filters['sent']) {
switch ($filters['sent']) {
if ($filters['filterSent']) {
switch ($filters['filterSent']) {
case self::SENT:
$constraintsAnd[] = $query->equals('sent', TRUE);
$constraintsAnd[] = $query->greaterThan('last_sending_time', 0);
break;
case self::NOT_SENT:
$constraintsAnd[] = $query->equals('sent', FALSE);
$constraintsAnd[] = $query->equals('last_sending_time', 0);
break;
}
}
......
......@@ -399,14 +399,14 @@ class MailTemplateService {
if (!$isPreview) {
$this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority,
$currentTimestamp, TRUE, $currentTimestamp, $this->language, $siteRootId
$currentTimestamp, $currentTimestamp, $this->language, $siteRootId
);
}
} else {
if (!$isPreview) {
$this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, 0, FALSE, 0,
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, 0, 0,
$this->language, $siteRootId
);
}
......@@ -427,11 +427,10 @@ class MailTemplateService {
* @param int $lastSendingTime
* @param string $language
* @param int $pid
* @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,
$lastSendingTime = 0, $language = 'en', $pid = 0
) {
$mail = $this->objectManager->get(Mail::class);
......@@ -447,7 +446,6 @@ class MailTemplateService {
$mail->setPriority($priority);
$mail->setBccAddresses($this->bccAddresses);
$mail->setCcAddresses($this->ccAddresses);
$mail->setSent($sent);
$mail->setSendingTime($sendingTime);
$mail->setLastSendingTime($lastSendingTime);
$mail->setReplyTo($this->replyToAddress);
......@@ -490,9 +488,6 @@ class MailTemplateService {
$dateTime = new DateTime();
$mailToSend->setLastSendingTime($dateTime->getTimestamp());
$this->mailMessage->send();
if (!$mailToSend->getSent()) {
$mailToSend->setSent(TRUE);
}
$mailRepository->update($mailToSend);
}
}
......
......@@ -38,15 +38,15 @@ return [
'enablecolumns' => [
'disabled' => 'hidden',
],
'default_sortby' => 'ORDER BY sent ASC, priority DESC',
'default_sortby' => 'ORDER BY priority DESC',
'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, sending_time, last_sending_time, language',
'showRecordFieldList' => 'hidden, 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',
],
'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, sending_time, last_sending_time, language'
'showitem' => 'hidden;;1, 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'
],
],
'columns' => [
......@@ -91,13 +91,6 @@ return [
'eval' => 'required, email'
],
],
'sent' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_mail.sent',
'config' => [
'type' => 'check',
],
],
'priority' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_mail.priority',
......
......@@ -30,84 +30,81 @@
<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()}
<f:if condition="{mail.sent}">
<f:then>
<tr data-uid="{mail.uid}">
</f:then>
<f:else>
<tr data-uid="{mail.uid}" class="recordlist-mail-unsent">
</f:else>
</f:if>
<td nowrap="nowrap" class="col-icon">
<f:format.raw><sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" /></f:format.raw>
</td>
<td>
<span>{mail.from_address}</span>
<hr>
<span>{mail.to_address}</span>
</td>
<td>
<span>{mail.extension_key}: {mail.template_name}</span>
<hr>
<f:if condition="{mail.mail_subject}">
<f:then>
<span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
<tr data-uid="{mail.uid}">
<td nowrap="nowrap" class="col-icon">
<f:format.raw>
<sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" />
</f:format.raw>
</td>
<td>
<span>{mail.from_address}</span>
<hr>
<span>{mail.to_address}</span>
</td>
<td>
<span>{mail.extension_key}: {mail.template_name}</span>
<hr>
<f:if condition="{mail.mail_subject}">
<f:then>
<span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
</td>
<td>
<span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span>
<hr>
<f:if condition="{mail.last_sending_time} != 0">
<f:then>
<span><f:format.date format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span>
</f:then>
<f:else>
<f:translate key="backend.not_sent" />
</f:else>
</f:if>
</td>
<td nowrap="nowrap" class="col-control">
<f:format.raw><sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" /></f:format.raw>
</td>
<td>
<f:link.action class="btn btn-default btn-send-now" controller="Queue" action="sendMail" arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}">
</td>
<td>
<span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span>
<hr>
<f:if condition="{mail.last_sending_time} != 0">
<f:then>
<span><f:format.date format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span>
</f:then>
<f:else>
<f:translate key="backend.not_sent" />
</f:else>
</f:if>
</td>
<td nowrap="nowrap" class="col-control">
<f:format.raw>
<sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" />
</f:format.raw>
</td>
<td>
<f:link.action class="btn btn-default btn-send-now" controller="Queue" action="sendMail" arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}">
<span class="t3js-icon icon icon-size-small icon-state-default actions-document-import-t3d">
<span class="icon-markup">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-import-t3d.svg" width="16" height="16">
</span>
</span>
<f:translate key="backend.send_now" />
</f:link.action>
<a class="btn btn-default btn-toggle" data-uid="{mail.uid}">
<f:translate key="backend.send_now" />
</f:link.action>
<a class="btn btn-default btn-toggle" data-uid="{mail.uid}">
<span class="t3js-icon icon icon-size-small icon-state-default actions-document-view">
<span class="icon-markup">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-view.svg" width="16" height="16">
</span>
</span>
<f:translate key="backend.showBody" />
</a>
</td>
<div class="modal fade" id="toggle-{mail.uid}" tabindex="-1" role="dialog" aria-labelledby="login-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="login-modal-label">{mail.mail_subject}</h4>
</div>
<div class="modal-body" id="login-modal-body">
<div class="modalcol modalcol-left">
<f:format.html>{mail.mail_body}</f:format.html>
<f:translate key="backend.showBody" />
</a>
</td>
<div class="modal fade" id="toggle-{mail.uid}" tabindex="-1" role="dialog" aria-labelledby="login-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="login-modal-label">{mail.mail_subject}</h4>
</div>
<div class="modal-body" id="login-modal-body">
<div class="modalcol modalcol-left">
<f:format.html>{mail.mail_body}</f:format.html>
</div>
</div>
</div>
</div>
</div>
</div>
</f:for>
</tbody>
</sgm:backend.widget.paginate>
......
......@@ -9,7 +9,6 @@ CREATE TABLE tx_sgmail_domain_model_mail (
from_name varchar(255) DEFAULT '' NOT NULL,
cc_addresses varchar(255) DEFAULT '' NOT NULL,
bcc_addresses varchar(255) DEFAULT '' NOT NULL,
sent tinyint(1) DEFAULT '0' NOT NULL,
priority int(11) unsigned DEFAULT '0' NOT NULL,
extension_key varchar(30) DEFAULT '' NOT NULL,
template_name varchar(30) DEFAULT '' 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