CCrmRequisitePresetFieldRestProxy::innerUpdateFields

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

	$preset = self::getEntity();

	$presetField = $this->getByFieldId($id, $preset->settingsGetFields($r['SETTINGS']), array(
			'COUNTRY_ID' => $r['COUNTRY_ID']
	));
	if(empty($presetField))
	{
		$errors[] = "The PresetField with ID '{$id}' is not found";
		return false;
	}

	if(!EntityPreset::checkUpdatePermissionOwnerEntity($r['ENTITY_TYPE_ID']))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$fields['ID'] = $id;
	if (!$this->checkFields('UPD', $presetId, $fields, $sError))
	{
		$errors[] = $sError;
		return false;
	}

	$presetSettings = $r['SETTINGS'];
	if($preset->settingsUpdateField($presetSettings, $fields))
	{
		$result = $preset->update($presetId, array('SETTINGS' => $presetSettings));
		if (is_object($result))
		{
			if($result->isSuccess())
			{
				return $id;
			}
			else
			{
				$errors = $result->getErrors();
				return false;
			}
		}
		else
		{
			$errors[] = 'Update preset field. Error when updated Requisite';
			return false;
		}
	}
	else
	{
		$errors[] = 'Error when update preset field.';
		return false;
	}
}

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