Skip to content
Snippets Groups Projects
Commit f7030f1f authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Finishing filter for mail queue

parent 20a5a71d
No related branches found
No related tags found
1 merge request!3New version 4 1
......@@ -63,6 +63,7 @@ class QueueController extends ActionController {
* @param array $filters
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) {
$registerArray = MailTemplateService::getRegisterArray();
......@@ -73,7 +74,7 @@ class QueueController extends ActionController {
}
$siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId);
$queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId, 0, $filters);
// create doc header component
$pageUid = (int) GeneralUtility::_GP('id');
......
......@@ -33,6 +33,9 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
* Repository for the Mail object
*/
class MailRepository extends AbstractRepository {
const SENT = '1';
const NOT_SENT = '2';
/**
* Returns all mails that are still not sent ordered by priority.
*
......@@ -57,14 +60,39 @@ class MailRepository extends AbstractRepository {
* @param string $templateName
* @param int $siteroot
* @param int $limit
* @param array $filters
* @return array|QueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function findAllEntries($extensionKey, $templateName, $siteroot = 0, $limit = NULL) {
public function findAllEntries($extensionKey, $templateName, $siteroot = 0, $limit = NULL, array $filters = []) {
$query = $this->createQuery();
if ($limit) {
$query->setLimit($limit);
}
if ($filters['from']) {
$constraintsAnd[] = $query->like('from_address', '%' . trim($filters['from'] . '%'));
}
if ($filters['to']) {
$constraintsAnd[] = $query->like('to_address', '%' . trim($filters['to'] . '%'));
}
if ($filters['subject']) {
$constraintsAnd[] = $query->like('mail_subject', '%' . trim($filters['subject']) . '%');
}
if ($filters['sent']) {
switch ($filters['sent']) {
case self::SENT:
$constraintsAnd[] = $query->equals('sent', TRUE);
break;
case self::NOT_SENT:
$constraintsAnd[] = $query->equals('sent', FALSE);
break;
}
}
$constraintsAnd[] = $query->equals('extension_key', $extensionKey);
$constraintsAnd[] = $query->equals('template_name', $templateName);
$constraintsAnd[] = $query->equals('site_root_id', (int) $siteroot);
......
......@@ -19,12 +19,20 @@
</tr>
<tr>
<td>
<f:form.radio property="sent" id="filters-all" value="0" checked="{f:if(condition: '{filters.sent} == \'0\'', then: '1')}"/>
<f:translate key="backend.all" />
<f:form.radio property="sent" id="filters-sent" value="1" checked="{f:if(condition: '{filters.sent} == \'1\'', then: '1')}"/>
<f:translate key="backend.sent" />
<f:form.radio property="sent" id="filters-notsent" value="2" checked="{f:if(condition: '{filters.sent} == \'2\'', then: '1')}"/>
<f:translate key="backend.not_sent" />
<div class="radio">
<label class="radio-inline">
<f:form.radio property="sent" id="filters-all" value="0" checked="{f:if(condition: '{filters.sent} == \'0\'', then: '1')}" />
<f:translate key="backend.all" />
</label>
<label class="radio-inline">
<f:form.radio property="sent" id="filters-sent" value="1" checked="{f:if(condition: '{filters.sent} == \'1\'', then: '1')}" />
<f:translate key="backend.sent" />
</label>
<label class="radio-inline">
<f:form.radio property="sent" id="filters-notsent" value="2" checked="{f:if(condition: '{filters.sent} == \'2\'', then: '1')}" />
<f:translate key="backend.not_sent" />
</label>
</div>
</td>
</tr>
<tr>
......@@ -35,4 +43,4 @@
</tbody>
</table>
</f:form>
</div>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment