Merge pull request #3670 from githubjeka/trim-username

Trim function for username
This commit is contained in:
Lucas Bartholemy 2019-10-03 18:45:17 +02:00 committed by GitHub
commit 897a28afd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -74,6 +74,7 @@ class Profile extends ActiveRecord
public function rules()
{
$rules = [
[['firstname', 'lastname'], 'trim'],
[['user_id'], 'required'],
[['user_id'], 'integer'],
];
@ -206,7 +207,10 @@ class Profile extends ActiveRecord
'elements' => [],
];
foreach (ProfileField::find()->orderBy('sort_order')->where(['profile_field_category_id' => $profileFieldCategory->id])->all() as $profileField) {
foreach (
ProfileField::find()->orderBy('sort_order')
->where(['profile_field_category_id' => $profileFieldCategory->id])->all() as $profileField
) {
/** @var ProfileField $profileField */
$profileField->editable = true;
@ -293,8 +297,8 @@ class Profile extends ActiveRecord
if ($this->user !== null) {
$query = ProfileField::find()
->where(['visible' => 1])
->orderBy('sort_order');
->where(['visible' => 1])
->orderBy('sort_order');
if ($category !== null) {
$query->andWhere(['profile_field_category_id' => $category->id]);

View File

@ -93,7 +93,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
/**
* A initial group for the user assigned while registration.
* @var type
* @var string|int
*/
public $registrationGroupId = null;
@ -109,7 +109,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
/**
*
* @var type
* @var string
*/
public $defaultRoute = '/user/profile';
@ -130,6 +130,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
$userModule = Yii::$app->getModule('user');
return [
[['username', 'email'], 'trim'],
[['username'], 'required'],
[['status', 'created_by', 'updated_by', 'visibility'], 'integer'],
[['status', 'visibility'], 'integer'],
@ -170,7 +171,6 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
*/
public function __get($name)
{
if ($name == 'super_admin') {
/**
* Replacement for old super_admin flag version
@ -440,6 +440,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
/**
* Before Save Addons
*
* @param bool $insert
* @return bool
*/
public function beforeSave($insert)
@ -472,6 +473,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
/**
* After Save Addons
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{