35 "calendar.event.get" => [__CLASS__,
"EventGet"],
36 "calendar.event.add" => [__CLASS__,
"EventAdd"],
37 "calendar.event.update" => [__CLASS__,
"EventUpdate"],
38 "calendar.event.delete" => [__CLASS__,
"EventDelete"],
39 "calendar.event.get.nearest" => [__CLASS__,
"EventGetNearest"],
40 "calendar.event.getbyid" => [__CLASS__,
"EventGetById"],
42 "calendar.section.get" => [__CLASS__,
"SectionGet"],
43 "calendar.section.add" => [__CLASS__,
"SectionAdd"],
44 "calendar.section.update" => [__CLASS__,
"SectionUpdate"],
45 "calendar.section.delete" => [__CLASS__,
"SectionDelete"],
47 "calendar.resource.list" => [__CLASS__,
"ResourceList"],
48 "calendar.resource.add" => [__CLASS__,
"ResourceAdd"],
49 "calendar.resource.update" => [__CLASS__,
"ResourceUpdate"],
50 "calendar.resource.delete" => [__CLASS__,
"ResourceDelete"],
52 "calendar.resource.booking.list" => [__CLASS__,
"ResourceBookingList"],
57 "calendar.meeting.status.set" => [__CLASS__,
"MeetingStatusSet"],
58 "calendar.meeting.params.set" => [__CLASS__,
"MeetingParamsSet"],
59 "calendar.meeting.status.get" => [__CLASS__,
"MeetingStatusGet"],
60 "calendar.accessibility.get" => [__CLASS__,
"MeetingAccessibilityGet"],
61 "calendar.settings.get" => [__CLASS__,
"SettingsGet"],
62 "calendar.user.settings.get" => [__CLASS__,
"UserSettingsGet"],
63 "calendar.user.settings.set" => [__CLASS__,
"UserSettingsSet"],
67 \CRestUtil::PLACEMENTS => [
68 self::PLACEMENT_GRID_VIEW => []
73 \CRestUtil::EVENTS => [
74 'OnCalendarEntryAdd' => [
76 'OnAfterCalendarEntryAdd',
77 [__CLASS__,
'PrepareOnCalendarEntryEvent'],
79 'sendRefreshToken' =>
true,
82 'OnCalendarEntryUpdate' => [
84 'OnAfterCalendarEntryUpdate',
85 [__CLASS__,
'PrepareOnCalendarEntryEvent'],
87 'sendRefreshToken' =>
true,
90 'OnCalendarEntryDelete' => [
92 'OnAfterCalendarEventDelete',
93 [__CLASS__,
'PrepareOnCalendarEntryEvent'],
95 'sendRefreshToken' =>
true,
98 'OnCalendarSectionAdd' => [
100 'OnAfterCalendarSectionAdd',
101 [__CLASS__,
'PrepareOnCalendarSectionEvent'],
103 'sendRefreshToken' =>
true,
106 'OnCalendarSectionUpdate' => [
108 'OnAfterCalendarSectionUpdate',
109 [__CLASS__,
'PrepareOnCalendarSectionEvent'],
111 'sendRefreshToken' =>
true,
114 'OnCalendarSectionDelete' => [
116 'OnAfterCalendarSectionDelete',
117 [__CLASS__,
'PrepareOnCalendarSectionEvent'],
119 'sendRefreshToken' =>
true,
122 'OnCalendarRoomCreate' => [
124 'OnAfterCalendarRoomCreate',
125 [__CLASS__,
'PrepareOnCalendarRoomEvent'],
127 'sendRefreshToken' =>
true,
130 'OnCalendarRoomUpdate' => [
132 'OnAfterCalendarRoomUpdate',
133 [__CLASS__,
'PrepareOnCalendarRoomEvent'],
135 'sendRefreshToken' =>
true,
138 'OnCalendarRoomDelete' => [
140 'OnAfterCalendarRoomDelete',
141 [__CLASS__,
'PrepareOnCalendarRoomEvent'],
143 'sendRefreshToken' =>
true,
149 return [self::SCOPE_NAME => $methods];
177 $userId = CCalendar::GetCurUserId();
178 $methodName =
"calendar.event.get";
180 $necessaryParams = [
'type'];
181 foreach ($necessaryParams as $param)
185 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
186 '#PARAM_NAME#' => $param,
187 '#REST_METHOD#' => $methodName
194 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
198 $ownerId = (int)
$params[
'ownerId'];
204 $from = CRestUtil::unConvertDateTime(
$params[
'from']);
208 $to = CRestUtil::unConvertDateTime(
$params[
'to']);
212 if ($from ===
false && $to ===
false)
218 $from = CCalendar::Date($ts - CCalendar::DAY_LENGTH * $pastDays,
false);
219 $to = CCalendar::Date($ts + CCalendar::DAY_LENGTH * $futureDays,
false);
221 elseif ($from !==
false && $to ===
false)
223 $to = CCalendar::Date(CCalendar::GetMaxTimestamp(),
false);
228 $sections = CCalendarSect::GetList([
231 'OWNER_ID' => $ownerId
234 foreach ($sections as $section)
236 if ($section[
'PERM'][
'view_full'] || $section[
'PERM'][
'view_title'] || $section[
'PERM'][
'view_time'])
238 $arSectionIds[] = (int)$section[
'ID'];
249 if (is_array(
$params[
'section']))
251 $preparedSections = array_unique(array_map(fn($section) => (
int)$section,
$params[
'section']));
253 $arSectionIds = array_intersect($arSectionIds, $preparedSections);
259 'ownerId' => $ownerId,
261 'section' => $arSectionIds,
262 'fromLimit' => $from,
268 return CCalendar::GetEventList(
$params, $arAttendees);
274 private static function isDateStringContainsTimezone(
string $dateString): bool
277 if (preg_match(
'/([+-]\d{2}:\d{2}|[+-]\d{4}|Z)$/', $dateString))
283 if (preg_match(
'/[A-Za-z_]+\/[A-Za-z_]+/', $dateString))
308 $methodName =
"calendar.event.getbyid";
312 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
313 '#PARAM_NAME#' =>
'id',
314 '#REST_METHOD#' => $methodName
320 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
408 $userId = CCalendar::GetCurUserId();
409 $methodName =
"calendar.event.add";
413 if (isset(
$params[
'skip_time']))
415 $skipTime =
$params[
'skip_time'] ===
'Y';
418 if (isset(
$params[
'skipTime']))
420 $skipTime =
$params[
'skipTime'] ===
'Y';
425 unset(
$params[
'timezone_from']);
431 $enableOffset =
true;
435 if (self::isDateStringContainsTimezone(
$params[
'from']))
437 unset(
$params[
'timezone_from']);
442 $enableOffset =
false;
446 $params[
'from'] = CRestUtil::unConvertDateTime(
$params[
'from'], $enableOffset);
451 $enableOffset =
true;
455 if (self::isDateStringContainsTimezone(
$params[
'to']))
462 $enableOffset =
false;
466 $params[
'to'] = CRestUtil::unConvertDateTime(
$params[
'to'], $enableOffset);
487 if (isset(
$params[
'auto_detect_section']) &&
$params[
'auto_detect_section'] !==
"Y")
489 $necessaryParams[] =
'section';
492 foreach ($necessaryParams as $param)
496 if ($param ===
'ownerId' && isset(
$params[$param]))
501 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
502 '#PARAM_NAME#' => $param,
503 '#REST_METHOD#' => $methodName
508 if (!is_string(
$params[
'name']))
510 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
511 '#PARAM_NAME#' =>
'name',
515 if (isset(
$params[
'description']) && !is_string(
$params[
'description']))
517 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
518 '#PARAM_NAME#' =>
'description',
523 $ownerId = (int)
$params[
'ownerId'];
524 $sectionId = (int)(
$params[
'section'] ??
null);
528 $res = CCalendarSect::GetList([
532 'OWNER_ID' => $ownerId,
538 if (!
$res[0][
'PERM'][
'edit'])
540 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
545 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_ERROR'));
551 "OWNER_ID" => $ownerId,
552 "NAME" => trim(
$params[
'name']),
553 "DATE_FROM" =>
$params[
'from'],
555 "SECTIONS" => $sectionId,
556 'SKIP_TIME' => $skipTime,
564 if (isset(
$params[
'description']))
571 $color = CCalendar::Color(
$params[
'color']);
578 if (isset(
$params[
'text_color']))
580 $color = CCalendar::Color(
$params[
'text_color']);
587 if (isset(
$params[
'accessibility']))
592 if (isset(
$params[
'importance']))
597 if (isset(
$params[
'private_event']))
612 if (isset(
$params[
'is_meeting']))
617 if (isset(
$params[
'location']))
629 $defaultAttendeeId = !empty($ownerId) ? $ownerId :
$userId;
632 $requestAttendees = (isset(
$params[
'attendees']) && is_array(
$params[
'attendees']))
633 ? array_map(
'intval',
$params[
'attendees'])
637 $arFields[
'ATTENDEES'] = $requestAttendees ?: [$defaultAttendeeId];
641 foreach(
$arFields[
'ATTENDEES'] as $attendeeId)
643 $code =
'U'. (int)$attendeeId;
651 $meeting =
$params[
'meeting'] ?? [];
654 'HOST_NAME' => CCalendar::GetUserName(
$arFields[
'MEETING_HOST']),
655 'NOTIFY' => (bool)($meeting[
'notify'] ??
false),
656 'REINVITE' => (bool)($meeting[
'reinvite'] ??
false),
657 'ALLOW_INVITE' => (bool)($meeting[
'allow_invite'] ??
false),
658 'HIDE_GUESTS' => (bool)($meeting[
'hide_guests'] ??
false),
659 'MEETING_CREATOR' =>
$arFields[
'MEETING_HOST'],
660 'LANGUAGE_ID' => CCalendar::getUserLanguageId($defaultAttendeeId),
663 $saveParams[
'userId'] =
$arFields[
'MEETING_HOST'];
668 $arFields[
'ATTENDEES'] = [$defaultAttendeeId];
669 $arFields[
'ATTENDEES_CODES'] = [
'U' . $defaultAttendeeId];
670 $arFields[
'MEETING_HOST'] = $defaultAttendeeId;
674 'MEETING_CREATOR' =>
$arFields[
'MEETING_HOST'],
676 'ALLOW_INVITE' =>
false,
677 'HIDE_GUESTS' =>
false,
678 'HOST_NAME' => CCalendar::GetUserName(
$arFields[
'MEETING_HOST']),
679 'LANGUAGE_ID' => CCalendar::getUserLanguageId($defaultAttendeeId),
683 if (isset(
$params[
'crm_fields']))
685 $crmFields =
$params[
'crm_fields'];
688 throw new RestException(Loc::getMessage(
'CAL_REST_CRM_FIELDS_ERROR'));
691 foreach ($crmFields as $field)
693 if (!is_string($field))
695 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
696 '#PARAM_NAME#' =>
'crm_fields',
700 $elementTitle = CCalendarEvent::getCrmElementTitle($field);
702 if (empty($elementTitle))
704 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
705 '#PARAM_NAME#' =>
'crm_fields',
710 $saveParams[
'UF'] = [
'UF_CRM_CAL_EVENT' => $crmFields];
714 if (isset(
$params[
'auto_detect_section']) &&
$params[
'auto_detect_section'] ===
'Y')
716 $saveParams[
'autoDetectSection'] =
true;
717 $saveParams[
'autoCreateSection'] =
true;
720 $newId = CCalendar::SaveEvent($saveParams);
724 throw new RestException(Loc::getMessage(
"CAL_REST_EVENT_NEW_ERROR"));
803 $userId = CCalendar::GetCurUserId();
804 $methodName =
"calendar.event.update";
811 foreach ($necessaryParams as $param)
815 if ($param ===
'ownerId' && isset(
$params[$param]))
820 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
821 '#PARAM_NAME#' => $param,
822 '#REST_METHOD#' => $methodName
829 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
830 '#PARAM_NAME#' =>
'name',
834 if (isset(
$params[
'description']) && !is_string(
$params[
'description']))
836 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
837 '#PARAM_NAME#' =>
'description',
843 $ownerId = (int)
$params[
'ownerId'];
847 if (isset(
$params[
'skip_time']))
849 $skipTime =
$params[
'skip_time'] ===
'Y';
852 if (isset(
$params[
'skipTime']))
854 $skipTime =
$params[
'skipTime'] ===
'Y';
859 unset(
$params[
'timezone_from']);
865 $enableOffset =
true;
869 if (self::isDateStringContainsTimezone(
$params[
'from']))
871 unset(
$params[
'timezone_from']);
876 $enableOffset =
false;
880 $params[
'from'] = CRestUtil::unConvertDateTime(
$params[
'from'], $enableOffset);
885 $enableOffset =
true;
889 if (self::isDateStringContainsTimezone(
$params[
'to']))
896 $enableOffset =
false;
900 $params[
'to'] = CRestUtil::unConvertDateTime(
$params[
'to'], $enableOffset);
939 $arFields[
"NAME"] = Loc::getMessage(
'EC_T_NEW_EVENT');
943 if (isset(
$params[
'description']))
950 $sectionId =
$params[
'section'];
953 $res = CCalendarSect::GetList([
957 'OWNER_ID' => $ownerId,
963 if (!
$res[0][
'PERM'][
'edit'])
965 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
970 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_ERROR'));
975 if ($recurrenceMode =
$params[
'recurrence_mode'] ??
null)
977 if (!in_array($recurrenceMode, [
'this',
'next',
'all'],
true))
979 throw new RestException(Loc::getMessage(
'CAL_REST_REC_MODE_ERROR'));
982 $saveParams[
'recursionEditMode'] = $recurrenceMode;
985 if (isset(
$params[
'current_date_from']))
987 $saveParams[
'currentEventDateFrom'] = CRestUtil::unConvertDate(
$params[
'current_date_from']);
991 empty($saveParams[
'currentEventDateFrom'])
992 && !empty($saveParams[
'recursionEditMode'])
993 && in_array($saveParams[
'recursionEditMode'], [
'this',
'next'],
true)
996 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
997 '#PARAM_NAME#' =>
'current_date_from',
1003 $color = CCalendar::Color(
$params[
'color']);
1010 if (isset(
$params[
'text_color']))
1012 $color = CCalendar::Color(
$params[
'text_color']);
1019 if (isset(
$params[
'accessibility']))
1024 if (isset(
$params[
'importance']))
1029 if (isset(
$params[
'private_event']))
1044 if (isset(
$params[
'is_meeting']))
1049 if (isset(
$params[
'location']))
1065 foreach(
$arFields[
'ATTENDEES'] as $attendeeId)
1067 $code =
'U'. (int)$attendeeId;
1075 $meeting =
$params[
'meeting'] ?? [];
1078 'HOST_NAME' => CCalendar::GetUserName(
$arFields[
'MEETING_HOST']),
1079 'NOTIFY' => (bool)($meeting[
'notify'] ??
false),
1080 'REINVITE' => (bool)($meeting[
'reinvite'] ??
false),
1081 'ALLOW_INVITE' => (bool)($meeting[
'allow_invite'] ??
false),
1082 'HIDE_GUESTS' => (bool)($meeting[
'hide_guests'] ??
false),
1083 'MEETING_CREATOR' =>
$arFields[
'MEETING_HOST'],
1084 'LANGUAGE_ID' => CCalendar::getUserLanguageId(
$userId),
1087 $saveParams[
'userId'] =
$arFields[
'MEETING_HOST'];
1092 && !empty($saveParams[
'currentEventDateFrom'])
1095 $event = CCalendar::getCurrentEventForSaving($id,
$userId,
true);
1099 foreach (
$event[
'ATTENDEE_LIST'] as $attendee)
1101 $arFields[
'ATTENDEES'][] = $attendee[
'id'];
1108 if (isset(
$params[
'crm_fields']))
1110 $crmFields =
$params[
'crm_fields'];
1113 throw new RestException(Loc::getMessage(
'CAL_REST_CRM_FIELDS_ERROR'));
1116 foreach ($crmFields as $field)
1118 if (!is_string($field))
1120 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1121 '#PARAM_NAME#' =>
'crm_fields',
1125 $elementTitle = CCalendarEvent::getCrmElementTitle($field);
1127 if (empty($elementTitle))
1129 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1130 '#PARAM_NAME#' =>
'crm_fields',
1135 if (empty($crmFields))
1140 $saveParams[
'UF'] = [
'UF_CRM_CAL_EVENT' => $crmFields];
1144 $newId = CCalendar::SaveEvent($saveParams);
1148 throw new RestException(Loc::getMessage(
"CAL_REST_EVENT_UPDATE_ERROR"));
1180 throw new RestException(Loc::getMessage(
'CAL_REST_EVENT_ID_EXCEPTION'));
1183 $res = CCalendar::DeleteEvent($id);
1187 throw new RestException(Loc::getMessage(
'CAL_REST_EVENT_DELETE_ERROR'));
1221 $userId = CCalendar::GetCurUserId();
1227 $params[
'forCurrentUser'] =
true;
1237 $fromLimit = CCalendar::Date($ts,
false);
1238 $toLimit = CCalendar::Date($ts + CCalendar::DAY_LENGTH *
$params[
'days'],
false);
1240 $arEvents = CCalendar::GetNearestEventsList([
1241 'bCurUserList' => (
bool)(
$params[
'forCurrentUser'] ??
true),
1242 'fromLimit' => $fromLimit,
1243 'toLimit' => $toLimit,
1248 if ($arEvents ===
'access_denied' || $arEvents ===
'inactive_feature')
1250 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1253 if (is_array($arEvents))
1255 if (isset(
$params[
'detailUrl']))
1257 if (str_contains(
$params[
'detailUrl'],
'?'))
1263 foreach ($arEvents as
$i =>
$event)
1269 if (isset(
$params[
'maxEventsCount']))
1271 array_splice($arEvents, (
int)
$params[
'maxEventsCount']);
1298 $userId = CCalendar::GetCurUserId();
1299 $methodName =
"calendar.section.get";
1307 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'type')));
1310 if (isset(
$params[
'ownerId']))
1312 $ownerId = (int)
$params[
'ownerId'];
1320 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'ownerId')));
1325 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1329 'CAL_TYPE' =>
$type,
1330 'OWNER_ID' => $ownerId,
1336 foreach(
$res as
$i => $section)
1340 $res[
$i][
'DAV_EXCH_CAL'],
1341 $res[
$i][
'DAV_EXCH_MOD'],
1352 if (!empty(
$res[
$i][
'DATE_CREATE']) && is_string(
$res[
$i][
'DATE_CREATE']))
1354 $res[
$i][
'DATE_CREATE'] = self::formatOld(
$res[
$i][
'DATE_CREATE']);
1357 if (!empty(
$res[
$i][
'TIMESTAMP_X']) && is_string(
$res[
$i][
'TIMESTAMP_X']))
1359 $res[
$i][
'TIMESTAMP_X'] = self::formatOld(
$res[
$i][
'TIMESTAMP_X']);
1370 private static function formatOld(
string $value): string
1374 $value = (new \Bitrix\Main\Type\DateTime($value))->format(
'Y-m-d H:i:s');
1376 catch (\Bitrix\Main\ObjectException $e) {}
1420 $userId = CCalendar::GetCurUserId();
1421 $methodName =
"calendar.section.add";
1422 $DEFAULT_COLOR =
'#E6A469';
1423 $DEFAULT_TEXT_COLOR =
'#000000';
1431 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1432 '#REST_METHOD#' => $methodName,
1433 '#PARAM_NAME#' =>
'type'
1437 if (isset(
$params[
'ownerId']))
1439 $ownerId = (int)
$params[
'ownerId'];
1447 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1448 '#REST_METHOD#' => $methodName,
1449 '#PARAM_NAME#' =>
'ownerId'
1453 if (!is_string(
$params[
'name']))
1455 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1456 '#PARAM_NAME#' =>
'name',
1460 if (isset(
$params[
'description']) && !is_string(
$params[
'description']))
1462 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1463 '#PARAM_NAME#' =>
'description',
1468 $sectionModel = SectionModel::createNew()
1473 if (!
$accessController->check(ActionDictionary::ACTION_SECTION_ADD, $sectionModel))
1475 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1479 'CAL_TYPE' =>
$type,
1480 'OWNER_ID' => $ownerId,
1482 'DESCRIPTION' => !empty(
$params[
'description']) ? trim(
$params[
'description']) :
''
1488 'ALLOW' => (bool)
$params[
'export'][
'ALLOW'],
1489 'SET' =>
$params[
'export'][
'SET']
1502 if (isset(
$params[
'text_color']))
1504 $arFields[
'TEXT_COLOR'] = CCalendar::Color(
$params[
'text_color'], $DEFAULT_TEXT_COLOR);
1508 $arFields[
'TEXT_COLOR'] = $DEFAULT_TEXT_COLOR;
1516 $id = CCalendar::SaveSection([
1517 'bAffectToDav' =>
false,
1523 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_NEW_ERROR'));
1526 CCalendarSect::SetClearOperationCache(
true);
1571 $userId = CCalendar::GetCurUserId();
1572 $methodName =
"calendar.section.update";
1580 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1581 '#REST_METHOD#' => $methodName,
1582 '#PARAM_NAME#' =>
'type'
1586 if (isset(
$params[
'ownerId']))
1588 $ownerId = (int)
$params[
'ownerId'];
1596 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'ownerId')));
1606 throw new RestException(Loc::getMessage(
'CAL_REST_SECT_ID_EXCEPTION'));
1611 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1612 '#PARAM_NAME#' =>
'name',
1616 if (isset(
$params[
'description']) && !is_string(
$params[
'description']))
1618 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
1619 '#PARAM_NAME#' =>
'description',
1625 SectionModel::createFromId($id)
1627 ->setOwnerId($ownerId)
1629 if (!
$accessController->check(ActionDictionary::ACTION_SECTION_EDIT, $sectionModel))
1631 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1636 'CAL_TYPE' =>
$type,
1637 'OWNER_ID' => $ownerId
1645 if (isset(
$params[
'description']) && trim(
$params[
'description']) !==
'')
1655 if (isset(
$params[
'text_color']))
1665 $id = (int)CCalendar::SaveSection([
1666 'bAffectToDav' =>
false,
1672 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_SAVE_ERROR'));
1700 $userId = CCalendar::GetCurUserId();
1701 $methodName =
"calendar.section.delete";
1709 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1710 '#REST_METHOD#' => $methodName,
1711 '#PARAM_NAME#' =>
'type'
1715 if (isset(
$params[
'ownerId']))
1717 $ownerId = (int)
$params[
'ownerId'];
1725 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'ownerId')));
1734 throw new RestException(Loc::getMessage(
'CAL_REST_SECT_ID_EXCEPTION'));
1739 SectionModel::createFromId($id)
1741 ->setOwnerId($ownerId)
1743 if (!
$accessController->check(ActionDictionary::ACTION_SECTION_EDIT, $sectionModel))
1745 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1748 $res = CCalendar::DeleteSection($id);
1752 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_DELETE_ERROR'));
1778 $userId = CCalendar::GetCurUserId();
1779 $methodName =
"calendar.meeting.status.set";
1781 $necessaryParams =
array(
'eventId',
'status');
1782 foreach ($necessaryParams as $param)
1786 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1787 '#PARAM_NAME#' => $param,
1788 '#REST_METHOD#' => $methodName
1794 if (!in_array(
$params[
'status'],
array(
'Y',
'N',
'Q')))
1796 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_ERROR', [
'#PARAM_NAME#' =>
'status']));
1799 CCalendarEvent::SetMeetingStatus(
array(
1801 'eventId' =>
$params[
'eventId'],
1826 $userId = CCalendar::GetCurUserId();
1827 $methodName =
"calendar.meeting.status.get";
1829 $necessaryParams =
array(
'eventId');
1830 foreach ($necessaryParams as $param)
1834 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1835 '#PARAM_NAME#' => $param,
1836 '#REST_METHOD#' => $methodName
1841 $status = CCalendarEvent::GetMeetingStatus(
1848 throw new RestException(Loc::getMessage(
'CAL_REST_GET_STATUS_ERROR'));
1859 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1884 $methodName =
"calendar.accessibility.get";
1888 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1891 $necessaryParams =
array(
'from',
'to',
'users');
1892 foreach ($necessaryParams as $param)
1896 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1897 '#PARAM_NAME#' => $param,
1898 '#REST_METHOD#' => $methodName
1903 $from = CRestUtil::unConvertDate(
$params[
'from']);
1904 $to = CRestUtil::unConvertDate(
$params[
'to']);
1906 return CCalendar::GetAccessibilityForUsers(
array(
1927 'work_time_start' => 9,
1928 'work_time_end' => 19,
1932 return CCalendar::GetSettings();
1960 $methodName =
"calendar.settings.set";
1962 if (!
$USER->CanDoOperation(
'bitrix24_config') && !
$USER->CanDoOperation(
'edit_php'))
1964 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1967 if (!isset(
$params[
'settings']))
1969 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION', [
1970 '#PARAM_NAME#' =>
'settings',
1971 '#REST_METHOD#' => $methodName
1975 CCalendar::SetSettings(
$params[
'settings']);
1994 if (!
$USER->CanDoOperation(
'bitrix24_config') && !
$USER->CanDoOperation(
'edit_php'))
1996 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
1999 CCalendar::SetSettings([],
true);
2013 $userId = CCalendar::GetCurUserId();
2015 return CCalendar::GetUserSettings(
$userId);
2042 $userId = CCalendar::GetCurUserId();
2043 $methodName =
"calendar.user.settings.set";
2045 if (!isset(
$params[
'settings']))
2047 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#PARAM_NAME#' =>
'settings',
'#REST_METHOD#' => $methodName)));
2068 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2073 $resourceList = Internals\SectionTable::getList(
2077 "=CAL_TYPE" =>
'resource'
2079 "select" => [
"ID",
"NAME",
"CREATED_BY"]
2083 while ($resource = $resourceList->fetch())
2085 $resources[] = $resource;
2109 $methodName =
"calendar.resource.add";
2114 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'name')));
2119 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2123 $typeModel = TypeModel::createFromXmlId(
$type);
2127 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2130 $id = \CCalendarSect::edit([
2132 'CAL_TYPE' =>
$type,
2140 throw new RestException(Loc::getMessage(
'CAL_REST_RESOURCE_NEW_ERROR'));
2143 CCalendarSect::SetClearOperationCache(
true);
2167 $methodName =
"calendar.resource.update";
2172 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2175 if (isset(
$params[
'resourceId']) && (
int)
$params[
'resourceId'] > 0)
2177 $id = (int)
$params[
'resourceId'];
2181 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'id')));
2186 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'name')));
2190 $typeModel = TypeModel::createFromXmlId(
$type);
2194 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2197 $id = \CCalendarSect::edit([
2200 'CAL_TYPE' =>
$type,
2208 throw new RestException(Loc::getMessage(
'CAL_REST_RESOURCE_UPDATE_ERROR'));
2211 CCalendarSect::SetClearOperationCache(
true);
2233 $userId = CCalendar::GetCurUserId();
2234 $methodName =
"calendar.resource.delete";
2236 if (isset(
$params[
'resourceId']) && (
int)
$params[
'resourceId'] > 0)
2238 $id = (int)
$params[
'resourceId'];
2242 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' =>
'resourceId')));
2247 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2251 $typeModel = TypeModel::createFromXmlId(Dictionary::CALENDAR_TYPE[
'resource']);
2255 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2258 $res = CCalendar::DeleteSection($id);
2262 throw new RestException(Loc::getMessage(
'CAL_REST_SECTION_DELETE_ERROR'));
2301 $methodName =
"calendar.resource.booking.list";
2303 $userId = CCalendar::GetCurUserId();
2307 throw new RestException(Loc::getMessage(
'CAL_REST_ACCESS_DENIED'));
2310 $idList = isset(
$params[
'filter']) && is_array(
$params[
'filter'])
2311 ? (
$params[
'filter'][
'resourceIdList'] ?? [])
2314 if (!empty($idList))
2316 if(!is_array($idList) && $idList > 0)
2318 $idList = [$idList];
2320 if (!empty($idList))
2322 $userId = CCalendar::GetCurUserId();
2328 if (is_array($resourseList) && isset($resourseList[
'ENTRIES']) && is_array($resourseList[
'ENTRIES']))
2330 foreach($resourseList[
'ENTRIES'] as $resEntry)
2332 $eventIdList[] = $resEntry[
'EVENT_ID'];
2333 $bookingIndex[$resEntry[
'EVENT_ID']] = (int)$resEntry[
'ID'];
2336 if (!empty($eventIdList))
2338 $entries = CCalendarEvent::GetList(
2340 'arFilter' =>
array(
2341 'ID' => $eventIdList
2343 'parseRecursion' =>
true,
2344 'fetchAttendees' =>
false,
2346 'fetchMeetings' =>
false,
2347 'setDefaultLimit' =>
false
2352 foreach($entries as
$k => $entry)
2354 $entries[
$k][
'RESOURCE_BOOKING_ID'] = $bookingIndex[$entry[
'ID']];
2362 $resourceTypeIdList = isset(
$params[
'filter']) && is_array(
$params[
'filter'])
2363 ? (
$params[
'filter'][
'resourceTypeIdList'] ?? [])
2366 if (empty($resourceTypeIdList) || !is_array($resourceTypeIdList))
2368 throw new RestException(Loc::getMessage(
'CAL_REST_PARAM_EXCEPTION',
array(
'#PARAM_NAME#' =>
'filter[\'resourceTypeIdList\']',
'#REST_METHOD#' => $methodName)));
2371 $from = isset(
$params[
'filter'][
'from']) ? CRestUtil::unConvertDateTime(
$params[
'filter'][
'from']) :
false;
2372 $to = isset(
$params[
'filter'][
'to']) ? CRestUtil::unConvertDateTime(
$params[
'filter'][
'to']) :
false;
2375 if ($from ===
false && $to ===
false)
2381 $from = CCalendar::Date($ts - CCalendar::DAY_LENGTH * $pastDays,
false);
2382 $to = CCalendar::Date($ts + CCalendar::DAY_LENGTH * $futureDays,
false);
2384 elseif($from !==
false && $to ===
false)
2386 $to = CCalendar::Date(CCalendar::GetMaxTimestamp(),
false);
2390 $entries = CCalendar::GetEventList([
2393 'section' => array_map(
'intval', $resourceTypeIdList),
2394 'fromLimit' => $from,
2401 foreach($entries as
$i => $eventEntry)
2403 $eventIdList[] = $eventEntry[
'ID'];
2404 $eventIndex[$eventEntry[
'ID']] =
$i;
2405 $entries[
$i][
'RESOURCE_BOOKING_ID'] =
null;
2408 $resourseList = \Bitrix\Calendar\Internals\ResourceTable::getList(
2410 "select" => [
"ID",
"EVENT_ID"],
2412 "=EVENT_ID" => $eventIdList
2417 while ($resBooking = $resourseList->fetch())
2419 if ($eventIndex[$resBooking[
'EVENT_ID']] >= 0)
2421 $entries[$eventIndex[$resBooking[
'EVENT_ID']]][
'RESOURCE_BOOKING_ID'] = $resBooking[
'ID'];
2669 $userId = CCalendar::GetCurUserId();
2701 if (isset(
$params[
'timezone_to']))
2706 if (isset(
$params[
'timezone_from']))
2710 if (!isset(
$params[
'timezone_to']))
2722 $arFields[
'TZ_FROM'] = $userTimezoneName;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getResourceEntriesList($idList=[])
static set($settings=[], $userId=false)
static includeModule($moduleName)
static GetUserTimezoneName($user, $getDefault=true)
static UserSettingsGet($params=[], $nav=null, $server=null)
static EventGetById($params=[], $nav=null, $server=null)
static EventAdd($params=[], $nav=null, $server=null)
static PrepareOnCalendarRoomEvent($params)
static UserSettingsSet($params=[], $nav=null, $server=null)
static PrepareOnCalendarSectionEvent($params, $handler)
static UserSettingsClear($params=[], $nav=null, $server=null)
static EventUpdate($params=[], $nav=null, $server=null)
static EventGetNearest($params=[], $nav=null, $server=null)
static ResourceUpdate($params=[], $nav=null, $server=null)
static OnRestServiceBuildDescription()
const PLACEMENT_GRID_VIEW
static MeetingAccessibilityGet($params=[], $nav=null, $server=null)
static SectionGet($params=[], $nav=null, $server=null)
static EventGet($params=[], $nav=null, $server=null)
static MeetingParamsSet($params=[], $nav=null, $server=null)
static MeetingStatusSet($params=[], $nav=null, $server=null)
static SectionUpdate($params=[], $nav=null, $server=null)
static MeetingStatusGet($params=[], $nav=null, $server=null)
static SettingsGet($params=[], $nav=null, $server=null)
static ResourceDelete($params=[], $nav=null, $server=null)
static SectionAdd($params=[], $nav=null, $server=null)
static ResourceBookingList($params=[])
static SectionDelete($params=[], $nav=null, $server=null)
static SettingsSet($params=[], $nav=null, $server=null)
static ResourceAdd($params=[], $nav=null, $server=null)
static EventDelete($params=[], $nav=null, $server=null)
static PrepareOnCalendarEntryEvent($params, $handler)
static urlAddParams($url, $add_params, $options=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']