• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/blog/mention.php
  • Класс: BitrixSocialnetworkIntegrationBlogMention
  • Вызов: Mention::parseUserList
static function parseUserList(array $params = []): array
{
	$result = [];

	$commentText = (string)($params['commentText'] ?? '');
	$excludedUserIdList = (isset($params['excludedUserIdList']) && is_array($params['excludedUserIdList']) ? $params['excludedUserIdList'] : []);
	$postId = (int)($params['postId'] ?? 0);

	if (
		$postId <= 0
		|| !Loader::includeModule('blog')
	)
	{
		return $result;
	}

	$mentionedUserIdList = BitrixSocialnetworkHelperMention::getUserIds($commentText);
	if (empty($mentionedUserIdList))
	{
		return $result;
	}

	$userIdToShareList = [];

	foreach ($mentionedUserIdList as $userId)
	{
		$userId = (int)$userId;
		if (
			$userId <= 0
			|| in_array($userId, $excludedUserIdList, true)
		)
		{
			continue;
		}

		$postPerm = CBlogPost::getSocNetPostPerms([
			'POST_ID' => $postId,
			'NEED_FULL' => true,
			'USER_ID' => $userId,
			'IGNORE_ADMIN' => true,
		]);

		if ($postPerm >= Permissions::PREMODERATE)
		{
			continue;
		}

		$userIdToShareList[] = $userId;
	}

	$userIdToShareList = array_unique($userIdToShareList);
	if (empty($userIdToShareList))
	{
		return $result;
	}

	foreach ($userIdToShareList as $userId)
	{
		$result[] = 'U' . $userId;
	}

	return $result;
}