• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/rest.php
  • Класс: CSocNetLogRestService
  • Вызов: CSocNetLogRestService::getBlogPostUsersImprtnt
static function getBlogPostUsersImprtnt($fields): array
{
	global $CACHE_MANAGER;

	if (!is_array($fields))
	{
		throw new ArgumentTypeException('Incorrect input data');
	}

	$arParams["postId"] = (int) ($fields['POST_ID'] ?? null);

	if ($arParams['postId'] <= 0)
	{
		throw new ArgumentException('Wrong post ID');
	}

	$arParams["nTopCount"] = 500;
	$arParams["paramName"] = 'BLOG_POST_IMPRTNT';
	$arParams["paramValue"] = 'Y';

	$result = array();

	$cache = new CPHPCache();
	$cache_id = "blog_post_param_".serialize(array(
		$arParams["postId"],
		$arParams["nTopCount"],
		$arParams["paramName"],
		$arParams["paramValue"]
	));
	$cache_path = $CACHE_MANAGER->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog"))."/".$arParams["postId"];
	$cache_time = (defined("BX_COMP_MANAGED_CACHE") ? 3600*24*365 : 600);

	if ($cache->InitCache($cache_time, $cache_id, $cache_path))
	{
		$result = $cache->GetVars();
	}
	else
	{
		$cache->StartDataCache($cache_time, $cache_id, $cache_path);

		if (CModule::IncludeModule("blog"))
		{
			if (defined("BX_COMP_MANAGED_CACHE"))
			{
				$CACHE_MANAGER->StartTagCache($cache_path);
				$CACHE_MANAGER->RegisterTag($arParams["paramName"].$arParams["postId"]);
			}

			if ($arBlogPost = CBlogPost::GetByID($arParams["postId"]))
			{
				$postPerms = CBlogPost::GetSocNetPostPerms($arParams["postId"], true, self::getCurrentUserId(), $arBlogPost["AUTHOR_ID"]);
				if ($postPerms >= BLOG_PERMS_READ)
				{
					$res = CBlogUserOptions::GetList(
						[],
						[
							'POST_ID' => $arParams["postId"],
							'NAME' => $arParams["paramName"],
							'VALUE' => $arParams["paramValue"],
							'USER_ACTIVE' => 'Y',
						],
						[
							"nTopCount" => $arParams["nTopCount"],
							'SELECT' => [ 'USER_ID' ],
						]
					);
					if ($res)
					{
						while ($userOptionFields = $res->fetch())
						{
							$result[] = $userOptionFields['USER_ID'];
						}
					}
				}
			}

			if (defined("BX_COMP_MANAGED_CACHE"))
			{
				$CACHE_MANAGER->EndTagCache();
			}

			$cache->EndDataCache($result);
		}
	}

	return $result;
}