- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/lib/integration/report/handler/base.php
- Класс: BitrixVoximplantIntegrationReportHandlerBase
- Вызов: Base::getUserInfo
public function getUserInfo($userId, array $params = []): ?array
{
static $users = [];
$userId = (int)$userId;
if (!$userId)
{
self::$withoutNameCount++;
$defaultName = Loc::getMessage('TELEPHONY_REPORT_BASE_USER_DEFAULT_NAME');
$userName = (self::$withoutNameCount < 2 ? $defaultName : $defaultName . ' ' . self::$withoutNameCount);
return ['name' => $userName];
}
if(isset($users[$userId]))
{
return $users[$userId];
}
// prepare link to profile
$replaceList = ['user_id' => $userId];
$template = '/company/personal/user/#user_id#/';
$link = CComponentEngine::makePathFromTemplate($template, $replaceList);
$this->preloadUserInfo([$userId]);
$userFields = static::$userFields[$userId];
if (!$userFields)
{
self::$withoutNameCount++;
$defaultName = Loc::getMessage('TELEPHONY_REPORT_BASE_USER_DEFAULT_NAME');
$userName = (self::$withoutNameCount < 2 ? $defaultName : $defaultName . ' ' . self::$withoutNameCount);
return ['name' => $userName];
}
// format name
$userName = CUser::FormatName(
CSite::GetNameFormat(),
[
'LOGIN' => $userFields['LOGIN'],
'NAME' => $userFields['NAME'],
'LAST_NAME' => $userFields['LAST_NAME'],
'SECOND_NAME' => $userFields['SECOND_NAME']
],
true,
false
);
if (empty($userName))
{
self::$withoutNameCount++;
$defaultName = Loc::getMessage('TELEPHONY_REPORT_BASE_USER_DEFAULT_NAME');
$userName = (self::$withoutNameCount < 2 ? $defaultName : $defaultName . ' ' . self::$withoutNameCount);
}
// prepare icon
$fileTmp = CFile::ResizeImageGet(
$userFields['PERSONAL_PHOTO'],
[
'width' => $params['avatarWidth'] ?? static::DEFAULT_AVATAR_WIDTH,
'height' => $params['avatarHeight'] ?? static::DEFAULT_AVATAR_HEIGHT
],
BX_RESIZE_IMAGE_EXACT,
false,
false,
true
);
$userIcon = $fileTmp['src'] ?: '/bitrix/js/ui/icons/b24/images/ui-user.svg?v2';
$users[$userId] = [
'id' => $userId,
'name' => $userName,
'link' => $link,
'icon' => $userIcon
];
return $users[$userId];
}