• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
  • Класс: BitrixImOpenLinesRest
  • Вызов: Rest::widgetConfigGet
static function widgetConfigGet($params, $n, CRestServer $server)
{
	if ($server->getAuthType() != WidgetAuth::AUTH_TYPE)
	{
		throw new RestException('Access for this method allowed only by livechat authorization.', 'WRONG_AUTH_TYPE', CRestServer::STATUS_FORBIDDEN);
	}

	$params = array_change_key_case($params, CASE_UPPER);

	$config = WidgetConfig::getByCode($params['CODE']);
	if (!$config)
	{
		throw new RestException(
			WidgetConfig::getError()->msg,
			WidgetConfig::getError()->code,
			CRestServer::STATUS_WRONG_REQUEST
		);
	}

	shuffle($config['OPERATORS']);
	$config['OPERATORS'] = array_slice($config['OPERATORS'], 0, 3);

	//get security code and statuses texts for welcome CRM-form
	if ($config['CRM_FORMS_SETTINGS']['USE_WELCOME_FORM'] && Loader::includeModule('crm'))
	{
		$welcomeFormId = (int)$config['CRM_FORMS_SETTINGS']['WELCOME_FORM_ID'];
		$welcomeForm = new WebFormForm($welcomeFormId);
		if ($welcomeForm && $welcomeForm->isActive())
		{
			$config['CRM_FORMS_SETTINGS']['WELCOME_FORM_SEC'] = $welcomeForm->get()['SECURITY_CODE'];
		}

		$config['CRM_FORMS_SETTINGS']['SUCCESS_TEXT'] = $welcomeForm->get()['RESULT_SUCCESS_TEXT'];
		$config['CRM_FORMS_SETTINGS']['ERROR_TEXT'] = $welcomeForm->get()['RESULT_FAILURE_TEXT'];
	}

	$result = self::objectEncode($config);

	$coreMessages = CJSCore::GetCoreMessages();
	$result['serverVariables'] = [
		'FORMAT_DATE' => $coreMessages['FORMAT_DATE'],
		'FORMAT_DATETIME' => $coreMessages['FORMAT_DATETIME'],
		'AMPM_MODE' => IsAmPmMode(true),
		'UTF_MODE' => MainApplication::getInstance()->isUtfMode() ? 'Y' : 'N',
		'isCloud' => BitrixMainModuleManager::isModuleInstalled('bitrix24'),
	];

	return $result;
}