- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_destination.php
- Класс: CSocNetLogDestination
- Вызов: CSocNetLogDestination::GetStucture
static function GetStucture($arParams = Array())
{
$bIntranetEnabled = false;
if(
IsModuleInstalled('intranet')
&& IsModuleInstalled('iblock')
)
{
$bIntranetEnabled = true;
}
$result = array(
"department" => array(),
"department_relation" => array(),
"department_relation_head" => array(),
);
$department_id = (
isset($arParams["DEPARTMENT_ID"])
&& intval($arParams["DEPARTMENT_ID"]) > 0
? intval($arParams["DEPARTMENT_ID"])
: false
);
if($bIntranetEnabled)
{
if (!(CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()))
{
if(($iblock_id = COption::GetOptionInt('intranet', 'iblock_structure', 0)) > 0)
{
global $CACHE_MANAGER;
$ttl = (
defined("BX_COMP_MANAGED_CACHE")
? 2592000
: 600
);
$cache_id = 'sonet_structure_new4_'.$iblock_id.(intval($department_id) > 0 ? "_".$department_id : "");
$obCache = new CPHPCache;
$cache_dir = '/sonet/structure';
if($obCache->InitCache($ttl, $cache_id, $cache_dir))
{
$result = $obCache->GetVars();
}
else
{
CModule::IncludeModule('iblock');
if(defined("BX_COMP_MANAGED_CACHE"))
{
$CACHE_MANAGER->StartTagCache($cache_dir);
}
$arFilter = array(
"IBLOCK_ID" => $iblock_id,
"ACTIVE" => "Y"
);
if (intval($department_id) > 0)
{
$rsSectionDepartment = CIBlockSection::GetList(
array(),
array(
"ID" => intval($department_id)
),
false,
array("ID", "LEFT_MARGIN", "RIGHT_MARGIN")
);
if ($arSectionDepartment = $rsSectionDepartment->Fetch())
{
$arFilter[">=LEFT_MARGIN"] = $arSectionDepartment["LEFT_MARGIN"];
$arFilter["<=RIGHT_MARGIN"] = $arSectionDepartment["RIGHT_MARGIN"];
}
}
$dbRes = CIBlockSection::GetList(
array("left_margin"=>"asc"),
$arFilter,
false,
array("ID", "IBLOCK_SECTION_ID", "NAME")
);
while ($ar = $dbRes->Fetch())
{
$result["department"]['DR'.$ar['ID']] = array(
'id' => 'DR'.$ar['ID'],
'entityId' => $ar["ID"],
'name' => htmlspecialcharsbx($ar['NAME']),
'parent' => 'DR'.intval($ar['IBLOCK_SECTION_ID']),
);
}
if(defined("BX_COMP_MANAGED_CACHE"))
{
$CACHE_MANAGER->RegisterTag('iblock_id_'.$iblock_id);
$CACHE_MANAGER->EndTagCache();
}
if($obCache->StartDataCache())
{
$obCache->EndDataCache($result);
}
}
}
}
}
if (
!empty( $result["department"])
&& !isset($arParams["LAZY_LOAD"])
)
{
$result["department_relation"] = self::GetTreeList('DR'.(intval($department_id) > 0 ? $department_id : 0), $result["department"], true);
if ((int) ($arParams["HEAD_DEPT"] ?? 0) > 0)
{
$result["department_relation_head"] = self::GetTreeList('DR'.intval($arParams["HEAD_DEPT"]), $result["department"], true);
}
}
return $result;
}