CCrmEntityBindingProxy::getItems

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmEntityBindingProxy
  4. getItems
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmEntityBindingProxy
  • Вызов: CCrmEntityBindingProxy::getItems
public function getItems($ownerEntityID)
{
	$ownerEntityID = (int)$ownerEntityID;
	if($ownerEntityID <= 0)
	{
		throw new RestException('The parameter ownerEntityID is invalid or not defined.');
	}

	$userPermissions = CCrmPerms::GetCurrentUserPermissions();
	if(
		$this->ownerEntityTypeID === CCrmOwnerType::Deal
		&& $this->entityTypeID === CCrmOwnerType::Contact
	)
	{
		$categoryID = CCrmDeal::GetCategoryID($ownerEntityID);
		if($categoryID < 0)
		{
			throw new RestException(
				!CCrmDeal::CheckReadPermission(0, $userPermissions) ? 'Access denied' : 'Not found'
			);
		}
		elseif(!CCrmDeal::CheckReadPermission($ownerEntityID, $userPermissions, $categoryID))
		{
			throw new AccessException();
		}

		return DealContactTable::getDealBindings($ownerEntityID);
	}
	elseif(
		$this->ownerEntityTypeID === CCrmOwnerType::Lead
		&& $this->entityTypeID === CCrmOwnerType::Contact
	)
	{
		if(!CCrmLead::CheckReadPermission($ownerEntityID, $userPermissions))
		{
			throw new AccessException();
		}

		return LeadContactTable::getLeadBindings($ownerEntityID);
	}
	elseif(
		$this->ownerEntityTypeID === CCrmOwnerType::Quote
		&& $this->entityTypeID === CCrmOwnerType::Contact
	)
	{
		if(!CCrmQuote::CheckReadPermission($ownerEntityID, $userPermissions))
		{
			throw new AccessException();
		}

		return QuoteContactTable::getQuoteBindings($ownerEntityID);
	}
	elseif(
		$this->ownerEntityTypeID === CCrmOwnerType::Contact
		&& $this->entityTypeID === CCrmOwnerType::Company
	)
	{
		if(!CCrmContact::CheckReadPermission($ownerEntityID, $userPermissions))
		{
			throw new AccessException();
		}

		return ContactCompanyTable::getContactBindings($ownerEntityID);
	}
	elseif(
		$this->ownerEntityTypeID === CCrmOwnerType::Company
		&& $this->entityTypeID === CCrmOwnerType::Contact
	)
	{
		if(!CCrmCompany::CheckReadPermission($ownerEntityID, $userPermissions))
		{
			throw new AccessException();
		}

		return ContactCompanyTable::getCompanyBindings($ownerEntityID);
	}

	$ownerEntityTypeName = CCrmOwnerType::ResolveName($this->ownerEntityTypeID);
	$entityTypeName = CCrmOwnerType::ResolveName($this->entityTypeID);

	throw new RestException("The binding type '{$ownerEntityTypeName} - {$entityTypeName}' is not supported in current context.");
}

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