Enh: Added virtual profile fields to display users e-mail address and username

This commit is contained in:
Lucas Bartholemy 2020-07-13 10:20:43 +02:00
parent b24cc27add
commit 8a36eab616
3 changed files with 35 additions and 0 deletions

View File

@ -18,3 +18,4 @@ HumHub Change Log
- Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:emptyResult()` helper to manage render state of JsInputWidget
- Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:field` in order to access ActiveField instances within JsInputWidget
- Enh #4216: Added `humhub\modules\ui\filter\widgets\DropdownFilterInput` in order to support dropdown stream filters
- Enh: Added virtual profile fields to display users e-mail address and username

View File

@ -85,6 +85,7 @@ class BaseType extends Model
Checkbox::class => Yii::t('UserModule.profile', 'Checkbox'),
CheckboxList::class => Yii::t('UserModule.profile', 'Checkbox List'),
UserEmail::class => Yii::t('UserModule.profile', 'E-mail address of the user'),
UserName::class => Yii::t('UserModule.profile', 'Username'),
], $this->fieldTypes);
return $fieldTypes;

View File

@ -0,0 +1,33 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2020 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\user\models\fieldtype;
use humhub\libs\Html;
/**
* UserName is a virtual profile field
* that displays the current user name of the user.
*
* @since 1.6
*/
class UserName extends BaseTypeVirtual
{
/**
* @inheritDoc
*/
public function getVirtualUserValue($user, $raw = true)
{
if (empty($user->username)) {
return '';
}
return Html::encode($user->username);
}
}