- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_event.php
- Класс: CCalendarEvent
- Вызов: CCalendarEvent::GetList
static function GetList($params = [])
{
$isIntranetEnabled = CCalendar::IsIntranetEnabled();
$checkPermissions = ($params['checkPermissions'] ?? null) !== false;
$bCache = CCalendar::CacheTime() > 0;
$params['setDefaultLimit'] = ($params['setDefaultLimit'] ?? null) === true;
$userId = (isset($params['userId']) && $params['userId']) ? (int)$params['userId'] : CCalendar::GetCurUserId();
$params['parseDescription'] = $params['parseDescription'] ?? true;
$params['fetchAttendees'] = ($params['fetchAttendees'] ?? null) !== false;
$resultEntryList = null;
$userIndex = null;
CTimeZone::Disable();
if ($bCache)
{
$cache = new CPHPCache;
$cacheId = 'eventlist'.md5(serialize($params)).CCalendar::GetOffset();
if ($checkPermissions)
{
$cacheId .= 'perm' . CCalendar::GetCurUserId() . '|';
}
if (CCalendar::IsSocNet() && CCalendar::IsSocnetAdmin())
{
$cacheId .= 'socnetAdmin|';
}
$cachePath = CCalendar::CachePath().'event_list';
if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath))
{
$cachedData = $cache->GetVars();
if (isset($cachedData['dateTimeFormat']) && $cachedData['dateTimeFormat'] === FORMAT_DATETIME)
{
$resultEntryList = $cachedData["resultEntryList"];
$userIndex = $cachedData["userIndex"];
}
}
}
if (!$bCache || !isset($resultEntryList))
{
$arFilter = $params['arFilter'];
$resultEntryList = [];
if (self::$useOrmFilter)
{
[$eventList, $parentMeetingIdList, $involvedUsersIdList] = self::getListOrm($params);
}
else
{
[$eventList, $parentMeetingIdList, $involvedUsersIdList] = self::getListOld($params);
}
if (!empty($params['fetchAttendees']) && !empty($parentMeetingIdList))
{
$attendeeListData = self::getAttendeeList($parentMeetingIdList);
$attendeeList = $attendeeListData['attendeeList'];
$involvedUsersIdList = array_unique(array_merge($involvedUsersIdList, $attendeeListData['userIdList']));
}
$userIndex = self::getUsersDetails($involvedUsersIdList);
foreach ($eventList as $event)
{
if (
$event['IS_MEETING']
&& isset($attendeeList[$event['PARENT_ID']])
&& $isIntranetEnabled
)
{
$event['ATTENDEE_LIST'] = $attendeeList[$event['PARENT_ID']];
}
else if (!empty($params['fetchAttendees']))
{
$event['ATTENDEE_LIST'] = [
[
'id' => (int)$event['MEETING_HOST'],
'entryId' => $event['ID'],
'status' => in_array($event['MEETING_STATUS'], ['Y', 'N', 'Q', 'H'])
? $event['MEETING_STATUS']
: 'H'
,
]
];
}
else
{
$event['ATTENDEE_LIST'] = [];
}
if ($checkPermissions)
{
$checkPermissionsForEvent = $userId !== (int)($event['CREATED_BY'] ?? null); // It's creator
// It's event in user's calendar
if (
$checkPermissionsForEvent
&& $event['CAL_TYPE'] === 'user'
&& $userId === (int)$event['OWNER_ID']
)
{
$checkPermissionsForEvent = false;
}
if (
$checkPermissionsForEvent
&& $event['IS_MEETING']
&& ($event['USER_MEETING'] ?? null)
&& (int)$event['USER_MEETING']['ATTENDEE_ID'] === $userId
)
{
$checkPermissionsForEvent = false;
}
if (
$checkPermissionsForEvent
&& $event['IS_MEETING']
&& is_array($event['ATTENDEE_LIST'] ?? null)
)
{
foreach($event['ATTENDEE_LIST'] as $attendee)
{
if ((int)$attendee['id'] === $userId)
{
$checkPermissionsForEvent = false;
break;
}
}
}
if ($checkPermissionsForEvent)
{
$event = self::ApplyAccessRestrictions($event, $userId);
}
}
if ($event !== false)
{
$event = self::PreHandleEvent($event, [
'parseDescription' => $params['parseDescription']
]);
if (!empty($params['parseRecursion']) && self::CheckRecurcion($event))
{
self::ParseRecursion($resultEntryList, $event, [
'userId' => $userId,
'fromLimit' => $arFilter["FROM_LIMIT"] ?? null,
'toLimit' => $arFilter["TO_LIMIT"] ?? null,
'loadLimit' => $params["limit"] ?? null,
'instanceCount' => $params['maxInstanceCount'] ?? false,
'preciseLimits' => $params['preciseLimits'] ?? false
]);
}
else
{
self::HandleEvent($resultEntryList, $event, $userId);
}
}
}
if ($bCache)
{
$cache->StartDataCache(CCalendar::CacheTime(), $cacheId, $cachePath);
$cache->EndDataCache([
"resultEntryList" => $resultEntryList,
"userIndex" => $userIndex,
"dateTimeFormat" => FORMAT_DATETIME,
]);
}
}
if (is_array($userIndex))
{
foreach($userIndex as $userIndexId => $userIndexDetails)
{
self::$userIndex[$userIndexId] = $userIndexDetails;
}
}
CTimeZone::Enable();
return $resultEntryList;
}