From d3099e13414c28ba935564f2c6591f5d2c297ae1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 18 Feb 2021 14:04:18 +0100 Subject: [PATCH] Add filter to EmailLogListPage --- .../files/acp/templates/emailLogList.tpl | 56 +++++++++++++++++-- .../lib/acp/page/EmailLogListPage.class.php | 56 +++++++++++++++++++ 2 files changed, 107 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/emailLogList.tpl b/wcfsetup/install/files/acp/templates/emailLogList.tpl index 231ce7b907..7240e4cef3 100644 --- a/wcfsetup/install/files/acp/templates/emailLogList.tpl +++ b/wcfsetup/install/files/acp/templates/emailLogList.tpl @@ -16,9 +16,55 @@ {/hascontent} +
+
+

{lang}wcf.global.filter{/lang}

+ +
+
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ {hascontent}
- {content}{pages print=true assign=pagesLinks controller="EmailLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content} + {content} + {pages print=true assign=pagesLinks controller="EmailLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder&$filterParameter"} + {/content}
{/hascontent} @@ -27,11 +73,11 @@ - + - - + + {event name='columnHeads'} @@ -52,7 +98,7 @@ {$entry->getRedactedRecipientAddress()} {/if} {if $entry->getRecipient()} - ({$entry->getRecipient()->getTitle()}) + ({$entry->getRecipient()->getTitle()}) {/if} diff --git a/wcfsetup/install/files/lib/acp/page/EmailLogListPage.class.php b/wcfsetup/install/files/lib/acp/page/EmailLogListPage.class.php index 0f710c2f40..e1ae17ab47 100644 --- a/wcfsetup/install/files/lib/acp/page/EmailLogListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/EmailLogListPage.class.php @@ -3,8 +3,10 @@ namespace wcf\acp\page; use wcf\data\email\log\entry\EmailLogEntryList; +use wcf\data\user\User; use wcf\page\SortablePage; use wcf\system\cache\runtime\UserRuntimeCache; +use wcf\system\WCF; /** * Shows email logs. @@ -53,6 +55,14 @@ class EmailLogListPage extends SortablePage */ public $objectListClassName = EmailLogEntryList::class; + /** + * @var array + */ + public $filter = [ + 'username' => null, + 'status' => null, + ]; + /** * @inheritDoc */ @@ -63,4 +73,50 @@ class EmailLogListPage extends SortablePage $userIDs = \array_filter(\array_column($this->objectList->getObjects(), 'recipientID')); UserRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } + + /** + * @inheritDoc + */ + public function readParameters() + { + parent::readParameters(); + + if (isset($_REQUEST['filter']) && \is_array($_REQUEST['filter'])) { + foreach ($_REQUEST['filter'] as $key => $value) { + if (\array_key_exists($key, $this->filter)) { + $this->filter[$key] = $value; + } + } + } + } + + /** + * @inheritDoc + */ + protected function initObjectList() + { + parent::initObjectList(); + + if (!empty($this->filter['username'])) { + $this->objectList->getConditionBuilder()->add('recipientID = ?', [ + User::getUserByUsername($this->filter['username'])->userID, + ]); + } + if (!empty($this->filter['status'])) { + $this->objectList->getConditionBuilder()->add('status = ?', [$this->filter['status']]); + } + } + + /** + * @inheritDoc + */ + public function assignVariables() + { + parent::assignVariables(); + + WCF::getTPL()->assign([ + 'filter' => $this->filter, + 'filterParameter' => \http_build_query(['filter' => $this->filter], '', '&'), + ]); + } } -- 2.20.1
{lang}wcf.global.objectID{/lang}{lang}wcf.global.objectID{/lang} {lang}wcf.acp.email.log.subject{/lang} {lang}wcf.user.email{/lang}{lang}wcf.acp.email.log.time{/lang}{lang}wcf.acp.email.log.status{/lang}{lang}wcf.acp.email.log.time{/lang}{lang}wcf.acp.email.log.status{/lang}
{@$entry->time|time}