- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/intranet/department.php
- Класс: BitrixTasksIntegrationIntranetDepartment
- Вызов: Department::getIBlockSections
static function getIBlockSections(array $select = array())
{
$result = array("SECTIONS" => array(), "STRUCTURE" => array());
if(!static::includeModule() || !Loader::includeModule('iblock') || !empty($ids))
{
return $result;
}
$iblockId = intval(COption::getOptionInt('intranet', 'iblock_structure'));
if(!$iblockId)
{
return $result;
}
$filter = array('IBLOCK_ID' => $iblockId);
$select = array_merge($select, array('ID', 'NAME', 'IBLOCK_SECTION_ID', 'DEPTH_LEVEL', 'LEFT_MARGIN', 'RIGHT_MARGIN'));
$cache = new CPHPCache();
$cacheDir = '/tasks/subordinatedeps';
$structure = array();
$sections = array();
if($cache->initCache(32100113, md5(serialize($filter)), $cacheDir))
{
$vars = $cache->getVars();
$sections = $vars["SECTIONS"];
$structure = $vars["STRUCTURE"];
}
elseif ($cache->startDataCache())
{
global $CACHE_MANAGER;
$CACHE_MANAGER->startTagCache($cacheDir);
$CACHE_MANAGER->registerTag("iblock_id_{$iblockId}");
$res = CIBlockSection::getList(
['left_margin' => 'asc'], // order as full expanded tree
$filter,
false, // don't count
$select
);
while ($item = $res->fetch())
{
$id = $item['ID'];
$iblockSectionID = (int)$item['IBLOCK_SECTION_ID'];
if (!isset($structure[$iblockSectionID]))
{
$structure[$iblockSectionID] = [];
}
$structure[$iblockSectionID][] = $id;
$sections[$id] = $item;
}
$CACHE_MANAGER->endTagCache();
$cache->endDataCache(array("SECTIONS" => $sections, "STRUCTURE" => $structure));
}
$result['SECTIONS'] = $sections;
$result['STRUCTURE'] = $structure;
return $result;
}