- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
- Класс: CCalendar
- Вызов: CCalendar::getSectionListForContext
static function getSectionListForContext(array $params = []): array
{
$userId = isset($params['userId']) ? (int)$params['userId'] : self::getCurUserId();
$sections = [];
$followedSectionList = UserSettings::getFollowedSectionIdList($userId);
$hiddenSections = UserSettings::getHiddenSections($userId);
self::$userMeetingSection = self::GetCurUserMeetingSection();
$sectionList = self::GetSectionList(
[
'ADDITIONAL_IDS' => $followedSectionList,
'checkPermissions' => true,
'getPermissions' => true,
'getImages' => true,
]
);
$sectionList = array_merge($sectionList, self::getSectionListAvailableForUser($userId));
$sectionIdList = [];
foreach ($sectionList as $i => $section)
{
if (!in_array((int)$section['ID'], $sectionIdList))
{
$sections[] = $section;
$sectionIdList[] = (int)$section['ID'];
}
}
$readOnly = !self::$perm['edit'] && !self::$perm['section_edit'];
if (self::$type === 'user' && self::$ownerId != self::$userId)
$readOnly = true;
if (self::$bAnonym)
$readOnly = true;
$bCreateDefault = !self::$bAnonym;
if (self::$type === 'user')
{
$bCreateDefault = self::$ownerId == self::$userId;
}
$additionalMeetingsId = [];
$groupOrUser = self::$type === 'user' || self::$type === 'group';
if ($groupOrUser)
{
$noEditAccessedCalendars = true;
}
$trackingUsers = [];
$trackingGroups = [];
foreach ($sections as $i => $section)
{
$sections[$i]['~IS_MEETING_FOR_OWNER'] = $section['CAL_TYPE'] === 'user' && $section['OWNER_ID'] !== self::$userId && self::GetMeetingSection($section['OWNER_ID']) === $section['ID'];
if (!in_array($section['ID'], $hiddenSections, true) && $section['ACTIVE'] !== 'N')
{
// It's superposed calendar of the other user and it's need to show user's meetings
if ($sections[$i]['~IS_MEETING_FOR_OWNER'])
{
$additionalMeetingsId[] = array('ID' => $section['OWNER_ID'], 'SECTION_ID' => $section['ID']);
}
}
// We check access only for main sections because we can't edit superposed section
if ($groupOrUser && $sections[$i]['CAL_TYPE'] == self::$type &&
$sections[$i]['OWNER_ID'] == self::$ownerId)
{
if ($noEditAccessedCalendars && $section['PERM']['edit'])
$noEditAccessedCalendars = false;
if ($readOnly && ($section['PERM']['edit'] || $section['PERM']['edit_section']) && !self::$isArchivedGroup)
$readOnly = false;
}
if (in_array($section['ID'], $followedSectionList))
{
$sections[$i]['SUPERPOSED'] = true;
}
if ($bCreateDefault && $section['CAL_TYPE'] == self::$type && $section['OWNER_ID'] == self::$ownerId)
{
$bCreateDefault = false;
}
if ($sections[$i]['SUPERPOSED'])
{
$type = $sections[$i]['CAL_TYPE'];
if ($type === 'user')
{
$path = self::$pathesForSite['path_to_user_calendar'];
$path = CComponentEngine::MakePathFromTemplate($path, array("user_id" => $sections[$i]['OWNER_ID']));
$trackingUsers[] = $sections[$i]['OWNER_ID'];
}
elseif($type === 'group')
{
$path = self::$pathesForSite['path_to_group_calendar'];
$path = CComponentEngine::MakePathFromTemplate($path, array("group_id" => $sections[$i]['OWNER_ID']));
$trackingGroups[] = $sections[$i]['OWNER_ID'];
}
else
{
$path = self::$pathesForSite['path_to_type_'.$type];
}
$sections[$i]['LINK'] = $path;
}
}
if ($groupOrUser && $noEditAccessedCalendars && !$bCreateDefault)
{
$readOnly = true;
}
self::$readOnly = $readOnly;
return $sections;
}