- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/textparser.php
- Класс: CTextParser
- Вызов: CTextParser::convert_user
public function convert_user($userId = 0, $userName = '')
{
static $userTypeList = [];
if (is_array($userId))
{
$userName = $userId[2];
$userId = $userId[1];
}
$userId = (int)$userId;
$renderParams = [
'USER_ID' => $userId,
'USER_NAME' => $userName,
];
if ($userId > 0)
{
$type = false;
if (isset($userTypeList[$userId]))
{
$type = $userTypeList[$userId];
}
else
{
if (BitrixMainLoader::includeModule('intranet'))
{
$res = BitrixIntranetUserTable::getList([
'filter' => [
'ID' => $userId
],
'select' => [
'USER_TYPE'
]
]);
if ($userFields = $res->fetch())
{
$type = $userFields['USER_TYPE'];
}
}
$userTypeList[$userId] = $type;
}
$pathToUser = (
!empty($this->userPath)
? $this->userPath // forum
: $this->pathToUser
);
if (empty($pathToUser))
{
$pathToUser = COption::GetOptionString('main', 'TOOLTIP_PATH_TO_USER', '', SITE_ID);
}
switch($type)
{
case 'extranet':
$classAdditional = ' blog-p-user-name-extranet';
break;
case 'email':
$classAdditional = ' blog-p-user-name-email';
$pathToUser .= '';
if (
$this->pathToUserEntityType && $this->pathToUserEntityType != ''
&& (int)$this->pathToUserEntityId > 0
)
{
$pathToUser .= (strpos($pathToUser, '?') === false ? '?' : '&') . 'entityType=' . $this->pathToUserEntityType . '&entityId=' . intval($this->pathToUserEntityId);
}
break;
default:
$classAdditional = '';
}
$renderParams = [
'CLASS_ADDITIONAL' => $classAdditional,
'PATH_TO_USER' => $pathToUser,
'USER_ID' => $userId,
'USER_NAME' => $userName,
];
if (
$type === 'email'
&& !empty($this->pathToUserEntityType)
&& !empty($this->pathToUserEntityId)
)
{
$renderParams['TOOLTIP_PARAMS'] = BitrixMainWebJson::encode([
'entityType' => $this->pathToUserEntityType,
'entityId' => (int)$this->pathToUserEntityId,
]);
}
}
$res = $this->render_user($renderParams);
return $this->defended_tags($res);
}