...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmRequisitePresetFieldRestProxy
- Вызов: CCrmRequisitePresetFieldRestProxy::innerAddField
protected function innerAddField($presetId, &$fields, &$errors) { $r = $this->exists($presetId, EntityPreset::Requisite); if(!is_array($r)) { $errors[] = "The Preset with ID '{$presetId}' is not found"; return false; } if(!EntityPreset::checkCreatePermissionOwnerEntity($r['ENTITY_TYPE_ID'])) { $errors[] = 'Access denied.'; return false; } $preset = self::getEntity(); $requisite = self::getOwnerEntity(); if (!$this->checkFields('ADD', $presetId, $fields, $sError)) { $errors[] = $sError; return false; } $presetData = $preset->getById($presetId); $presetCountryId = isset($presetData['COUNTRY_ID']) ? (int)$presetData['COUNTRY_ID'] : 0; $fieldsTitles = $requisite->getFieldsTitles($presetCountryId); $addFields = $fields; if (isset($addFields['FIELD_TITLE']) && isset($addFields['FIELD_NAME'])) { if (isset($fieldsTitles[$addFields['FIELD_NAME']])) { $title = $fieldsTitles[$addFields['FIELD_NAME']]; $origFieldTitle = empty($title) ? $addFields['FIELD_NAME'] : $title; if ($addFields['FIELD_TITLE'] === $origFieldTitle) $addFields['FIELD_TITLE'] = ''; } unset($title); } if (!is_array($presetData['SETTINGS'])) $presetData['SETTINGS'] = array(); $id = $preset->settingsAddField($presetData['SETTINGS'], $addFields); if ($id > 0) { $result = $preset->update($presetId, array('SETTINGS' => $presetData['SETTINGS'])); if (is_object($result)) { if($result->isSuccess()) { return $id; } else { $errors = $result->getErrors(); return false; } } else { $errors[] = 'Added preset field. Error when updated Requisite'; return false; } } else { $errors[] = 'Error when adding preset field.'; return false; } }