Squashed commit of the following:

commit 9c2061ca147cb5227130d4edb53d10342fc9e9ad
Merge: 6f4d2b0b2 f3640e874
Author: Lucas Bartholemy <lucas@bartholemy.com>
Date:   Mon Feb 14 18:18:30 2022 +0100

    Merge branch 'fix/5553-multiple-users-with-emailRequired-disabled' of https://github.com/KeudellCoding/humhub into KeudellCoding-fix/5553-multiple-users-with-emailRequired-disabled

commit f3640e874ec4f43c819fafd12d5a610828437f99
Author: KarlKeu00 <47644344+KarlKeu00@users.noreply.github.com>
Date:   Mon Feb 14 17:17:57 2022 +0100

    Undo some unnecessary changes

commit 34839b8dab975f7ef2887d1354bcce40381e94bd
Merge: 84033c092 3a02b7a44
Author: KarlKeu00 <47644344+KarlKeu00@users.noreply.github.com>
Date:   Mon Feb 14 17:08:49 2022 +0100

    Merge branch 'fix/5553-multiple-users-with-emailRequired-disabled' of https://github.com/KeudellCoding/humhub into fix/5553-multiple-users-with-emailRequired-disabled

commit 84033c092f5b805c1e1c06c671f848f56118f7c9
Author: KarlKeu00 <47644344+KarlKeu00@users.noreply.github.com>
Date:   Mon Feb 14 17:08:18 2022 +0100

    No need for random emails, fix regarding HForm

commit 3a02b7a44c88528f32b325fc816c9f02ed6ef3e2
Merge: 9d235b0ee 12ea7da5b
Author: KarlKeu00 <47644344+KarlKeu00@users.noreply.github.com>
Date:   Mon Feb 14 12:05:59 2022 +0100

    Merge branch 'develop' into fix/5553-multiple-users-with-emailRequired-disabled

commit 9d235b0eec694f30ad8e7e35ac2afa1025196a04
Author: KarlKeu00 <47644344+KarlKeu00@users.noreply.github.com>
Date:   Sun Feb 13 14:52:31 2022 +0100

    Improved support of the emailRequired property
This commit is contained in:
Lucas Bartholemy 2022-02-14 18:20:13 +01:00
parent 6f4d2b0b25
commit cb000a1f72
3 changed files with 13 additions and 3 deletions

3
.gitignore vendored
View File

@ -24,6 +24,7 @@ uploads/profile_image/banner/*
nbproject
.idea/*
.gitmodules
.vscode
themes/*
!themes/HumHub
@ -38,3 +39,5 @@ favicon.ico
**/tests/codeception/_output/**
/.php_cs.cache
.DS_Store

View File

@ -18,3 +18,4 @@
- Fix #5478: Avoid permalinks on comments related to a global content (not in a container) to crash.
- Fix #5549: Topic icon is missing in TopicPicker search
- Fix #5556: Formatted output for date fields in "About me" profile area.
- Fix #5553: Cannot have two or more users without email when emailRequired is disabled.

View File

@ -166,12 +166,14 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
[['email'], 'unique'],
[['email'], 'email'],
[['email'], 'string', 'max' => 150],
[['email'], 'required', 'when' => function () {
return $this->isEmailRequired();
}],
[['guid'], 'unique'],
[['username'], 'validateForbiddenUsername', 'on' => [self::SCENARIO_REGISTRATION]],
];
if ($this->isEmailRequired()) // HForm does not support 'required' in combination with 'when'.
$rules[] = [['email'], 'required'];
return $rules;
}
public function isEmailRequired(): bool
@ -546,6 +548,10 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
$this->time_zone = Yii::$app->settings->get('defaultTimeZone');
}
if (empty($this->email)) {
$this->email = new \yii\db\Expression('NULL');
}
return parent::beforeSave($insert);
}