--- /dev/null
+<?php
+namespace wcf\system\condition;
+use wcf\data\condition\Condition;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+
+/**
+ * Condition implementation if it is the user has an active second factor.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Condition
+ * @since 5.4
+ */
+class UserMultifactorCondition extends AbstractSingleFieldCondition implements IContentCondition {
+ /**
+ * @inheritDoc
+ */
+ protected $label = 'wcf.user.condition.multifactor';
+
+ /**
+ * 1 if uses multifactor checkbox is checked
+ * @var integer
+ */
+ protected $usesMultifactor = 0;
+
+ /**
+ * 1 if uses no multifactor checkbox is checked
+ * @var integer
+ */
+ protected $usesNoMultifactor = 0;
+
+ /**
+ * @inheritDoc
+ */
+ public function getData() {
+ if ($this->usesMultifactor || $this->usesNoMultifactor) {
+ return [
+ // if usesNoMultifactor is selected usesMultifactor is 0
+ // otherwise usesNoMultifactor is 1
+ 'usesMultifactor' => $this->usesMultifactor
+ ];
+ }
+
+ return null;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFieldElement() {
+ $usesMultifactorLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.usesMultifactor');
+ $usesNoMultifactorLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.usesNoMultifactor');
+ $usesMultifactorChecked = '';
+ if ($this->usesMultifactor) {
+ $usesMultifactorChecked = ' checked';
+ }
+
+ $usesNoMultifactorChecked = '';
+ if ($this->usesNoMultifactor) {
+ $usesNoMultifactorChecked = ' checked';
+ }
+
+ return <<<HTML
+<label><input type="checkbox" name="usesMultifactor" id="usesMultifactor"{$usesMultifactorChecked}> {$usesMultifactorLabel}</label>
+<label><input type="checkbox" name="usesNoMultifactor" id="usesNoMultifactor"{$usesNoMultifactorChecked}> {$usesNoMultifactorLabel}</label>
+HTML;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function readFormParameters() {
+ if (isset($_POST['usesMultifactor'])) $this->usesMultifactor = 1;
+ if (isset($_POST['usesNoMultifactor'])) $this->usesNoMultifactor = 1;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function reset() {
+ $this->usesMultifactor = $this->usesNoMultifactor = 0;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setData(Condition $condition) {
+ $this->usesMultifactor = $condition->usesMultifactor;
+ $this->usesNoMultifactor = !$condition->usesMultifactor;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validate() {
+ if ($this->usesMultifactor && $this->usesNoMultifactor) {
+ $this->errorMessage = 'wcf.user.condition.multifactor.usesMultifactor.error.conflict';
+
+ throw new UserInputException('usesMultifactor', 'conflict');
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function showContent(Condition $condition) {
+ return (($condition->usesMultifactor && WCF::getUser()->multifactorActive) || (!$condition->usesMultifactor && !WCF::getUser()->multifactorActive));
+ }
+}
<item name="wcf.user.condition.mobileBrowser.usesMobileBrowser"><![CDATA[Verwendet mobilen Browser]]></item>
<item name="wcf.user.condition.mobileBrowser.usesMobileBrowser.error.conflict"><![CDATA[„Verwendet mobilen Browser“ und „Verwendet keinen mobilen Browser“ können nicht gleichzeitig ausgewählt werden.]]></item>
<item name="wcf.user.condition.mobileBrowser.usesNoMobileBrowser"><![CDATA[Verwendet keinen mobilen Browser]]></item>
+ <item name="wcf.user.condition.multifactor"><![CDATA[Mehrfaktor-Authentifizierung]]></item>
+ <item name="wcf.user.condition.multifactor.usesMultifactor"><![CDATA[Verwendet eine Mehrfaktor-Authentifizierung]]></item>
+ <item name="wcf.user.condition.multifactor.usesMultifactor.error.conflict"><![CDATA[„Verwendet die Mehrfaktor-Authentifizierung“ und „Verwendet keine Mehrfaktor-Authentifizierung“ können nicht gleichzeitig ausgewählt werden.]]></item>
+ <item name="wcf.user.condition.multifactor.usesNoMultifactor"><![CDATA[Verwendet keine Mehrfaktor-Authentifizierung]]></item>
<item name="wcf.user.condition.notGroupIDs"><![CDATA[nicht in Benutzergruppen]]></item>
<item name="wcf.user.condition.notGroupIDs.description"><![CDATA[Benutzer dürfen in keiner der ausgewählten Benutzergruppen Mitglied sein.]]></item>
<item name="wcf.user.condition.notGroupIDs.error.groupIDsIntersection"><![CDATA[Die ausgewählten Benutzergruppen in „in Benutzergruppen“ und „nicht in Benutzergruppen“ sind widersprüchlich.]]></item>
<item name="wcf.user.condition.mobileBrowser.usesMobileBrowser"><![CDATA[Uses mobile device]]></item>
<item name="wcf.user.condition.mobileBrowser.usesMobileBrowser.error.conflict"><![CDATA[You cannot simultaneously select “Uses mobile device” and “Uses desktop”.]]></item>
<item name="wcf.user.condition.mobileBrowser.usesNoMobileBrowser"><![CDATA[Uses desktop]]></item>
+ <item name="wcf.user.condition.multifactor"><![CDATA[Multi-Factor Authentication]]></item>
+ <item name="wcf.user.condition.multifactor.usesMultifactor"><![CDATA[Uses a Multi-Factor Authentication]]></item>
+ <item name="wcf.user.condition.multifactor.usesMultifactor.error.conflict"><![CDATA[You cannot simultaneously select “Uses a Multi-Factor Authentication” and “Uses no Multi-Factor Authentication”.]]></item>
+ <item name="wcf.user.condition.multifactor.usesNoMultifactor"><![CDATA[Uses no Multi-Factor Authentication]]></item>
<item name="wcf.user.condition.notGroupIDs"><![CDATA[User Not in User Group(s)]]></item>
<item name="wcf.user.condition.notGroupIDs.description"><![CDATA[User is not a member of the selected user group(s).]]></item>
<item name="wcf.user.condition.notGroupIDs.error.groupIDsIntersection"><![CDATA[The selected user group(s) in “User in User Group(s)” and “User Not in User Group(s)” are conflicting.]]></item>