CCrmLiveFeedMessageRestProxy::processMethodRequest

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmLiveFeedMessageRestProxy
  4. processMethodRequest
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmLiveFeedMessageRestProxy
  • Вызов: CCrmLiveFeedMessageRestProxy::processMethodRequest
public function processMethodRequest($name, $nameDetails, $arParams, $nav, $server)
{
	global $USER;

	$name = mb_strtoupper($name);
	if($name === 'ADD')
	{
		$fields = $this->resolveArrayParam($arParams, 'fields');

		$arComponentResult = array(
			'USER_ID' => $this->getCurrentUserID()
		);

		$arPOST = array(
			'ENABLE_POST_TITLE' => 'Y',
			'MESSAGE' => $fields['MESSAGE'],
			'SPERM' => $fields['SPERM']
		);

		if (
			isset($fields['POST_TITLE'])
			&& $fields['POST_TITLE'] <> ''
		)
		{
			$arPOST['POST_TITLE'] = $fields['POST_TITLE'];
		}

		$entityTypeID = $fields['ENTITYTYPEID'];
		$entityID = $fields['ENTITYID'];

		$entityTypeName = CCrmOwnerType::ResolveName($entityTypeID);
		$userPerms = CCrmPerms::GetCurrentUserPermissions();

		if(
			$entityTypeName !== ''
			&& !CCrmAuthorizationHelper::CheckUpdatePermission($entityTypeName, $entityID, $userPerms)
		)
		{
			throw new RestException('Access denied.');
		}

		if (
			isset($fields["FILES"])
			&& \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false)
			&& CModule::includeModule('disk')
			&& ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($USER->getID()))
			&& ($folder = $storage->getFolderForUploadedFiles())
		)
		{
			$arComponentResult["WEB_DAV_FILE_FIELD_NAME"] = "UF_SONET_LOG_DOC";

			// upload to storage
			$arResultFile = array();

			foreach($fields["FILES"] as $tmp)
			{
				$arFile = CRestUtil::saveFile($tmp);

				if(is_array($arFile))
				{
					$file = $folder->uploadFile(
						$arFile, // file array
						array(
							'NAME' => $arFile["name"],
							'CREATED_BY' => $USER->getID()
						),
						array(),
						true
					);

					if ($file)
					{
						$arResultFile[] = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX.$file->getId();
					}
				}
			}

			if (!empty($arResultFile))
			{
				$arPOST['UF_SONET_LOG_DOC'] = $arResultFile;
			}
		}

		$res = CCrmLiveFeedComponent::ProcessLogEventEditPOST($arPOST, $entityTypeID, $entityID, $arComponentResult);

		if(is_array($res))
		{
			throw new RestException(implode(", ", $res));
		}

		return $res;
	}

	throw new RestException('Method not found!', RestException::ERROR_METHOD_NOT_FOUND, CRestServer::STATUS_NOT_FOUND);
}

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