- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_event.php
- Класс: CCalendarEvent
- Вызов: CCalendarEvent::ApplyAccessRestrictions
static function ApplyAccessRestrictions($event, $userId = false)
{
$sectId = $event['SECT_ID'];
if (empty($event['ACCESSIBILITY']))
{
$event['ACCESSIBILITY'] = 'busy';
}
$private = !empty($event['PRIVATE_EVENT']) && ($event['CAL_TYPE'] ?? null) === 'user';
$isAttendee = false;
if (is_array($event['ATTENDEE_LIST'] ?? null))
{
foreach($event['ATTENDEE_LIST'] as $attendee)
{
if ((int)$attendee['id'] === (int)$userId)
{
$isAttendee = true;
break;
}
}
}
if (!$userId)
{
$userId = CCalendar::GetUserId();
}
if (
($event['CAL_TYPE'] ?? null) === 'user'
&& !empty($event['IS_MEETING'])
&& (int)$event['OWNER_ID'] !== (int)$userId
)
{
if ($isAttendee)
{
$sectId = CCalendar::GetMeetingSection($userId);
}
elseif (
isset($event['USER_MEETING']['ATTENDEE_ID'])
&& $event['USER_MEETING']['ATTENDEE_ID'] !== $userId
)
{
$sectId = CCalendar::GetMeetingSection($event['USER_MEETING']['ATTENDEE_ID']);
$event['SECT_ID'] = $sectId;
$event['OWNER_ID'] = $event['USER_MEETING']['ATTENDEE_ID'];
}
}
$accessController = new EventAccessController($userId);
$eventModel = self::getEventModelForPermissionCheck((int)($event['ID'] ?? 0), $event, $userId);
$eventModel->setSectionId((int)$sectId);
$request = [
ActionDictionary::ACTION_EVENT_VIEW_FULL => [],
ActionDictionary::ACTION_EVENT_VIEW_TIME => [],
ActionDictionary::ACTION_EVENT_VIEW_TITLE => [],
];
$accessResult = $accessController->batchCheck($request, $eventModel);
if ($private || (!$accessResult[ActionDictionary::ACTION_EVENT_VIEW_FULL] && !$isAttendee))
{
if ($private)
{
$event['NAME'] = '['.GetMessage('EC_ACCESSIBILITY_'.mb_strtoupper($event['ACCESSIBILITY'])).']';
$event['IS_ACCESSIBLE_TO_USER'] = false;
if (!$accessResult[ActionDictionary::ACTION_EVENT_VIEW_TIME])
{
return false;
}
}
else if (!$accessResult[ActionDictionary::ACTION_EVENT_VIEW_TITLE])
{
if ($accessResult[ActionDictionary::ACTION_EVENT_VIEW_TIME])
{
$event['NAME'] = '['.GetMessage('EC_ACCESSIBILITY_'.mb_strtoupper($event['ACCESSIBILITY'])).']';
$event['IS_ACCESSIBLE_TO_USER'] = false;
}
else
{
return false;
}
}
else
{
$event['NAME'] .= ' ['.GetMessage('EC_ACCESSIBILITY_'.mb_strtoupper($event['ACCESSIBILITY'])).']';
}
// Clear information about
unset(
$event['DESCRIPTION'],
$event['LOCATION'],
$event['REMIND'],
$event['USER_MEETING'],
$event['ATTENDEE_LIST'],
$event['ATTENDEES_CODES'],
$event['UF_CRM_CAL_EVENT'],
$event['UF_WEBDAV_CAL_EVENT'],
);
}
return $event;
}