...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmAddressRestProxy
- Вызов: CCrmAddressRestProxy::processMethodRequest
public function processMethodRequest($name, $nameDetails, $arParams, $nav, $server) { $name = mb_strtoupper($name); $fieldsInfo = $this->getFieldsInfo(); if($name === 'FIELDS' || $name === 'LIST') { return parent::processMethodRequest($name, $nameDetails, $arParams, $nav, $server); } elseif($name === 'ADD') { $fields = $this->resolveArrayParam($arParams, 'fields'); $entityID = $entityTypeID = $typeID = 0; if(is_array($fields)) { $typeID = intval($this->resolveParam($fields, 'TYPE_ID')); $entityTypeID = intval($this->resolveParam($fields, 'ENTITY_TYPE_ID')); $entityID = intval($this->resolveParam($fields, 'ENTITY_ID')); } if(!$this->isValidID($typeID) || !EntityAddressType::isDefined($typeID)) { throw new RestException('TYPE_ID is not defined or invalid.'); } if(!$this->isValidID($entityTypeID) || !CCrmOwnerType::IsDefined($entityTypeID)) { throw new RestException('ENTITY_TYPE_ID is not defined or invalid.'); } if(!$this->checkEntityID($entityID)) { throw new RestException('ENTITY_ID is not defined or invalid.'); } $r = $this->exists($typeID, $entityTypeID, $entityID); if(is_array($r)) { throw new RestException("TypeAddress exists."); } if(!EntityAddress::checkCreatePermissionOwnerEntity($entityTypeID, $entityID)) { throw new RestException('Access denied.'); } $this->internalizeFields($fields, $fieldsInfo, array()); if ($entityTypeID === \CCrmOwnerType::Requisite) { $anchor = EntityRequisite::getOwnerEntityById($entityID); $fields['ANCHOR_TYPE_ID'] = intval($anchor['ENTITY_TYPE_ID']); $fields['ANCHOR_ID'] = intval($anchor['ENTITY_ID']); } EntityAddress::register($entityTypeID, $entityID, $typeID, $fields); return true; } elseif($name === 'UPDATE') { $fields = $this->resolveArrayParam($arParams, 'fields'); $entityID = $entityTypeID = $typeID = 0; if(is_array($fields)) { $typeID = intval($this->resolveParam($fields, 'TYPE_ID')); $entityTypeID = intval($this->resolveParam($fields, 'ENTITY_TYPE_ID')); $entityID = intval($this->resolveParam($fields, 'ENTITY_ID')); } if(!$this->isValidID($typeID) || !EntityAddressType::isDefined($typeID)) { throw new RestException('TYPE_ID is not defined or invalid.'); } if(!$this->isValidID($entityTypeID) || !CCrmOwnerType::IsDefined($entityTypeID)) { throw new RestException('ENTITY_TYPE_ID is not defined or invalid.'); } if(!$this->checkEntityID($entityID)) { throw new RestException('ENTITY_ID is not defined or invalid.'); } $r = $this->exists($typeID, $entityTypeID, $entityID); if(!is_array($r)) { throw new RestException("TypeAddress not found."); } if(!EntityAddress::checkUpdatePermissionOwnerEntity($entityTypeID, $entityID)) { throw new RestException('Access denied.'); } $this->internalizeFields($fields, $fieldsInfo, array()); if (isset($fields['ENTITY_TYPE_ID']) && $fields['ENTITY_TYPE_ID'] == CCrmOwnerType::Requisite && isset($fields['ENTITY_ID']) && $fields['ENTITY_ID'] > 0) { $requisite = (new EntityRequisite)->getById( $fields['ENTITY_ID']); if (is_array($requisite) && isset($requisite['ENTITY_TYPE_ID']) && $requisite['ENTITY_TYPE_ID'] > 0 && isset($requisite['ENTITY_ID']) && $requisite['ENTITY_ID'] > 0) { $fields['ANCHOR_TYPE_ID'] = $requisite['ENTITY_TYPE_ID']; $fields['ANCHOR_ID'] = $requisite['ENTITY_ID']; } } EntityAddress::register($entityTypeID, $entityID, $typeID, $fields, [ 'updateLocationAddress' => !( isset($fields['ADDRESS_LOC_ADDR_ID']) && $fields['ADDRESS_LOC_ADDR_ID'] > 0 ) ]); return true; } elseif($name === 'DELETE') { $fields = $this->resolveArrayParam($arParams, 'fields'); $entityID = $entityTypeID = $typeID = 0; if(is_array($fields)) { $typeID = intval($this->resolveParam($fields, 'TYPE_ID')); $entityTypeID = intval($this->resolveParam($fields, 'ENTITY_TYPE_ID')); $entityID = intval($this->resolveParam($fields, 'ENTITY_ID')); } if(!$this->isValidID($typeID) || !EntityAddressType::isDefined($typeID)) { throw new RestException('TYPE_ID is not defined or invalid.'); } if(!$this->isValidID($entityTypeID) || !CCrmOwnerType::IsDefined($entityTypeID)) { throw new RestException('ENTITY_TYPE_ID is not defined or invalid.'); } if(!$this->checkEntityID($entityID)) { throw new RestException('ENTITY_ID is not defined or invalid.'); } $r = $this->exists($typeID, $entityTypeID, $entityID); if(!is_array($r)) { throw new RestException("TypeAddress not found."); } if(!EntityAddress::checkDeletePermissionOwnerEntity($entityTypeID, $entityID)) { throw new RestException('Access denied.'); } EntityAddress::unregister($entityTypeID, $entityID, $typeID); return true; } elseif($name === 'GETZONEID') { return EntityAddress::getZoneId(); } elseif($name === 'SETZONEID') { $zoneId = $this->resolveParam($arParams, 'ID'); EntityAddress::setZoneId($zoneId); return true; } throw new RestException("Resource '{$name}' is not supported in current context."); }