• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/blog/mention.php
  • Класс: BitrixSocialnetworkIntegrationBlogMention
  • Вызов: Mention::processCommentShare
static function processCommentShare($params = [])
{
	$commentText = (string)($params['commentText'] ?? '');
	$excludedUserIdList = (isset($params['excludedUserIdList']) && is_array($params['excludedUserIdList']) ? $params['excludedUserIdList'] : []);
	$postId = (int)($params['postId'] ?? 0);
	$blogId = (int)($params['blogId'] ?? 0);
	$siteId = (string)($params['siteId'] ?? SITE_ID);

	$authorId = (int)($params['authorId'] ?? 0);
	if ($authorId > 0)
	{
		$excludedUserIdList[] = $authorId;
	}
	$excludedUserIdList = array_map(function ($item) { return (int)$item; }, $excludedUserIdList);
	$excludedUserIdList = array_unique($excludedUserIdList);

	if (
		$commentText === ''
		|| $postId <= 0
	)
	{
		return false;
	}

	if ($blogId <= 0)
	{
		$postFields = CBlogPost::getById($postId);
		$blogId = (int)$postFields['BLOG_ID'];
	}

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

	$newRightsList = self::parseUserList([
		'commentText' => $commentText,
		'postId' => $postId,
		'excludedUserIdList' => $excludedUserIdList,
	]);

	$newRightsList = array_merge($newRightsList, self::parseProjectList([
		'commentText' => $commentText,
		'postId' => $postId,
	]));

	$newRightsList = array_merge($newRightsList, self::parseDepartmentList([
		'commentText' => $commentText,
		'postId' => $postId,
	]));

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

	$fullRightsList = $newRightsList;

	$blogPermsList = CBlogPost::getSocnetPerms($postId);
	foreach ($blogPermsList as $entitiesList)
	{
		foreach ($entitiesList as $rightsList)
		{
			$fullRightsList = array_merge($fullRightsList, $rightsList);
		}
	}

	$fullRightsList = array_unique($fullRightsList);

	return BitrixSocialnetworkComponentHelper::processBlogPostShare(
		[
			'POST_ID' => $postId,
			'BLOG_ID' => $blogId,
			'SITE_ID' => $siteId,
			'SONET_RIGHTS' => $fullRightsList,
			'NEW_RIGHTS' => $newRightsList,
			'USER_ID' => $authorId,
		],
		[
			'PATH_TO_USER' => Option::get('main', 'TOOLTIP_PATH_TO_USER', SITE_DIR . 'company/personal/user/#user_id#/', $siteId),
			'PATH_TO_POST' => Path::get('userblogpost_page', $siteId),
			'NAME_TEMPLATE' => CSite::getNameFormat(),
			'SHOW_LOGIN' => 'Y',
			'LIVE' => 'N',
			'MENTION' => 'Y',
			'CLEAR_COMMENTS_CACHE' => (isset($params['clearCache']) && $params['clearCache'] === false ? 'N' : 'Y')
		]
	);
}