From: joshuaruesweg Date: Sat, 23 May 2020 18:01:07 +0000 (+0200) Subject: Add condition for user with(out) confirmed email addresses X-Git-Tag: 5.3.0_Alpha_1~182^2~19 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6c9d78ea501a6a8f61c2438b1e2d522c38b7cac;p=GitHub%2FWoltLab%2FWCF.git Add condition for user with(out) confirmed email addresses --- diff --git a/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php index 013409ff56..b2336559a3 100644 --- a/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php @@ -47,6 +47,19 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten */ protected $userIsNotBanned = 0; + /** + * true if the the user is be email confirmed + * + * @var integer + */ + protected $userIsEmailConfirmed = 0; + + /** + * true if the the user is not be email confirmed + * @var integer + */ + protected $userIsNotEmailConfirmed = 0; + /** * @inheritDoc */ @@ -67,6 +80,15 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten $objectList->getConditionBuilder()->add('user_table.activationCode <> ?', [0]); } } + + if (isset($conditionData['userIsEmailConfirmed'])) { + if ($conditionData['userIsEmailConfirmed']) { + $objectList->getConditionBuilder()->add('user_table.emailConfirmed IS NULL'); + } + else { + $objectList->getConditionBuilder()->add('user_table.emailConfirmed IS NOT NULL'); + } + } } /** @@ -90,6 +112,17 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten } } + /** @noinspection PhpUndefinedFieldInspection */ + $userIsEmailConfirmed = $condition->userIsEmailConfirmed; + if ($userIsEmailConfirmed !== null) { + if ($userIsEmailConfirmed && !$user->isEmailConfirmed()) { + return false; + } + else if (!$userIsEmailConfirmed && $user->isEmailConfirmed()) { + return false; + } + } + return true; } @@ -111,6 +144,12 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten else if ($this->userIsDisabled) { $data['userIsEnabled'] = 0; } + if ($this->userIsEmailConfirmed) { + $data['userIsEmailConfirmed'] = 1; + } + else if ($this->userIsNotEmailConfirmed) { + $data['userIsEmailConfirmed'] = 0; + } if (!empty($data)) { return $data; @@ -142,12 +181,16 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten $userIsBanned = WCF::getLanguage()->get('wcf.user.condition.state.isBanned'); $userIsDisabled = WCF::getLanguage()->get('wcf.user.condition.state.isDisabled'); $userIsEnabled = WCF::getLanguage()->get('wcf.user.condition.state.isEnabled'); + $userIsEmailConfirmed = WCF::getLanguage()->get('wcf.user.condition.state.isEmailConfirmed'); + $userIsNotEmailConfirmed = WCF::getLanguage()->get('wcf.user.condition.state.isNotEmailConfirmed'); return <<getCheckedAttribute('userIsBanned')}> {$userIsBanned} + + HTML; } @@ -159,6 +202,8 @@ HTML; if (isset($_POST['userIsDisabled'])) $this->userIsDisabled = 1; if (isset($_POST['userIsEnabled'])) $this->userIsEnabled = 1; if (isset($_POST['userIsNotBanned'])) $this->userIsNotBanned = 1; + if (isset($_POST['userIsEmailConfirmed'])) $this->userIsEmailConfirmed = 1; + if (isset($_POST['userIsNotEmailConfirmed'])) $this->userIsNotEmailConfirmed = 1; } /** @@ -169,6 +214,8 @@ HTML; $this->userIsDisabled = 0; $this->userIsEnabled = 0; $this->userIsNotBanned = 0; + $this->userIsEmailConfirmed = 0; + $this->userIsNotEmailConfirmed = 0; } /** @@ -188,6 +235,13 @@ HTML; $this->userIsEnabled = $userIsEnabled; $this->userIsDisabled = !$userIsEnabled; } + + /** @noinspection PhpUndefinedFieldInspection */ + $userIsEmailConfirmed = $condition->userIsEmailConfirmed; + if ($condition->userIsEmailConfirmed !== null) { + $this->userIsEmailConfirmed = $userIsEmailConfirmed; + $this->userIsNotEmailConfirmed = !$userIsEmailConfirmed; + } } /** @@ -205,6 +259,12 @@ HTML; throw new UserInputException('userIsEnabled', 'conflict'); } + + if ($this->userIsEmailConfirmed && $this->userIsNotEmailConfirmed) { + $this->errorMessage = 'wcf.user.condition.state.isEmailConfirmed.error.conflict'; + + throw new UserInputException('userIsEmailConfirmed', 'conflict'); + } } /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 91e580143e..0d67613385 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -4958,6 +4958,9 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email} + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index b61535a7ca..9992478084 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -4953,6 +4953,9 @@ Open the link below to access the user profile: + + +