- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_sect.php
- Класс: CCalendarSect
- Вызов: CCalendarSect::GetList
static function GetList($params = [])
{
$result = false;
$checkPermissions = ($params['checkPermissions'] ?? null) !== false;
$params['joinTypeInfo'] = (bool)($params['joinTypeInfo'] ?? null);
$params['checkPermissions'] = $checkPermissions;
$params['getPermissions'] = ($params['getPermissions'] ?? null) !== false;
$userId = ($params['userId'] ?? false) ? (int)$params['userId'] : CCalendar::GetCurUserId();
$params['userId'] = $userId;
$cacheEnabled = CCalendar::CacheTime() > 0;
if ($cacheEnabled)
{
$cache = new CPHPCache;
$cacheId = 'section_list_'.serialize($params).(CCalendar::IsSocnetAdmin() ? 'socnet_admin' : '');
$cachePath = CCalendar::CachePath().'section_list';
if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath))
{
$res = $cache->GetVars();
$result = $res["arResult"];
$sectionIdList = $res["arSectionIds"];
$permissions = $res["permissions"];
if (is_array($permissions))
{
foreach($res["permissions"] as $sectionId => $perms)
{
self::$Permissions[$sectionId] = $perms;
}
}
}
}
if (!$cacheEnabled || !isset($sectionIdList))
{
if (self::$useOrmFilter)
{
$sectionList = self::getListOrm($params);
}
else
{
$sectionList = self::getListOld($params);
}
$result = [];
$sectionIdList = [];
$checkedConnections = [];
$isExchangeEnabled = CCalendar::IsExchangeEnabled();
$isCalDAVEnabled = CCalendar::IsCalDAVEnabled();
foreach ($sectionList as $section)
{
$sectId = (int)$section['ID'];
if (in_array($sectId, $sectionIdList, true))
{
continue;
}
if ($checkPermissions)
{
self::HandlePermission($section);
}
$sectionType = $section['CAL_TYPE'];
// Outlook js
if (
$sectionType !== RoomsManager::TYPE
&& CCalendar::IsIntranetEnabled()
)
{
$section['OUTLOOK_JS'] = 'needAction';
}
unset($section['ACCESS_CODE'], $section['TASK_ID']);
$sectionIdList[] = $sectId;
$section['EXPORT'] = [
'ALLOW' => true,
'LINK' => self::GetExportLink($section['ID'], $sectionType, $section['OWNER_ID'])
];
if ($sectionType === 'user')
{
$section['IS_EXCHANGE'] = $section['DAV_EXCH_CAL'] && $isExchangeEnabled;
if ($section['CAL_DAV_CON'] && $isCalDAVEnabled)
{
$connectionId = (int)$section["CAL_DAV_CON"];
if (isset($checkedConnections[$connectionId]))
{
$section['CAL_DAV_CON'] = $checkedConnections[$connectionId] ? $connectionId : false;
}
else
{
$connection = CDavConnection::GetList(
["ID" => "ASC"],
["ID" => $connectionId]
);
if ($connection)
{
$section['CAL_DAV_CON'] = (int)$connection["ID"];
}
else
{
$section['CAL_DAV_CON'] = false;
}
$checkedConnections[$connectionId] = (bool)$connection;
}
}
}
else
{
$section['IS_EXCHANGE'] = false;
$section['CAL_DAV_CON'] = false;
}
$result[] = $section;
}
if ($cacheEnabled)
{
$cache->StartDataCache(CCalendar::CacheTime(), $cacheId, $cachePath);
$cache->EndDataCache([
"arResult" => $result,
"arSectionIds" => $sectionIdList,
"permissions" => self::$Permissions,
]);
}
}
if (($checkPermissions || $params['getPermissions']) && $userId >= 0 && !empty($sectionIdList))
{
$result = self::GetSectionPermission($result, $params['getPermissions']);
}
return $result;
}