#4283 Added UserMemberSince.php class for virtual field. Init UserMemberSince in BaseType.php class

This commit is contained in:
Master_Hans 2020-10-02 09:17:27 +03:00
parent bf50021e8a
commit 29d4d1f24e
2 changed files with 36 additions and 0 deletions

View File

@ -86,6 +86,7 @@ class BaseType extends Model
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'),
UserMemberSince::class => Yii::t('UserModule.profile', 'User member since'),
], $this->fieldTypes);
return $fieldTypes;

View File

@ -0,0 +1,35 @@
<?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;
/**
* UserEmail is a virtual profile field
* that displays the user member since information
*
* @since 1.6
*/
class UserMemberSince extends BaseTypeVirtual
{
/**
* @inheritDoc
*/
public function getVirtualUserValue($user, $raw = true)
{
if (empty($user->created_at)) {
return '';
}
if ($raw) {
return Html::encode($user->created_at);
}
}
}