• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/rest.php
  • Класс: CSocNetLogRestService
  • Вызов: CSocNetLogRestService::getBlogCommentPerm
static function getBlogCommentPerm($fields)
{
	if (!Loader::includeModule('blog'))
	{
		throw new InvalidOperationException('Blog module not installed');
	}

	$result = BitrixBlogItemPermissions::DENY;

	$commentId = $fields['COMMENT_ID'];

	$currentUserId = (int)(
		isset($fields["USER_ID"])
		&& (int)$fields['USER_ID'] > 0
		&& self::isAdmin()
			? $fields["USER_ID"]
			: self::getCurrentUserId()
	);

	$arComment = self::getBlogCommentFields($commentId);
	if (empty($arComment))
	{
		return $result;
	}

	if ((int)$arComment["AUTHOR_ID"] === $currentUserId)
	{
		$result = BitrixBlogItemPermissions::FULL;
	}
	elseif (CSocNetUser::isUserModuleAdmin($currentUserId, SITE_ID))
	{
		$result = BitrixBlogItemPermissions::FULL;
	}
	elseif ($arComment['PUBLISH_STATUS'] === BLOG_PUBLISH_STATUS_PUBLISH)
	{
		$postItem = BitrixBlogItemPost::getById($arComment['POST_ID']);
		$permsResult = $postItem->getSonetPerms(array(
			"CHECK_FULL_PERMS" => true
		));
		$result = $permsResult['PERM'];
		if (
			$result <= BitrixBlogItemPermissions::READ
			&& $permsResult['READ_BY_OSG']
		)
		{
			$result = BitrixBlogItemPermissions::READ;
		}
		elseif ($result > BitrixBlogItemPermissions::READ)
		{
			$result = BitrixBlogItemPermissions::READ;
		}
	}

	return $result;
}