mirror of
https://github.com/humhub/humhub.git
synced 2025-02-25 03:34:10 +01:00
Improved user display name sub text handling
This commit is contained in:
parent
7d67c7eb1a
commit
46c31b192d
@ -77,6 +77,11 @@ class Module extends \humhub\components\Module
|
|||||||
*/
|
*/
|
||||||
public $displayNameCallback = null;
|
public $displayNameCallback = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var callable a callback that returns the user displayName sub text
|
||||||
|
*/
|
||||||
|
public $displayNameSubCallback = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean defines if the user following is disabled or not.
|
* @var boolean defines if the user following is disabled or not.
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
|
@ -25,6 +25,7 @@ use humhub\modules\user\behaviors\Followable;
|
|||||||
use humhub\modules\user\behaviors\ProfileController;
|
use humhub\modules\user\behaviors\ProfileController;
|
||||||
use humhub\modules\user\components\ActiveQueryUser;
|
use humhub\modules\user\components\ActiveQueryUser;
|
||||||
use humhub\modules\user\events\UserEvent;
|
use humhub\modules\user\events\UserEvent;
|
||||||
|
use humhub\modules\user\Module;
|
||||||
use humhub\modules\user\widgets\UserWall;
|
use humhub\modules\user\widgets\UserWall;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
@ -55,6 +56,7 @@ use yii\web\IdentityInterface;
|
|||||||
* @property Profile $profile
|
* @property Profile $profile
|
||||||
*
|
*
|
||||||
* @property string $displayName
|
* @property string $displayName
|
||||||
|
* @property string $displayNameSub
|
||||||
*/
|
*/
|
||||||
class User extends ContentContainerActiveRecord implements IdentityInterface, Searchable
|
class User extends ContentContainerActiveRecord implements IdentityInterface, Searchable
|
||||||
{
|
{
|
||||||
@ -548,8 +550,11 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
|||||||
*/
|
*/
|
||||||
public function getDisplayName()
|
public function getDisplayName()
|
||||||
{
|
{
|
||||||
if (Yii::$app->getModule('user')->displayNameCallback !== null) {
|
/** @var Module $module */
|
||||||
return call_user_func(Yii::$app->getModule('user')->displayNameCallback, $this);
|
$module = Yii::$app->getModule('user');
|
||||||
|
|
||||||
|
if ($module->displayNameCallback !== null) {
|
||||||
|
return call_user_func($module->displayNameCallback, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = '';
|
$name = '';
|
||||||
@ -568,6 +573,29 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the users display name sub text.
|
||||||
|
* Per default as sub text the 'title' profile attribute is used
|
||||||
|
*
|
||||||
|
* @return string the display name sub text
|
||||||
|
*/
|
||||||
|
public function getDisplayNameSub()
|
||||||
|
{
|
||||||
|
/** @var Module $module */
|
||||||
|
$module = Yii::$app->getModule('user');
|
||||||
|
|
||||||
|
if ($module->displayNameSubCallback !== null) {
|
||||||
|
return call_user_func($module->displayNameSubCallback, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->profile !== null && $this->profile->hasAttribute('title')) {
|
||||||
|
return $this->profile->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this user is the current logged in user.
|
* Checks if this user is the current logged in user.
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
@ -28,7 +28,7 @@ $userModel = Yii::$app->user->getIdentity();
|
|||||||
|
|
||||||
<?php if ($this->context->showUserName): ?>
|
<?php if ($this->context->showUserName): ?>
|
||||||
<div class="user-title pull-left hidden-xs">
|
<div class="user-title pull-left hidden-xs">
|
||||||
<strong><?= Html::encode($userModel->displayName); ?></strong><br/><span class="truncate"><?= Html::encode($userModel->profile->title); ?></span>
|
<strong><?= Html::encode($userModel->displayName); ?></strong><br/><span class="truncate"><?= Html::encode($userModel->displayNameSub); ?></span>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ if ($allowModifyProfileBanner || $allowModifyProfileImage) {
|
|||||||
<!-- show user name and title -->
|
<!-- show user name and title -->
|
||||||
<div class="img-profile-data">
|
<div class="img-profile-data">
|
||||||
<h1><?= Html::encode($user->displayName); ?></h1>
|
<h1><?= Html::encode($user->displayName); ?></h1>
|
||||||
|
<h2><?= Html::encode($user->displayNameSub); ?></h2>
|
||||||
<h2><?= Html::encode($user->profile->title); ?></h2>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- check if the current user is the profile owner and can change the images -->
|
<!-- check if the current user is the profile owner and can change the images -->
|
||||||
|
@ -30,7 +30,7 @@ use yii\helpers\Html;
|
|||||||
|
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h4 class="media-heading"><?= Html::encode($user->displayName); ?></h4>
|
<h4 class="media-heading"><?= Html::encode($user->displayName); ?></h4>
|
||||||
<h5><?= Html::encode($user->profile->title); ?></h5>
|
<h5><?= Html::encode($user->displayNameSub); ?></h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -11,7 +11,7 @@ use humhub\modules\directory\widgets\UserTagList;
|
|||||||
<?= Image::widget(['user' => $user, 'width' => 40, 'htmlOptions' => ['class' => 'pull-left']]); ?>
|
<?= Image::widget(['user' => $user, 'width' => 40, 'htmlOptions' => ['class' => 'pull-left']]); ?>
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h4 class="media-heading"><?= Html::containerLink($user); ?></h4>
|
<h4 class="media-heading"><?= Html::containerLink($user); ?></h4>
|
||||||
<h5><?php echo Html::encode($user->profile->title); ?></h5>
|
<h5><?= Html::encode($user->displayNameSub); ?></h5>
|
||||||
<?= UserTagList::widget(['user' => $user]); ?>
|
<?= UserTagList::widget(['user' => $user]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,14 +33,14 @@ class MailContentContainerInfoBox extends \yii\base\Widget
|
|||||||
'container' => $this->container,
|
'container' => $this->container,
|
||||||
'url' => $this->container->createUrl('/space/space', [], true),
|
'url' => $this->container->createUrl('/space/space', [], true),
|
||||||
'description' => Helpers::trimText($this->container->description, 60)
|
'description' => Helpers::trimText($this->container->description, 60)
|
||||||
|
|
||||||
]);
|
]);
|
||||||
} elseif ($this->container instanceof \humhub\modules\user\models\User) {
|
} elseif ($this->container instanceof \humhub\modules\user\models\User) {
|
||||||
return $this->render('mailContentContainerInfoBox', [
|
return $this->render('mailContentContainerInfoBox', [
|
||||||
'container' => $this->container,
|
'container' => $this->container,
|
||||||
'url' => $this->container->createUrl('/user/profile', [], true),
|
'url' => $this->container->createUrl('/user/profile', [], true),
|
||||||
'description' => Helpers::trimText($this->container->profile->title, 60)
|
'description' => Helpers::trimText($this->container->displayNameSub, 60)
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ use yii\helpers\Html;
|
|||||||
</td>
|
</td>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<td height="15" style="font-size: 15px; line-height: 22px; font-family:Open Sans,Arial,Tahoma, Helvetica, sans-serif; color:<?= Yii::$app->view->theme->variable('text-color-soft2', '#aeaeae') ?>; font-weight:300; text-align:left; ">
|
<td height="15" style="font-size: 15px; line-height: 22px; font-family:Open Sans,Arial,Tahoma, Helvetica, sans-serif; color:<?= Yii::$app->view->theme->variable('text-color-soft2', '#aeaeae') ?>; font-weight:300; text-align:left; ">
|
||||||
<?= Html::encode($originator->profile->title); ?>
|
<?= Html::encode($originator->displayNameSub); ?>
|
||||||
</td>
|
</td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user