...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmEntityEditorRestProxy
- Вызов: CCrmEntityEditorRestProxy::processMethodRequest
public function processMethodRequest($name, $nameDetails, $arParams, $nav, $server) { $name = mb_strtoupper($name); if($name !== 'CONFIGURATION') { throw new RestException("Resource '{$name}' is not supported in current context."); } if(!\Bitrix\Crm\Entity\EntityEditorConfig::isEntityTypeSupported($this->entityTypeID)) { $entityTypeName = \CCrmOwnerType::ResolveName($this->entityTypeID); throw new RestException("The entity type '{$entityTypeName}' is not supported in current context."); } $userID = (int)\CCrmRestHelper::resolveParam( $arParams, \CCrmRestHelper::resolveParamName($arParams, array('user', 'id')), 0 ); if($userID <= 0) { $userID = CCrmSecurityHelper::GetCurrentUserID(); } $scope = \CCrmRestHelper::resolveParam($arParams, 'scope', ''); if ($scope !== \Bitrix\Crm\Entity\EntityEditorConfigScope::COMMON) { $scope = \Bitrix\Crm\Entity\EntityEditorConfigScope::PERSONAL; } $extras = \CCrmRestHelper::resolveArrayParam($arParams, 'extras', null); if(!is_array($extras)) { $extras = array(); } if(!empty($extras)) { if (\CCrmOwnerType::isPossibleDynamicTypeId($this->entityTypeID)) { \CCrmRestHelper::renameParam($extras, ['category', 'id'], 'CATEGORY_ID'); } elseif ($this->entityTypeID === \CCrmOwnerType::Deal) { \CCrmRestHelper::renameParam($extras, ['deal', 'category', 'id'], 'DEAL_CATEGORY_ID'); } elseif ($this->entityTypeID === \CCrmOwnerType::Lead) { \CCrmRestHelper::renameParam($extras, ['lead', 'customer', 'type'], 'LEAD_CUSTOMER_TYPE'); } } $config = new \Bitrix\Crm\Entity\EntityEditorConfig($this->entityTypeID, $userID, $scope, $extras); $nameSuffix = mb_strtoupper(!empty($nameDetails)? implode('_', $nameDetails) : ''); if($nameSuffix === 'GET') { if(!$config->canDoOperation(\Bitrix\Crm\Entity\EntityEditorConfigOperation::GET)) { throw new RestException('Access denied.'); } return $config->get(); } elseif($nameSuffix === 'SET') { if(!$config->canDoOperation(\Bitrix\Crm\Entity\EntityEditorConfigOperation::SET)) { throw new RestException('Access denied.'); } $data = \CCrmRestHelper::resolveArrayParam($arParams, 'data', null); if(!is_array($data)) { throw new RestException("Parameter 'data' must be array."); } $data = $config->normalize($data); if(empty($data)) { throw new RestException("There are no data to write."); } $errors = array(); if(!$config->check($data, $errors)) { throw new RestException(implode("\n", $errors)); } $data = $config->sanitize($data); return !empty($data) && $config->set($data); } elseif($nameSuffix === 'RESET') { if(!$config->canDoOperation(\Bitrix\Crm\Entity\EntityEditorConfigOperation::RESET)) { throw new RestException('Access denied.'); } $config->reset(); return true; } elseif($nameSuffix === 'FORCECOMMONSCOPEFORALL') { if(!$config->canDoOperation(\Bitrix\Crm\Entity\EntityEditorConfigOperation::FORCE_COMMON_SCOPE_FOR_ALL)) { throw new RestException('Access denied.'); } $config->forceCommonScopeForAll(); return true; } throw new RestException("Operation '{$nameSuffix}' is not supported in current context."); }