• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/component/entitydetails/basecomponent.php
  • Класс: Bitrix\Crm\Component\EntityDetails\BaseComponent
  • Вызов: BaseComponent::tryToDetectMode
protected function tryToDetectMode()
{
	if($this->entityID <= 0)
	{
		if(!$this->checkEntityPermission(EntityPermissionType::CREATE))
		{
			$this->addError(ComponentError::PERMISSION_DENIED);
			return false;
		}

		if ($this->getConversionWizard())
		{
			$this->mode = ComponentMode::CONVERSION;
		}
		else
		{
			$this->mode = ComponentMode::CREATION;
		}
	}
	else
	{
		if(!$this->checkIfEntityExists())
		{
			$this->addError(ComponentError::ENTITY_NOT_FOUND);
			return false;
		}

		if($this->getRequestParamOrDefault('copy', '') !== '')
		{
			if(!($this->checkEntityPermission(EntityPermissionType::READ)
				&& $this->checkEntityPermission(EntityPermissionType::CREATE))
			)
			{
				$this->addError(ComponentError::PERMISSION_DENIED);
				return false;
			}

			$this->mode = ComponentMode::COPING;
		}
		else
		{
			if(!$this->checkEntityPermission(EntityPermissionType::READ))
			{
				$this->addError(ComponentError::PERMISSION_DENIED);
				return false;
			}

			$this->mode = $this->checkEntityPermission(EntityPermissionType::UPDATE)
				? ComponentMode::MODIFICATION
				: ComponentMode::VIEW;
		}
	}

	$this->arResult['COMPONENT_MODE'] = $this->mode;

	return true;
}