From c6a588feb5661e4736026cb0870c9ce428a52356 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Sun, 22 Nov 2020 12:03:34 +0100 Subject: [PATCH] Add usesMultifactor condition for user search in acp --- com.woltlab.wcf/objectType.xml | 6 ++++ .../UserMultifactorCondition.class.php | 32 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 0a015a876e..2b70815363 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1457,6 +1457,12 @@ wcf\system\condition\UserOptionsCondition userOptions + + com.woltlab.wcf.user.multifactor + com.woltlab.wcf.condition.userSearch + wcf\system\condition\UserMultifactorCondition + general + diff --git a/wcfsetup/install/files/lib/system/condition/UserMultifactorCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserMultifactorCondition.class.php index cfec88c676..6276c2465c 100644 --- a/wcfsetup/install/files/lib/system/condition/UserMultifactorCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserMultifactorCondition.class.php @@ -1,6 +1,10 @@ usesMultifactor && WCF::getUser()->multifactorActive) || (!$condition->usesMultifactor && !WCF::getUser()->multifactorActive)); } + + /** + * @inheritDoc + */ + public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { + if (!($objectList instanceof UserList)) { + throw new InvalidObjectArgument($objectList, UserList::class, 'Object list'); + } + + if (isset($conditionData['usesMultifactor'])) { + $objectList->getConditionBuilder()->add('user_table.multifactorActive = ?', [$conditionData['usesMultifactor']]); + } + } + + /** + * @inheritDoc + */ + public function checkUser(Condition $condition, User $user) { + if ($condition->usesMultifactor !== null && $user->multifactorActive != $condition->usesMultifactor) { + return false; + } + + return true; + } } -- 2.20.1