• Модуль: pull
  • Путь к файлу: ~/bitrix/modules/pull/lib/rest.php
  • Класс: BitrixPullRest
  • Вызов: Rest::configGet
static function configGet($params, $n, CRestServer $server)
{
	$params = array_change_key_case($params, CASE_UPPER);

	if ($server->getAuthType() === BitrixRestOAuthAuth::AUTH_TYPE)
	{
		throw new BitrixRestRestException("Method not available for OAuth authorization.", "WRONG_AUTH_TYPE", CRestServer::STATUS_FORBIDDEN);
	}

	global $USER;
	$guestMode = defined("PULL_USER_ID") && (int)PULL_USER_ID != 0;
	if($server->getAuthType() === GuestAuth::AUTH_TYPE && $guestMode)
	{
		$userId = (int)PULL_USER_ID;
	}
	else if ($USER->IsAuthorized())
	{
		$userId = $USER->getId();
	}
	else
	{
		throw new BitrixRestRestException("Method not available for guest session at the moment.", "AUTHORIZE_ERROR", CRestServer::STATUS_FORBIDDEN);
	}

	$configParams = Array();
	$configParams['USER_ID'] = $userId;
	$configParams['CACHE'] = !isset($params['CACHE']) || $params['CACHE'] !== 'N';
	$configParams['REOPEN'] = !isset($params['REOPEN']) || $params['REOPEN'] !== 'N';
	$configParams['JSON'] = true;

	$config = BitrixPullConfig::get($configParams);
	if (!$config)
	{
		throw new BitrixRestRestException("Push & Pull server is not configured", "SERVER_ERROR", CRestServer::STATUS_INTERNAL);
	}

	$config['serverTime'] = date('c', time());

	return $config;
}