29 'getTimezoneList' => [
39 $timezones = \CCalendar::getTimezoneList();
40 $defaultTimezone = \CCalendar::getGoodTimezoneForOffset(\CCalendar::getCurrentOffsetUTC(\CCalendar::getCurUserId()));
41 if (isset($timezones[$defaultTimezone]))
43 $timezones[$defaultTimezone][
'default'] =
true;
51 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
60 $isNew = (!isset($id) || !$id);
62 $ownerId = (int)
$request->getPost(
'ownerId');
63 $name = trim(
$request->getPost(
'name'));
65 $customization =
$request->getPost(
'customization') ===
'Y';
66 $userId = \CCalendar::GetUserId();
67 $isPersonal = $type ===
'user' && $ownerId === $userId;
79 'OWNER_ID' => $ownerId,
80 'ACCESS' =>
$request->getPost(
'access'),
81 'EXTERNAL_TYPE' =>
$request->getPost(
'external_type') ??
'local',
84 if ($customization && !$isNew)
90 if (Loader::includeModule(
'extranet') && !\CExtranet::IsIntranetUser(SITE_ID, $userId))
94 && Loader::includeModule(
'socialnetwork')
97 $r = \Bitrix\Socialnetwork\UserToGroupTable::getList([
99 '@ROLE' => \
Bitrix\Socialnetwork\UserToGroupTable::getRolesMember(),
100 '=GROUP_ID' => $ownerId,
101 '=USER_ID' => $userId,
105 if (!$group = $r->fetch())
122 if ($type ===
'group')
125 if (!\CCalendarType::CanDo(
'calendar_type_edit_section',
'group'))
132 if (Loader::includeModule(
'socialnetwork'))
134 $result = \Bitrix\Socialnetwork\UserToGroupTable::getList([
136 '@ROLE' => \
Bitrix\Socialnetwork\UserToGroupTable::getRolesMember(),
137 '=GROUP_ID' => $ownerId,
138 '=USER_ID' => $userId,
142 $group = $result->fetch();
151 else if ($type ===
'user')
160 else if (!\CCalendarType::CanDo(
'calendar_type_edit_section', $type))
167 $fields[
'IS_EXCHANGE'] =
$request->getPost(
'is_exchange') ===
'Y';
171 $section = \CCalendarSect::GetById($id);
175 && !\CCalendarSect::CanDo(
'calendar_edit_section', $id, $userId)
183 if (!\CCalendarType::CanDo(
'calendar_type_edit_section', $section[
'CAL_TYPE']))
190 $fields[
'CAL_TYPE'] = $section[
'CAL_TYPE'];
191 $fields[
'OWNER_ID'] = $section[
'OWNER_ID'];
196 $id = \CCalendar::SaveSection([
'arFields' => $fields]);
199 \CCalendarSect::SetClearOperationCache(
true);
200 $response[
'section'] = \CCalendarSect::GetById($id,
true,
true);
201 if (!$response[
'section'])
207 $response[
'accessNames'] = \CCalendar::GetAccessNames();
209 $response[
'sectionList'] = \CCalendarSect::prepareSectionListResponse($type, $ownerId);
229 if (!\CCalendar::IsPersonal() && !\CCalendarSect::CanDo(
'calendar_edit_section', $id, \CCalendar::GetUserId()))
234 $section = \CCalendarSect::GetById($id);
236 if ($section && $section[
'CAL_DAV_CON'])
238 \CCalendarSect::Edit([
246 $sections = \CCalendarSect::GetList([
248 'CAL_DAV_CON' => $section[
'CAL_DAV_CON'],
253 if (empty($sections))
255 \CCalendar::setOwnerId(\CCalendar::GetUserId());
256 \CCalendar::RemoveConnection([
'id' => (
int)$section[
'CAL_DAV_CON'],
'del_calendars' =>
true]);
265 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
274 if ($mode ===
'users')
276 $userIds =
$request->get(
'userIdList');
277 $ormRes = \Bitrix\Main\UserTable::getList([
278 'filter' => [
'=ID' => $userIds],
279 'select' => [
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME']
281 while ($user = $ormRes->fetch())
283 $user[
'FORMATTED_NAME'] = \CCalendar::GetUserName($user);
287 $sections = \CCalendarSect::getSuperposedList([
'USERS' => $userIds]);
289 elseif ($mode ===
'groups')
291 $groupIds =
$request->get(
'groupIdList') ?? [];
292 $sections = \CCalendarSect::getSuperposedList([
'GROUPS' => $groupIds]);
294 if (Loader::includeModule(
'socialnetwork'))
296 foreach($groupIds as $groupId)
298 $groupId = (int)$groupId;
299 $createDefaultGroupSection = \CSocNetFeatures::isActiveFeature(
305 if ($createDefaultGroupSection)
307 foreach($sections as $section)
309 if ((
int)$section[
'OWNER_ID'] === $groupId)
311 $createDefaultGroupSection =
false;
317 if ($createDefaultGroupSection)
319 $sections[] = \CCalendarSect::createDefault([
321 'ownerId' => $groupId
330 $typesRes = \CCalendarType::GetList();
331 foreach($typesRes as $type)
333 if ($type[
'XML_ID'] !==
'user'
334 && $type[
'XML_ID'] !==
'group'
335 && $type[
'XML_ID'] !==
'location')
337 $types[] = $type[
'XML_ID'];
341 $sections = \CCalendarSect::getSuperposedList([
'TYPES' => $types]);
346 'sections' => $sections
355 $userId = \CCalendar::getCurUserId();
356 if ($type ===
'users')
361 $sections =
$request->get(
'sections');
367 \CCalendar::setDisplayedSuperposed($userId, $sections);
374 $responseParams = [];
375 $uniqueId =
'calendar_edit_slider_'.mt_rand();
376 $formType = preg_replace(
'/\W/',
'',
$request->get(
'form_type'));
377 $entryId = (int)
$request->get(
'event_id');
378 $userCodes =
$request->get(
'userCodes');
379 $userId = \CCalendar::GetCurUserId();
380 $ownerId = (int)
$request->get(
'ownerId');
386 $fromTs = !empty($_REQUEST[
'date_from_offset']) ? \CCalendar::Timestamp($_REQUEST[
'date_from']) - $_REQUEST[
'date_from_offset'] : \CCalendar::Timestamp($_REQUEST[
'date_from']);
387 $entry = \CCalendarEvent::getEventForEditInterface($entryId, [
'eventDate' => \CCalendar::Date($fromTs)]);
388 $entryId = is_array($entry) && isset($entry[
'ID']) ? (int)$entry[
'ID'] : $entryId;
395 if (!$entryId || (!empty($entry) && \CCalendarSceleton::CheckBitrix24Limits([
'id' => $uniqueId])))
397 $responseParams[
'uniqueId'] = $uniqueId;
398 $responseParams[
'userId'] = $userId;
399 $responseParams[
'editorId'] = $uniqueId.
'_entry_slider_editor';
400 $responseParams[
'entry'] = $entry;
401 $responseParams[
'timezoneList'] = \CCalendar::GetTimezoneList();
406 if (($type ===
'user' && $ownerId !== $userId) || $type !==
'user')
408 $sectionList = \CCalendar::getSectionList([
410 'OWNER_ID' => $ownerId,
412 'checkPermissions' =>
true,
413 'getPermissions' =>
true
416 foreach($sectionList as $section)
418 if ($section[
'PERM'][
'edit'] || $section[
'PERM'][
'add'])
420 $sections[] = $section;
425 if (empty($sections) && $type ===
'group')
427 $sections[] = \CCalendarSect::createDefault(array(
429 'ownerId' => $ownerId
433 $sections = array_merge(
435 \CCalendar::getSectionListAvailableForUser($userId, (array)($entry[
'SECTION_ID'] ??
null))
438 $responseParams[
'sections'] = [];
439 foreach($sections as $section)
442 !\CCalendarSect::CheckGoogleVirtualSection(
443 $section[
'GAPI_CALENDAR_ID'] ??
null,
444 $section[
'EXTERNAL_TYPE'] ??
null,
448 ($entryId && \CCalendarSect::CanDo(
'calendar_edit', $section[
'ID'], $userId))
449 || (!$entryId && \CCalendarSect::CanDo(
'calendar_add', $section[
'ID'], $userId))
453 $responseParams[
'sections'][] = $section;
457 $responseParams[
'dayOfWeekMonthFormat'] = stripslashes(
460 ->getDayOfWeekMonthFormat()
464 $responseParams[
'eventWithEmailGuestLimit'] = Bitrix24Manager::getEventWithEmailGuestLimit();
465 $responseParams[
'countEventWithEmailGuestAmount'] = Bitrix24Manager::getCountEventWithEmailGuestAmount();
466 $responseParams[
'iblockMeetingRoomList'] = Rooms\IBlockMeetingRoom::getMeetingRoomList();
467 $responseParams[
'userIndex'] = \CCalendarEvent::getUserIndex();
468 $responseParams[
'locationFeatureEnabled'] = Bitrix24Manager::isFeatureEnabled(
"calendar_location");
469 if ($responseParams[
'locationFeatureEnabled'])
471 $responseParams[
'locationList'] = Rooms\Manager::getRoomsList();
472 $responseParams[
'locationAccess'] = Rooms\Util::getLocationAccess($userId);
474 $responseParams[
'plannerFeatureEnabled'] = Bitrix24Manager::isPlannerFeatureEnabled();
475 $responseParams[
'attendeesEntityList'] = ($entryId > 0 && !empty($entry[
'attendeesEntityList']))
476 ? $entry[
'attendeesEntityList']
478 $responseParams[
'meetSection'] =
null;
479 if ($type === Dictionary::EVENT_TYPE[
'user'])
481 $responseParams[
'meetSection'] =
UserSettings::get($ownerId)[
'meetSection'] ??
null;
484 return new \Bitrix\Main\Engine\Response\Component(
485 'bitrix:calendar.edit.slider',
490 'formType' => $formType,
491 'type' => \CCalendar::GetType(),
492 'bIntranet' => \CCalendar::IsIntranetEnabled(),
493 'bSocNet' => \CCalendar::IsSocNet(),
495 'ATTENDEES_CODES' => $userCodes
509 $responseParams = [];
510 $uniqueId =
'calendar_view_slider_'.mt_rand();
511 $entryId = (int)
$request->get(
'entryId');
512 $userId = \CCalendar::GetCurUserId();
517 $entry = \CCalendarEvent::getEventForViewInterface($entryId,
519 'eventDate' =>
$request->get(
'dateFrom'),
520 'timezoneOffset' => (
int)
$request->get(
'timezoneOffset'),
532 $responseParams[
'uniqueId'] = $uniqueId;
533 $responseParams[
'userId'] = $userId;
534 $responseParams[
'userTimezone'] = \CCalendar::GetUserTimezoneName($userId);
535 $responseParams[
'entry'] = $entry;
536 $responseParams[
'userIndex'] = \CCalendarEvent::getUserIndex();
538 $responseParams[
'plannerFeatureEnabled'] = Bitrix24Manager::isPlannerFeatureEnabled();
539 $responseParams[
'entryUrl'] = \CHTTP::urlAddParams(
540 \CCalendar::GetPath($entry[
'CAL_TYPE'], $entry[
'OWNER_ID'],
true),
542 'EVENT_ID' => (
int)$entry[
'ID'],
543 'EVENT_DATE' => urlencode($entry[
'DATE_FROM'])
545 $responseParams[
'dayOfWeekMonthFormat'] = stripslashes(
548 ->getDayOfWeekMonthFormat()
551 $sections = \CCalendarSect::GetList([
553 'ID' => $entry[
'SECTION_ID'],
556 'checkPermissions' =>
false,
557 'getPermissions' =>
true
560 $responseParams[
'section'] = isset($sections[0]) ? $sections[0] :
null;
562 return new \Bitrix\Main\Engine\Response\Component(
563 'bitrix:calendar.view.slider',
568 'type' => \CCalendar::GetType(),
569 'sectionName' => $_REQUEST[
'section_name'],
570 'bIntranet' => \CCalendar::IsIntranetEnabled(),
571 'bSocNet' => \CCalendar::IsSocNet(),
586 $UF = \CCalendarEvent::GetEventUserFields([
'PARENT_ID' => (
int)
$request->get(
'event_id')]);
587 if (isset($UF[
'UF_CRM_CAL_EVENT']))
589 $crmUF = $UF[
'UF_CRM_CAL_EVENT'];
590 $additionalResponseParams = [];
591 return new \Bitrix\Main\Engine\Response\Component(
592 'bitrix:system.field.edit',
593 $crmUF[
"USER_TYPE"][
"USER_TYPE_ID"],
595 "bVarsFromForm" =>
false,
596 "arUserField" => $crmUF,
597 "form_name" =>
'event_edit_form'
599 $additionalResponseParams
609 $entryId = (int)
$request[
'entryId'];
610 $userId = \CCalendar::getCurUserId();
611 $ownerId = (int)
$request[
'ownerId'];
617 if (!$hostId && $type ===
'user' && !$entryId)
622 if (Loader::includeModule(
'intranet'))
624 if (!\
Bitrix\Intranet\Util::isIntranetUser($userId) && !$isExtranetUser)
633 $entries = \CExtranet::getMyGroupsUsersSimple(\CExtranet::GetExtranetSiteID());
636 if (!$entryId &&
$request[
'cur_event_id'])
638 $entryId = (int)
$request[
'cur_event_id'];
650 if (
$request[
'add_cur_user_to_list'] ===
'Y' || count($codes) == 0)
652 $codes[] =
'U'.$userId;
655 $prevUserList = is_array(
$request[
'prevUserList']) ?
$request[
'prevUserList'] : [];
660 return \CCalendarPlanner::prepareData([
661 'entry_id' => $entryId,
662 'user_id' => $userId,
663 'host_id' => $hostId,
665 'entryLocation' => trim(
$request[
'entryLocation']),
666 'entries' => $entries,
667 'date_from' => $dateFrom,
668 'date_to' => $dateTo,
670 'location' => trim(
$request[
'location']),
671 'roomEventId' => (
int)
$request[
'roomEventId'],
672 'initPullWatches' =>
true,
673 'prevUserList' => $prevUserList
680 \CCalendarPlanner::Init(array(
'id' =>
$request[
'planner_id']));
688 $response[
'result'] = \CCalendar::deleteEvent(
692 'recursionMode' => $recursionMode,
693 'requestUid' => (
int)$requestUid
697 if ($response[
'result'] !==
true)
707 $response = [
'result' =>
false];
709 $event = \CCalendarEvent::GetById((
int)$entryId);
710 $untilTimestamp = \CCalendar::Timestamp($untilDate);
715 if (\CCalendarEvent::CheckRecurcion($event))
717 $event[
'RRULE'] = \CCalendarEvent::ParseRRULE($event[
'RRULE']);
718 $event[
'RRULE'][
'UNTIL'] = \CCalendar::Date($untilTimestamp,
false);
719 if (isset($event[
'RRULE'][
'COUNT']))
721 unset($event[
'RRULE'][
'COUNT']);
724 $id = \CCalendar::SaveEvent(array(
726 "ID" => $event[
"ID"],
727 "RRULE" => $event[
'RRULE']
729 'silentErrorMode' =>
false,
730 'recursionEditMode' =>
'skip',
731 'editParentEvents' =>
true,
732 'editEntryUntil' =>
true,
734 $recId = $event[
"ID"];
735 $response[
'id'] = $id;
738 if ($event[
"RECURRENCE_ID"] > 0)
740 $recParentEvent = \CCalendarEvent::GetById($event[
"RECURRENCE_ID"]);
741 if ($recParentEvent && \CCalendarEvent::CheckRecurcion($recParentEvent))
743 $recParentEvent[
'RRULE'] = \CCalendarEvent::ParseRRULE($recParentEvent[
'RRULE']);
745 if ($recParentEvent[
'RRULE'][
'UNTIL']
746 && \CCalendar::Timestamp($recParentEvent[
'RRULE'][
'UNTIL']) > $untilTimestamp)
748 $recParentEvent[
'RRULE'][
'UNTIL'] = \CCalendar::Date($untilTimestamp,
false);
750 if (isset($recParentEvent[
'RRULE'][
'COUNT']))
752 unset($recParentEvent[
'RRULE'][
'COUNT']);
755 $id = \CCalendar::SaveEvent(array(
757 "ID" => $recParentEvent[
"ID"],
758 "RRULE" => $recParentEvent[
'RRULE']
760 'silentErrorMode' =>
false,
761 'recursionEditMode' =>
'skip',
762 'editParentEvents' =>
true,
763 'editEntryUntil' =>
true,
765 $response[
'id'] = $id;
769 $recId = $event[
"RECURRENCE_ID"];
774 $recRelatedEvents = \CCalendarEvent::GetEventsByRecId($recId,
false);
775 foreach($recRelatedEvents as $ev)
777 if (\CCalendar::Timestamp($ev[
'DATE_FROM']) > $untilTimestamp)
779 \CCalendar::DeleteEvent((
int)$ev[
'ID'],
true, array(
'recursionMode' =>
'this'));
784 $response[
'result'] =
true;
787 if ($response[
'result'] !==
true)
798 \CCalendarEvent::ExcludeInstance((
int)$entryId, $excludeDate);
806 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
811 $sectionList = SectionTable::getList([
825 if (!($section = $sectionList->fetch()))
830 if ($section && !\CCalendarType::CanDo(
'calendar_type_edit', $section[
'CAL_TYPE']))
835 if (!\CCalendar::IsPersonal() && !\CCalendarSect::CanDo(
'calendar_edit_section', $id, \CCalendar::GetUserId()))
842 \CCalendar::DeleteSection($id);
850 $userId = \CCalendar::GetCurUserId();
854 \CCalendarEvent::SetMeetingStatusEx([
855 'attendeeId' => $userId,
856 'eventId' => (
int)
$request->getPost(
'entryId'),
857 'parentId' => (
int)
$request->getPost(
'entryParentId'),
858 'status' =>
$request->getPost(
'status'),
859 'reccurentMode' =>
$request->getPost(
'recursionMode'),
860 'currentDateFrom' =>
$request->getPost(
'currentDateFrom')
863 \CCalendar::UpdateCounter([$userId]);
873 $entryId = (int)
$request->getPost(
'entryId');
874 $userId = \CCalendar::GetUserId();
875 $entry = \CCalendarEvent::GetById($entryId);
877 if (\CCalendarSect::CanDo(
'calendar_edit', $entry[
'SECTION_ID'], $userId))
879 $entry[
'REMIND'] = \CCalendarReminder::prepareReminder(
$request->getPost(
'reminders'));
880 $response[
'REMIND'] = $entry[
'REMIND'];
881 $response[
'id'] = \CCalendar::SaveEvent([
883 'ID' => $entry[
'ID'],
884 'REMIND' => $entry[
'REMIND']
886 'updateReminders' =>
true,
889 \CCalendar::ClearCache(
'event_list');
899 $params[
'type'] =
$request->getPost(
'type');
900 $params[
'userId'] = \CCalendar::getCurUserId();
902 return \CCalendarSync::GetSyncInfo($params);
907 $attestedSectionsStatus = [];
909 $sectionsStatus =
$request[
'sectionStatus'];
910 $userId = \CCalendar::getCurUserId();
912 foreach ($sectionsStatus as $sectionId => $sectionStatus)
914 $sectionStatus = json_decode($sectionStatus);
915 if (is_int($sectionId) && is_bool($sectionStatus))
917 $attestedSectionsStatus[$sectionId] = $sectionStatus;
921 if ($attestedSectionsStatus && $userId > 0)
923 \CCalendarSync::SetSectionStatus($userId, $attestedSectionsStatus);
940 $entryId = intVal(
$request->getPost(
'entryId'));
941 $userId = \CCalendar::GetUserId();
942 $entry = \CCalendarEvent::GetById($entryId);
944 if (\CCalendarSect::CanDo(
'calendar_edit', $entry[
'SECTION_ID'], $userId))
946 \CCalendarEvent::updateColor($entryId,
$request->getPost(
'color'));
947 \CCalendar::ClearCache(
'event_list');
955 $uid = preg_replace(
'/\W/',
'', $uid);
957 $userId = \CCalendar::getCurUserId();
958 $additionalResponseParams = [
960 'mailboxList' => \Bitrix\Calendar\Integration\Sender\AllowedSender::getList($userId)
963 return new \Bitrix\Main\Engine\Response\Component(
964 'bitrix:calendar.settings.slider',
968 'is_personal' => $showPersonalSettings ===
'Y',
969 'show_general_settings' => $showGeneralSettings ===
'Y',
970 'show_access_control' => $showAccessControl ===
'Y'
972 $additionalResponseParams
978 $userId = \CCalendar::getCurUserId();
979 return new \Bitrix\Main\Engine\Response\Component(
980 'bitrix:main.mail.confirm',
984 'mailboxList' => \
Bitrix\Calendar\Integration\Sender\AllowedSender::getList($userId)
991 $userId = \CCalendar::getCurUserId();
993 'mailboxList' => \Bitrix\Calendar\Integration\Sender\AllowedSender::getList($userId)
1000 $loadSectionId = (int)
$request[
'loadSectionId'];
1002 if ($loadSectionId > 0)
1004 $result[
'section'] = \CCalendarSect::GetById($loadSectionId);
1012 'sections' => \CCalendarSect::prepareSectionListResponse($type, (
int) $ownerId)
1018 $userId = \CCalendar::GetCurUserId();
1019 \CCalendar::UpdateCounter([$userId]);
1028 $userId = \CCalendar::GetCurUserId();
1029 $key = preg_replace(
"/[^a-zA-Z0-9_:\.]/is",
"", $key);
1030 if ($key && $sectionId)
1033 $userSettings[
'defaultSections'][$key] = $sectionId;
1043 public function saveSettingsAction(
string $type, array $user_settings = [],
string $user_timezone_name =
'', array $settings = []): void
1046 $userId = \CCalendar::GetCurUserId();
1052 if (\CCalendarType::CanDo(
'calendar_type_edit_access', $type))
1055 if (!empty($settings) )
1057 \CCalendar::SetSettings($settings);
1060 if (!empty(
$request[
'type_access']))
1062 \CCalendarType::Edit([
1065 'ACCESS' =>
$request[
'type_access']
1071 if (!empty($user_timezone_name))
1073 \CCalendar::SaveUserTimezoneName($userId, $user_timezone_name);
1074 \CCalendar::ClearCache(
'event_list');
1080 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
1088 'ownerId' =>
$request->getPost(
'ownerId'),
1089 'userId' =>
$request->getPost(
'userId'),
1090 'type' =>
$request->getPost(
'type'),
1096 public function getConferenceChatIdAction(
int $eventId)
1100 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
1114 $chatId = (
new Sharing\SharingConference($eventLink))->getConferenceChatId();
1118 $this->
addError(
new Error(
'Conference not found'));
1123 $result[
'chatId'] = $chatId;
getSettingsSliderAction($uid, $showPersonalSettings, $showGeneralSettings, $showAccessControl)
getAllowedMailboxListAction()
getAllowedMailboxDataAction()
getViewEventSliderAction()
getSectionListAction($type, $ownerId)
updateDefaultSectionIdAction(string $key, int $sectionId)
changeRecurciveEntryUntilAction($entryId, $untilDate)
setTrackingSectionsAction()
saveSettingsAction(string $type, array $user_settings=[], string $user_timezone_name='', array $settings=[])
sendAnalyticsLabelAction()
hideExternalCalendarSectionAction()
getEditEventSliderAction()
deleteCalendarEntryAction($entryId, $recursionMode, $requestUid)
excludeRecursionDateAction($entryId, $excludeDate)
deleteCalendarSectionAction($id)
getTrackingSectionsAction()
editCalendarSectionAction()
getCompactFormDataAction()
static getFilterData(array $params)
static getValues(int $userId)
static getFormSettings($formType, $userId=false)
static setTrackingUsers($userId=false, $value=[])
static set($settings=[], $userId=false)
static setSectionCustomization($userId=false, $data=[])
static getTrackingUsers($userId=false, $params=[])
static isExtranetUser(int $userId)
static getDefaultEntityList($userId, $type, $ownerId)
static convertEntitiesToCodes($entityList=[])
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)