• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/UserPermissions.php
  • Класс: Bitrix\Crm\Service\UserPermissions
  • Вызов: UserPermissions::checkAddPermissions
public function checkAddPermissions(int $entityTypeId, ?int $categoryId = null, ?string $stageId = null): bool
{
	if ($entityTypeId === \CCrmOwnerType::ShipmentDocument)
	{
		if (Loader::includeModule('catalog'))
		{
			return
				AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ)
				&& AccessController::getCurrent()->check(ActionDictionary::ACTION_INVENTORY_MANAGEMENT_ACCESS)
				&& AccessController::getCurrent()->checkByValue(
					ActionDictionary::ACTION_STORE_DOCUMENT_MODIFY,
					\Bitrix\Catalog\StoreDocumentTable::TYPE_SALES_ORDERS
				)
			;
		}

		return \Bitrix\Crm\Order\Permissions\Shipment::checkCreatePermission($this->getCrmPermissions());
	}
	elseif($entityTypeId === \CCrmOwnerType::StoreDocument)
	{
		return Loader::includeModule('catalog') && AccessController::getCurrent()->check(ActionDictionary::ACTION_STORE_VIEW);
	}

	if (is_null($stageId))
	{
		return
			is_null($categoryId)
			? $this->canAddToType($entityTypeId)
			: $this->canAddToTypeInCategory($entityTypeId, $categoryId)
		;
	}

	$categoryId = $categoryId ?? 0;

	$entityName = static::getPermissionEntityType($entityTypeId, $categoryId);

	$attributes = [];
	$stageAttribute = $this->getStageIdAttributeByEntityTypeId($entityTypeId, $stageId);
	if ($stageAttribute)
	{
		$attributes[] = $stageAttribute;
	}

	$permission = $this->getCrmPermissions()->GetPermType($entityName, static::OPERATION_ADD, $attributes);

	return $permission > static::PERMISSION_NONE;
}