- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/integration/dav/syncadapter.php
- Класс: BitrixCalendarIntegrationDavSyncAdapter
- Вызов: SyncAdapter::getSectionList
static function getSectionList($entityType, $entityId, $params = [])
{
$sectionId = $params['sectionId'];
$sectionList = [];
if ($sectionId && self::$sectionIndex[$sectionId])
{
$sectionList[] = self::$sectionIndex[$sectionId];
}
else
{
if ($sectionId !== CCalendar::TASK_SECTION_ID)
{
$filter = [
'CAL_TYPE' => $entityType,
'OWNER_ID' => $entityId
];
if (!is_array($params))
{
$params = [];
}
if ($sectionId > 0)
{
$filter['ID'] = $sectionId;
}
CCalendar::SetSilentErrorMode(true);
if (isset($params['active']))
{
$filter['ACTIVE'] = $params['active'] ? 'Y' : 'N';
}
$res = CCalendarSect::GetList(['arFilter' => $filter]);
CCalendar::SetSilentErrorMode(false);
foreach($res as $calendar)
{
if ($params['skipExchange'] == true && $calendar['DAV_EXCH_CAL'] <> '')
{
continue;
}
$section = [
'ID' => $calendar['ID'],
'~NAME' => $calendar['NAME'],
'NAME' => htmlspecialcharsbx($calendar['NAME']),
'COLOR' => htmlspecialcharsbx($calendar['COLOR'])
];
$sectionList[] = $section;
self::$sectionIndex[$section['ID']] = $section;
}
// Temporary hide it, while waiting for new interface.
if (!$sectionId && false)
{
$followedSectionIdList = UserSettings::getFollowedSectionIdList($entityId);
if (count($followedSectionIdList) > 0)
{
$followedSectionList = CCalendarSect::GetList(['arFilter' => [
'CAL_TYPE' => $entityType,
'OWNER_ID' => $entityId,
'ACTIVE' => 'Y',
'ADDITIONAL_IDS' => $followedSectionIdList
]]);
foreach($followedSectionList as $calendar)
{
$section = [
'ID' => $calendar['ID'],
'~NAME' => $calendar['NAME'],
'NAME' => htmlspecialcharsbx($calendar['NAME']),
'COLOR' => htmlspecialcharsbx($calendar['COLOR'])
];
$sectionList[] = $section;
self::$sectionIndex[$section['ID']] = $section;
}
}
}
}
if (CCalendarSync::isTaskListSyncEnabled() && $entityType == 'user' && ($sectionId === CCalendar::TASK_SECTION_ID || !$sectionId))
{
$sectionsUserData = UserSettings::getSectionCustomization($entityId);
$taskSectionTitle = (isset($sectionsUserData['tasks']) && !empty($sectionsUserData['tasks']['name']))
? $sectionsUserData['tasks']['name']
: BitrixMainLocalizationLoc::getMessage('EC_MY_TASKS');
$section = [
'ID' => CCalendar::TASK_SECTION_ID,
'~NAME' => $taskSectionTitle,
'NAME' => htmlspecialcharsbx($taskSectionTitle),
'COLOR' => (isset($sectionsUserData['tasks']) && !empty($sectionsUserData['tasks']['color'])) ?
htmlspecialcharsbx($sectionsUserData['tasks']['color']) : CCalendar::DEFAULT_TASK_COLOR
];
$sectionList[] = $section;
self::$sectionIndex[$section['ID']] = $section;
}
}
return $sectionList;
}