- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmCompanyRestProxy
- Вызов: CCrmCompanyRestProxy::innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null)
{
$isImportMode = is_array($params) && isset($params['IMPORT']) && $params['IMPORT'];
if(!($isImportMode ? CCrmCompany::CheckImportPermission() : CCrmCompany::CheckCreatePermission()))
{
$errors[] = 'Access denied.';
return false;
}
$diskQuotaRestriction = \Bitrix\Crm\Restriction\RestrictionManager::getDiskQuotaRestriction();
if (!$diskQuotaRestriction->hasPermission())
{
$errors[] = $diskQuotaRestriction->getErrorMessage();
return false;
}
$entity = self::getEntity();
$options = [];
if(!$this->isRequiredUserFieldCheckEnabled())
{
$options['DISABLE_REQUIRED_USER_FIELD_CHECK'] = true;
}
if(is_array($params) && isset($params['REGISTER_SONET_EVENT']))
{
$options['REGISTER_SONET_EVENT'] = mb_strtoupper($params['REGISTER_SONET_EVENT']) === 'Y';
}
if($isImportMode)
{
$options['ALLOW_SET_SYSTEM_FIELDS'] = true;
$fields['PERMISSION'] = 'IMPORT';
}
$result = $entity->Add($fields, true, $options);
if($result <= 0)
{
$errors[] = $entity->LAST_ERROR;
}
else
{
self::traceEntity(\CCrmOwnerType::Company, $result, $fields);
if (self::isBizProcEnabled() && !$isImportMode)
{
CCrmBizProcHelper::AutoStartWorkflows(
CCrmOwnerType::Company,
$result,
CCrmBizProcEventType::Create,
$errors
);
}
}
return $result;
}