47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
namespace Conmed\Authserver;
|
|
|
|
use Bitrix\Main\Context;
|
|
use Bitrix\Main\Loader;
|
|
|
|
trait DictionariesTrait {
|
|
public static function dictionariesAction() {
|
|
header('Content-Type: application/json');
|
|
$req = Context::getCurrent()->getRequest();
|
|
|
|
// Проверка прав клиента
|
|
if(!self::checkClient($req->getPost("client_id"), $req->getPost("client_secret"))) {
|
|
die(json_encode(['error'=>'forbidden']));
|
|
}
|
|
|
|
// 1. Страны (Стандартный список Битрикс)
|
|
$countries = [];
|
|
$arCountries = GetCountryArray();
|
|
if (is_array($arCountries['reference_id'])) {
|
|
foreach ($arCountries['reference_id'] as $k => $id) {
|
|
$countries[] = [
|
|
'id' => $id,
|
|
'name' => $arCountries['reference'][$k]
|
|
];
|
|
}
|
|
}
|
|
|
|
// 2. Города (Из модуля statistic)
|
|
$cities = [];
|
|
if (Loader::includeModule('statistic')) {
|
|
$rs = \CCity::GetList(['CITY_NAME' => 'ASC'], []);
|
|
while ($el = $rs->Fetch()) {
|
|
if (!empty($el['CITY_NAME'])) {
|
|
$cities[] = $el['CITY_NAME'];
|
|
}
|
|
}
|
|
$cities = array_unique($cities);
|
|
$cities = array_values($cities);
|
|
}
|
|
|
|
echo json_encode([
|
|
'countries' => $countries,
|
|
'cities' => $cities
|
|
]);
|
|
}
|
|
} |