- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat/GroupChat.php
- Класс: BitrixImV2ChatGroupChat
- Вызов: GroupChat::generateTitle
protected function generateTitle(): string
{
if (Color::isEnabled() && $this->getColor())
{
$colorCodeKey = 'im_chat_color_' . $this->getColor();
$colorCodeCount = CGlobalCounter::GetValue($colorCodeKey, CGlobalCounter::ALL_SITES);
if ($colorCodeCount >= Color::MAX_COLOR_COUNT)
{
$colorCodeCount = 0;
CGlobalCounter::Set($colorCodeKey, 1, CGlobalCounter::ALL_SITES, '', false);
}
$chatTitle = Loc::getMessage('IM_CHAT_NAME_FORMAT', [
'#COLOR#' => Color::getName($this->getColor()),
'#NUMBER#' => ++$colorCodeCount,
]);
CGlobalCounter::Set($colorCodeKey, $colorCodeCount, CGlobalCounter::ALL_SITES, '', false);
}
else
{
$userIds = [];
if ($this->getUserIds() && count($this->getUserIds()))
{
$userIds = $this->getUserIds();
}
$userIds = CIMContactList::PrepareUserIds($userIds);
$users = CIMContactList::GetUserData([
'ID' => array_values($userIds),
'DEPARTMENT' => 'N',
'USE_CACHE' => 'N'
]);
$usersNames = [];
foreach ($users['users'] as $user)
{
$usersNames[] = htmlspecialcharsback($user['name']);
}
$chatTitle = Loc::getMessage('IM_CHAT_NAME_FORMAT_USERS', [
'#USERS_NAMES#' => implode(', ', $usersNames),
]);
}
return mb_substr($chatTitle, 0, 255);
}