• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/uf/sonetcommentconnector.php
  • Класс: BitrixDiskUfSonetCommentConnector
  • Вызов: SonetCommentConnector::canRead
public function canRead($userId)
{
	if($this->canRead !== null)
	{
		return $this->canRead;
	}


	if (CSocNetUser::isCurrentUserModuleAdmin())
	{
		$this->canRead = true;
		return $this->canRead;
	}

	if ($comment = $this->loadLogCommentData())
	{
		if (mb_strpos($comment["EVENT_ID"], "crm_") === 0)
		{
			$queryLog = CSocNetLog::getList(
				array(),
				array(
					"ID" => intval($comment["LOG_ID"])
				),
				false,
				false,
				array("ID", "ENTITY_TYPE", "ENTITY_ID")
			);
			if (
				($log = $queryLog->fetch())
				&& Loader::includeModule("crm")
			)
			{
				$userPermissions = CCrmPerms::getUserPermissions($userId);
				if ($log["ENTITY_TYPE"] == "CRMACTIVITY")
				{
					$bindings = CCRMActivity::getBindings($log["ENTITY_ID"]);
					foreach($bindings as $binding)
					{
						if (BitrixCrmSecurityEntityAuthorization::checkReadPermission(
							$binding["OWNER_TYPE_ID"],
							$binding["OWNER_ID"],
							$userPermissions
						))
						{
							$this->canRead = true;

							return $this->canRead;
						}
					}
				}
				else
				{
					if (BitrixCrmSecurityEntityAuthorization::checkReadPermission(
						CCrmLiveFeedEntity::resolveEntityTypeID($log["ENTITY_TYPE"]),
						$log["ENTITY_ID"],
						$userPermissions
					))
					{
						$this->canRead = true;

						return $this->canRead;
					}
					elseif (
						intval($comment["LOG_ID"]) > 0
						&& CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)
					)
					{
						$this->canRead = true;

						return $this->canRead;
					}
				}
			}
		}
		elseif (
			intval($comment["LOG_ID"]) > 0
			&& CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)
		)
		{
			$this->canRead = true;

			return $this->canRead;
		}
	}

	$this->canRead = false;

	return $this->canRead;
}