mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 06:08:21 +01:00
Fix visibility of email requiring on backoffice add user form (#5264)
This commit is contained in:
parent
6c0afe347e
commit
9ad36945ac
@ -19,6 +19,7 @@ HumHub Changelog
|
|||||||
- Fix #5238: Typo in Offline Page Text
|
- Fix #5238: Typo in Offline Page Text
|
||||||
- Fix #5247: Fix translate with not defined language
|
- Fix #5247: Fix translate with not defined language
|
||||||
- Fix #5252: Removed "strong>" from the Dutch translations
|
- Fix #5252: Removed "strong>" from the Dutch translations
|
||||||
|
- Fix #5262: Fix visibility of email requiring on backoffice add user form
|
||||||
|
|
||||||
|
|
||||||
1.9.0 (July 22, 2021)
|
1.9.0 (July 22, 2021)
|
||||||
|
@ -36,7 +36,6 @@ use Yii;
|
|||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
use yii\db\Expression;
|
use yii\db\Expression;
|
||||||
use yii\db\Query;
|
|
||||||
use yii\web\IdentityInterface;
|
use yii\web\IdentityInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +142,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
/* @var $userModule \humhub\modules\user\Module */
|
/* @var $userModule Module */
|
||||||
$userModule = Yii::$app->getModule('user');
|
$userModule = Yii::$app->getModule('user');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -165,13 +164,32 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
|||||||
[['email'], 'unique'],
|
[['email'], 'unique'],
|
||||||
[['email'], 'email'],
|
[['email'], 'email'],
|
||||||
[['email'], 'string', 'max' => 150],
|
[['email'], 'string', 'max' => 150],
|
||||||
[['email'], 'required', 'when' => function ($model, $attribute) use ($userModule) {
|
[['email'], 'required', 'when' => function () {
|
||||||
return $userModule->emailRequired;
|
return $this->isEmailRequired();
|
||||||
}],
|
}],
|
||||||
[['guid'], 'unique'],
|
[['guid'], 'unique'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isEmailRequired(): bool
|
||||||
|
{
|
||||||
|
/* @var $userModule Module */
|
||||||
|
$userModule = Yii::$app->getModule('user');
|
||||||
|
return $userModule->emailRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function isAttributeRequired($attribute)
|
||||||
|
{
|
||||||
|
if ($attribute === 'email') {
|
||||||
|
return $this->isEmailRequired();
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::isAttributeRequired($attribute);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate attribute time zone
|
* Validate attribute time zone
|
||||||
* Force time zone to NULL if browser's time zone cannot be found on server side
|
* Force time zone to NULL if browser's time zone cannot be found on server side
|
||||||
|
Loading…
x
Reference in New Issue
Block a user