CCrmRequisiteRestProxy::innerUpdate

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRequisiteRestProxy
  4. innerUpdate
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmRequisiteRestProxy
  • Вызов: CCrmRequisiteRestProxy::innerUpdate
protected function innerUpdate($ID, &$fields, &$errors, array $params = null)
{
	$r = $this->getById($ID);
	if(!is_array($r))
	{
		$errors[] = "The Requisite with ID '{$ID}' is not found";
		return false;
	}

	$entityTypeID = intval($r['ENTITY_TYPE_ID']);
	$entityID = intval($r['ENTITY_ID']);
	$presetID = intval($r['PRESET_ID']);

	if(!$this->isValidID($entityTypeID) || !CCrmOwnerType::IsDefined($entityTypeID))
	{
		$errors[] = "ENTITY_TYPE_ID is not defined or invalid.";
		return false;
	}
	if(!$this->checkEntityID($entityID))
	{
		$errors[] = "ENTITY_ID is not defined or invalid.";
		return false;
	}
	if(!$this->checkEntityID($presetID))
	{
		$errors[] = "PRESET_ID is not defined or invalid.";
		return false;
	}

	if(!EntityRequisite::checkUpdatePermissionOwnerEntity($entityTypeID, $entityID))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$entity = self::getEntity();

	$result = $entity->update($ID, $fields, $params);
	if(!$result->isSuccess())
	{
		$errors = $result->getErrors();
	}
	elseif(self::isBizProcEnabled())
	{
		CCrmEntityHelper::NormalizeUserFields($fields, EntityRequisite::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
		$GLOBALS['USER_FIELD_MANAGER']->Update(EntityRequisite::$sUFEntityID, $ID, $fields);

		CCrmBizProcHelper::AutoStartWorkflows(
				CCrmOwnerType::Company,
				$result->getId(),
				CCrmBizProcEventType::Edit,
				$errors
		);
	}
	return $result->isSuccess();
}

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