• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/integration/intranet/user.php
  • Класс: BitrixImIntegrationIntranetUser
  • Вызов: User::onUserInvited
static function onUserInvited(BitrixMainEvent $event): bool
{
	if (!BitrixMainModuleManager::isModuleInstalled('intranet'))
	{
		return false;
	}

	$originatorId = (int)$event->getParameter('originatorId');
	$users = (array)$event->getParameter('userId');

	if (!self::isEmployee($originatorId))
	{
		return false;
	}

	$userForSend = [];
	$result = BitrixIntranetUserTable::getList([
		'filter' => [
			'=ID' => $users
		],
		'select' => ['ID', 'USER_TYPE', 'EMAIL']

	]);
	while ($row = $result->fetch())
	{
		if ($row['USER_TYPE'] === 'employee')
		{
			$userForSend[] = [
				'ID' => $row['ID'],
				'INVITED' => [
					'originator_id' => $originatorId,
					'can_resend' => !empty($row['EMAIL'])
				]
			];
		}
	}

	if (empty($userForSend))
	{
		return false;
	}

	self::sendInviteEvent($userForSend);

	$userForSend = array_map(function($user) {
		return self::getUserBlock($user['ID']);
	}, $userForSend);

	return self::sendMessageToGeneralChat($originatorId, [
		'MESSAGE' => Loc::getMessage('IM_INT_USR_INVITE_USERS', [
			'#USER_NAME#' => self::getUserBlock($originatorId),
			'#USERS#' => implode(', ', $userForSend)
		]),
		'SYSTEM' => 'Y',
		'PUSH' => 'N'
	]);
}