- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
- Класс: CCalendar
- Вызов: CCalendar::GetUserPermissionsForCalendar
static function GetUserPermissionsForCalendar($calendarId, $userId)
{
[$sectionId, $entityType, $entityId] = $calendarId;
$entityType = mb_strtolower($entityType);
$accessController = new SectionAccessController((int)$userId);
$sectionModel =
SectionModel::createFromId((int)$sectionId)
->setType($entityType)
->setOwnerId((int)$entityId)
;
$request = [
ActionDictionary::ACTION_SECTION_EDIT => [],
ActionDictionary::ACTION_SECTION_EVENT_VIEW_FULL => [],
ActionDictionary::ACTION_SECTION_EVENT_VIEW_TIME => [],
ActionDictionary::ACTION_SECTION_EVENT_VIEW_TITLE => [],
];
$result = $accessController->batchCheck($request, $sectionModel);
$res = [
'bAccess' => $result[ActionDictionary::ACTION_SECTION_EVENT_VIEW_TIME],
'bReadOnly' => !$result[ActionDictionary::ACTION_SECTION_EDIT],
];
if ($res['bReadOnly'])
{
if ($result[ActionDictionary::ACTION_SECTION_EVENT_VIEW_TIME])
{
$res['privateStatus'] = 'time';
}
if ($result[ActionDictionary::ACTION_SECTION_EVENT_VIEW_TITLE])
{
$res['privateStatus'] = 'title';
}
}
return $res;
}