• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/classes/general/restentity.php
  • Класс: CBitrixRestEntity
  • Вызов: CBitrixRestEntity::entityRights
static function entityRights($params, $n, $server)
{
	global $USER;

	if(self::checkParams($params))
	{
		$arIBlock = self::getIBlock(self::getEntityIBlockCode($params['ENTITY'], $server));
		if($arIBlock)
		{
			$obIBlockRights = new CIBlockRights($arIBlock['ID']);

			if(isset($params['ACCESS']) && is_array($params['ACCESS']) && count($params['ACCESS']) > 0)
			{
				if(CIBlockRights::UserHasRightTo($arIBlock['ID'], $arIBlock['ID'], 'iblock_edit'))
				{
					$params['ACCESS']['U'.$USER->GetID()] = 'X';
					$arRights = self::checkRights($params['ACCESS']);

					$obIBlockRights->SetRights($arRights);
					$obIBlockRights->Recalculate();
				}
				else
				{
					throw new AccessException();
				}
			}

			$arRights = $obIBlockRights->GetRights();
			$res = array();

			foreach($arRights as $arRight)
			{
				$res[$arRight['GROUP_CODE']] = CIBlockRights::TaskToLetter($arRight['TASK_ID']);
			}

			return $res;
		}
	}
}