Initial commit: Auth Server Base
This commit is contained in:
67
local/modules/conmed.authserver/lib/internaldatatrait.php
Normal file
67
local/modules/conmed.authserver/lib/internaldatatrait.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace Conmed\Authserver;
|
||||
|
||||
use Bitrix\Main\Loader;
|
||||
|
||||
trait InternalDataTrait {
|
||||
|
||||
/**
|
||||
* Возвращает Client ID по умолчанию для локальной регистрации и системных нужд
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultClientId() {
|
||||
return 'app_id_site';
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список специальностей для PHP-компонента
|
||||
*/
|
||||
public static function getSpecialtiesForComponent() {
|
||||
$rs = \Bitrix\Main\GroupTable::getList([
|
||||
'filter' =>['=ACTIVE' => 'Y', '=C_SORT' => 555],
|
||||
'select' =>['ID', 'NAME', 'STRING_ID'],
|
||||
'order' => ['NAME' => 'ASC']
|
||||
]);
|
||||
$res =[];
|
||||
while($g = $rs->fetch()) {
|
||||
if($g['STRING_ID']) {
|
||||
$res[] = ['id' => $g['ID'], 'name' => $g['NAME'], 'code' => $g['STRING_ID']];
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает справочники стран и городов для PHP-компонента
|
||||
*/
|
||||
public static function getGeoForComponent() {
|
||||
// 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. Города (из модуля веб-аналитики)
|
||||
$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_values(array_unique($cities));
|
||||
}
|
||||
|
||||
return[
|
||||
'countries' => $countries,
|
||||
'cities' => $cities
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user