From a5cb5c48e69e7399e91002d38ca1a33e115dfa7e Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Sun, 4 Apr 2021 22:23:09 +0200 Subject: [PATCH] Add acp user email search --- .../acp/UserACPSearchResultProvider.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/search/acp/UserACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/UserACPSearchResultProvider.class.php index e846b105d3..8b1ffd8964 100644 --- a/wcfsetup/install/files/lib/system/search/acp/UserACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/UserACPSearchResultProvider.class.php @@ -4,14 +4,15 @@ namespace wcf\system\search\acp; use wcf\data\user\group\UserGroup; use wcf\data\user\User; +use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\request\LinkHandler; use wcf\system\WCF; /** * ACP search result provider implementation for users. * - * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH + * @author Joshua Ruesweg, Matthias Schmidt + * @copyright 2001-2021 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Search\Acp */ @@ -26,13 +27,20 @@ class UserACPSearchResultProvider implements IACPSearchResultProvider return []; } - $results = []; + $conditionBuilder = new PreparedStatementConditionBuilder(true, 'OR'); + $conditionBuilder->add("username LIKE ?", [[$query . '%']]); + + if (WCF::getSession()->getPermission('admin.user.canEditMailAddress')) { + $conditionBuilder->add("email LIKE ?", [[$query . '%']]); + } $sql = "SELECT * FROM wcf" . WCF_N . "_user - WHERE username LIKE ?"; + " . $conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$query . '%']); + $statement->execute($conditionBuilder->getParameters()); + + $results = []; /** @var User $user */ while ($user = $statement->fetchObject(User::class)) { -- 2.20.1