CAllCrmDeal::BuildPermSql

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmDeal
  4. BuildPermSql
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_deal.php
  • Класс: \CAllCrmDeal
  • Вызов: CAllCrmDeal::BuildPermSql
public function BuildPermSql($sAliasPrefix = 'L', $mPermType = 'READ', $arOptions = [])
{
	$allowSkipCheckOtherEntityTypes = false;
	if(isset($arOptions['RESTRICT_BY_ENTITY_TYPES'])
		&& is_array($arOptions['RESTRICT_BY_ENTITY_TYPES'])
		&& !empty($arOptions['RESTRICT_BY_ENTITY_TYPES'])
	)
	{
		$entityTypes = $arOptions['RESTRICT_BY_ENTITY_TYPES'];
		$allowSkipCheckOtherEntityTypes = true;
	}
	else
	{
		$entityTypes = array_merge(['DEAL'], DealCategory::getPermissionEntityTypeList());
	}

	$userId = null;
	if (isset($arOptions['PERMS']) && is_object($arOptions['PERMS']))
	{
		/** @var \CCrmPerms $arOptions['PERMS'] */
		$userId = $arOptions['PERMS']->GetUserID();
	}
	$builderOptions =
		Crm\Security\QueryBuilder\Options::createFromArray((array)$arOptions)
			->setOperations((array)$mPermType)
			->setAliasPrefix((string)$sAliasPrefix)
			->setSkipCheckOtherEntityTypes($allowSkipCheckOtherEntityTypes)
	;

	$queryBuilder = Crm\Service\Container::getInstance()
		->getUserPermissions($userId)
		->createListQueryBuilder($entityTypes, $builderOptions)
	;

	return $queryBuilder->buildCompatible();
}

Добавить комментарий