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

	$result = [];

	$commentText = (string)($params['commentText'] ?? '');

	$postId = (int)($params['postId'] ?? 0);

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

	if (
		Loader::includeModule('extranet')
		&& !CExtranet::isIntranetUser()
	)
	{
		return $result;
	}

	$mentionedDepartmentIdList = BitrixSocialnetworkHelperMention::getDepartmentIds($commentText);
	if (empty($mentionedDepartmentIdList))
	{
		return $result;
	}

	$departmentIdToShareList = [];

	$postPermsData = self::getSocNetPerms([
		'postId' => $postId,
	]);

	foreach ($mentionedDepartmentIdList as $departmentId)
	{
		$departmentId = (int)$departmentId;
		if (
			$departmentId <= 0
			|| (
				isset($postPermsData['DR'])
				&& isset($postPermsData['DR'][$departmentId])
			)
		)
		{
			continue;
		}

		$departmentIdToShareList[] = $departmentId;
	}

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

	$res = SectionTable::getList([
		'filter' => [
			'@ID' => $departmentIdToShareList,
			'=ACTIVE' => 'Y',
		],
		'select' => [ 'ID' ],
	]);
	while ($sectionFields = $res->fetch())
	{
		$result[] = 'DR' . $sectionFields['ID'];
	}

	return $result;
}