- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/lib/integration/ui/entityselector/departmentprovider.php
- Класс: BitrixIntranetIntegrationUIEntitySelectorDepartmentProvider
- Вызов: DepartmentProvider::getStructure
public function getStructure(array $options = []): EO_Section_Collection
{
$structureIBlockId = self::getStructureIBlockId();
if ($structureIBlockId <= 0)
{
return new EO_Section_Collection();
}
$filter = [
'=IBLOCK_ID' => $structureIBlockId,
'=ACTIVE' => 'Y',
];
if (!empty($options['searchQuery']) && is_string($options['searchQuery']))
{
$filter['?NAME'] = $options['searchQuery'];
}
if (!empty($options['parentId']) && is_int($options['parentId']))
{
$filter['=IBLOCK_SECTION_ID'] = $options['parentId'];
}
$limit = isset($options['limit']) && is_int($options['limit']) ? $options['limit'] : 100;
if ($this->getOptions()['hideChatBotDepartment'])
{
$filter['!=XML_ID'] = 'im_bot';
}
$rootDepartment = null;
$rootDepartmentId = self::getRootDepartmentId();
if ($rootDepartmentId > 0)
{
$rootDepartment = SectionTable::getList([
'select' => ['ID', 'LEFT_MARGIN', 'RIGHT_MARGIN', 'DEPTH_LEVEL'],
'filter' => [
'=ID' => $rootDepartmentId,
'=IBLOCK_ID' => $structureIBlockId,
'=ACTIVE' => 'Y',
],
])->fetchObject();
if ($rootDepartment)
{
$filter['>=LEFT_MARGIN'] = $rootDepartment->getLeftMargin();
$filter['<=RIGHT_MARGIN'] = $rootDepartment->getRightMargin();
}
}
if (!empty($options['depthLevel']) && is_int($options['depthLevel']))
{
if ($rootDepartment)
{
$filter['<=DEPTH_LEVEL'] = $options['depthLevel'] + $rootDepartment->getDepthLevel();
}
else
{
$filter['<=DEPTH_LEVEL'] = $options['depthLevel'];
}
}
return SectionTable::getList([
'select' => ['ID', 'NAME', 'DEPTH_LEVEL', 'IBLOCK_SECTION_ID', 'LEFT_MARGIN', 'RIGHT_MARGIN'],
'filter' => $filter,
'order' => ['LEFT_MARGIN' => 'asc'],
'limit' => $limit,
])->fetchCollection();
}