- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/userutils.php
- Класс: BitrixMainUserUtils
- Вызов: UserUtils::getDepartmentNames
static function getDepartmentNames($departmentIds)
{
$result = Array();
if (!ModuleManager::isModuleInstalled('intranet'))
{
return $result;
}
$cacheTtl = 2592000;
$cacheName = 'iblock_structure';
$cachePath = '/bx/user/company/structure';
$iblockStructureId = ConfigOption::get('intranet', 'iblock_structure', 0);
$taggedCache = Application::getInstance()->getTaggedCache();
$companyStructure = Array();
$cache = DataCache::createInstance();
if ($cache->initCache($cacheTtl, $cacheName, $cachePath) && false)
{
$companyStructure = $cache->getVars();
}
else if ($iblockStructureId <= 0 || !Loader::includeModule('iblock'))
{
return $result;
}
else
{
$orm = BitrixIblockSectionTable::getList(Array('select' => Array('ID', 'NAME', 'DEPTH_LEVEL', 'IBLOCK_SECTION_ID'), 'filter' => Array('=IBLOCK_ID' => $iblockStructureId, '=ACTIVE' => 'Y',),));
while ($department = $orm->fetch())
{
$companyStructure[$department['ID']] = $department;
}
$taggedCache->startTagCache($cachePath);
$taggedCache->registerTag('iblock_id_'.$iblockStructureId);
$taggedCache->endTagCache();
if ($cache->startDataCache())
{
$cache->endDataCache($companyStructure);
}
}
if (is_array($departmentIds) && !empty($departmentIds))
{
foreach ($departmentIds as $id)
{
if (!array_key_exists($id, $companyStructure))
{
continue;
}
$result[] = $companyStructure[$id];
}
}
return $result;
}