• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::commandUnRegister
static function commandUnRegister($arParams, $n, CRestServer $server)
{
	if ($server->getAuthType() == BitrixRestSessionAuthAuth::AUTH_TYPE)
	{
		throw new BitrixRestRestException("Access for this method not allowed by session authorization.", "WRONG_AUTH_TYPE", CRestServer::STATUS_FORBIDDEN);
	}
	$arParams = array_change_key_case($arParams, CASE_UPPER);

	$clientId = $server->getClientId();
	if (!$clientId)
	{
		if (!empty($arParams['CLIENT_ID']))
		{
			$clientId = 'custom'.$arParams['CLIENT_ID'];
		}
		else
		{
			throw new BitrixRestAccessException("Client ID not specified");
		}
	}

	$commands = BitrixImCommand::getListCache();
	if (!isset($commands[$arParams['COMMAND_ID']]))
	{
		throw new BitrixRestRestException("Command not found", "COMMAND_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
	}
	if ($commands[$arParams['COMMAND_ID']]['APP_ID'] != $clientId)
	{
		throw new BitrixRestRestException("Command was installed by another rest application", "APP_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
	}

	$result = BitrixImCommand::unRegister(Array('COMMAND_ID' => $arParams['COMMAND_ID']));
	if (!$result)
	{
		throw new BitrixRestRestException("Command can't be deleted", "WRONG_REQUEST", CRestServer::STATUS_WRONG_REQUEST);
	}

	return true;
}