- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_restservice.php
- Класс: CCalendarRestService
- Вызов: CCalendarRestService::EventGet
static function EventGet($params = [], $nav = null, $server = null)
{
$userId = CCalendar::GetCurUserId();
$methodName = "calendar.event.get";
$necessaryParams = ['type'];
foreach ($necessaryParams as $param)
{
if (empty($params[$param]))
{
throw new RestException(Loc::getMessage('CAL_REST_PARAM_EXCEPTION', [
'#PARAM_NAME#' => $param,
'#REST_METHOD#' => $methodName
]));
}
}
if (Loader::includeModule('intranet') && !BitrixIntranetUtil::isIntranetUser())
{
throw new RestException(Loc::getMessage('CAL_REST_ACCESS_DENIED'));
}
$type = $params['type'];
$ownerId = (int)$params['ownerId'];
$from = false;
$to = false;
if (isset($params['from']))
{
$from = CRestUtil::unConvertDateTime($params['from']);
}
if (isset($params['to']))
{
$to = CRestUtil::unConvertDateTime($params['to']);
}
// Default values for from-to period
if ($from === false && $to === false)
{
// Limits
$ts = time();
$pastDays = 30;
$futureDays = 90;
$from = CCalendar::Date($ts - CCalendar::DAY_LENGTH * $pastDays, false);
$to = CCalendar::Date($ts + CCalendar::DAY_LENGTH * $futureDays, false);
}
elseif ($from !== false && $to === false)
{
$to = CCalendar::Date(CCalendar::GetMaxTimestamp(), false);
}
$arSectionIds = [];
$sections = CCalendarSect::GetList([
'arFilter' => [
'CAL_TYPE' => $type,
'OWNER_ID' => $ownerId
]
]);
foreach ($sections as $section)
{
if ($section['PERM']['view_full'] || $section['PERM']['view_title'] || $section['PERM']['view_time'])
{
$arSectionIds[] = $section['ID'];
}
}
if (isset($params['section']))
{
if (!is_array($params['section']) && (int)$params['section'] > 0)
{
$params['section'] = [(int)$params['section']];
}
if (is_array($params['section']))
{
$arSectionIds = array_intersect($arSectionIds, $params['section']);
}
}
$params = [
'type' => $type,
'ownerId' => $ownerId,
'userId' => $userId,
'section' => $arSectionIds,
'fromLimit' => $from,
'toLimit' => $to,
];
$arAttendees = [];
return CCalendar::GetEventList($params, $arAttendees);
}