24 private static $mobileBannerDisplay;
37 [$sectionId, $entityType,
$entityId] = $calendarId;
41 $bExchange = CCalendar::IsExchangeEnabled(
$userId) && $entityType ===
'user';
43 CCalendar::SetSilentErrorMode();
44 if ($sectionId && ($section = CCalendarSect::GetById((
int)$sectionId,
false)))
46 CCalendar::SetOffset(
false, CCalendar::GetOffset(
$userId));
50 'CAL_DAV_LABEL' => (isset(
$arFields[
'PROPERTY_BXDAVCD_LABEL']) &&
$arFields[
'PROPERTY_BXDAVCD_LABEL']) ?
$arFields[
'PROPERTY_BXDAVCD_LABEL'] :
'',
51 'DAV_EXCH_LABEL' => (isset(
$arFields[
'PROPERTY_BXDAVEX_LABEL']) &&
$arFields[
'PROPERTY_BXDAVEX_LABEL']) ?
$arFields[
'PROPERTY_BXDAVEX_LABEL'] :
'',
54 'CAL_TYPE' => $section[
'CAL_TYPE'],
55 'OWNER_ID' => $section[
'OWNER_ID'],
56 'DESCRIPTION' =>
$arFields[
'DESCRIPTION'] ??
'',
57 'SECTIONS' => [$sectionId],
58 'ACCESSIBILITY' =>
$arFields[
'ACCESSIBILITY'] ??
'busy',
59 'IMPORTANCE' =>
$arFields[
'IMPORTANCE'] ??
'normal',
63 'PRIVATE_EVENT' => (bool)(
$arFields[
'PRIVATE_EVENT'] ??
null)
66 $currentEvent = CCalendarEvent::getList([
68 'DAV_XML_ID' => $arNewFields[
'DAV_XML_ID'],
76 $currentEvent = $currentEvent[0];
79 $arNewFields[
'DATE_FROM'] =
$arFields[
'DATE_FROM'];
80 $arNewFields[
'DATE_TO'] =
$arFields[
'DATE_TO'];
81 $arNewFields[
'TZ_FROM'] =
$arFields[
'TZ_FROM'];
82 $arNewFields[
'TZ_TO'] =
$arFields[
'TZ_TO'];
83 $arNewFields[
'SKIP_TIME'] =
$arFields[
'SKIP_TIME'];
87 $arNewFields[
'RECURRENCE_ID'] =
$arFields[
'RECURRENCE_ID'];
92 $arNewFields[
'ORIGINAL_DATE_FROM'] =
$arFields[
'RECURRENCE_ID_DATE'];
95 if (isset($arNewFields[
'SKIP_TIME']) && $arNewFields[
'SKIP_TIME'])
97 $arNewFields[
'DATE_FROM'] = CCalendar::Date(CCalendar::Timestamp($arNewFields[
'DATE_FROM']),
false);
98 $arNewFields[
'DATE_TO'] = CCalendar::Date(CCalendar::Timestamp($arNewFields[
'DATE_TO']) - CCalendar::GetDayLen(),
false);
101 if (!empty(
$arFields[
'PROPERTY_REMIND_SETTINGS']))
103 if (is_array(
$arFields[
'PROPERTY_REMIND_SETTINGS']))
105 foreach (
$arFields[
'PROPERTY_REMIND_SETTINGS'] as $remindSetting)
107 $ar = explode(
'_', $remindSetting);
108 $arNewFields = self::prepareRemind(
$ar, $arNewFields);
113 $ar = explode(
'_',
$arFields[
'PROPERTY_REMIND_SETTINGS']);
114 $arNewFields = self::prepareRemind(
$ar, $arNewFields);
118 if (!empty(
$arFields[
'PROPERTY_ACCESSIBILITY']))
120 $arNewFields[
'ACCESSIBILITY'] =
$arFields[
'PROPERTY_ACCESSIBILITY'];
122 if (!empty(
$arFields[
'PROPERTY_IMPORTANCE']))
124 $arNewFields[
'IMPORTANCE'] =
$arFields[
'PROPERTY_IMPORTANCE'];
126 if (!empty(
$arFields[
'PROPERTY_LOCATION']))
128 $arNewFields[
'LOCATION'] = Bitrix\Calendar\Rooms\Util::unParseTextLocation(
$arFields[
'PROPERTY_LOCATION']);
132 if (empty(
$arFields[
'MEETING'][
'LANGUAGE_ID']))
134 $arNewFields[
'MEETING'][
'LANGUAGE_ID'] = CCalendar::getUserLanguageId((
int)$arNewFields[
'OWNER_ID']);
138 self::getAttendeesCodesForCut($currentEvent[
'ATTENDEES_CODES'] ??
null),
139 $arNewFields[
'MEETING'][
'LANGUAGE_ID']
143 $arNewFields[
'DESCRIPTION'] = CCalendar::ClearExchangeHtml($arNewFields[
'DESCRIPTION']);
145 if (isset(
$arFields[
'PROPERTY_PERIOD_TYPE']) && in_array(
$arFields[
'PROPERTY_PERIOD_TYPE'], [
"DAILY",
"WEEKLY",
"MONTHLY",
"YEARLY"]))
147 $arNewFields[
'RRULE'][
'FREQ'] =
$arFields[
"PROPERTY_PERIOD_TYPE"];
148 $arNewFields[
'RRULE'][
'INTERVAL'] =
$arFields[
"PROPERTY_PERIOD_COUNT"];
150 if (!isset($arNewFields[
'DT_LENGTH']) && !empty(
$arFields[
'PROPERTY_EVENT_LENGTH']))
152 $arNewFields[
'DT_LENGTH'] = (int)
$arFields[
'PROPERTY_EVENT_LENGTH'];
160 $arNewFields[
'DT_LENGTH'] =
null;
163 if ($arNewFields[
'RRULE'][
'FREQ'] ===
"WEEKLY" && !empty(
$arFields[
'PROPERTY_PERIOD_ADDITIONAL']))
165 $arNewFields[
'RRULE'][
'BYDAY'] = [];
166 $bydays = explode(
',',
$arFields[
'PROPERTY_PERIOD_ADDITIONAL']);
167 foreach($bydays as $day)
169 $day = CCalendar::WeekDayByInd($day,
false);
172 $arNewFields[
'RRULE'][
'BYDAY'][] = $day;
176 $arNewFields[
'RRULE'][
'BYDAY'] = implode(
',',$arNewFields[
'RRULE'][
'BYDAY']);
179 if (isset(
$arFields[
'PROPERTY_RRULE_COUNT']))
181 $arNewFields[
'RRULE'][
'COUNT'] =
$arFields[
'PROPERTY_RRULE_COUNT'];
185 $arNewFields[
'RRULE'][
'UNTIL'] =
$arFields[
'PROPERTY_PERIOD_UNTIL'];
189 $arNewFields[
'RRULE'][
'UNTIL'] =
$arFields[
'DT_TO_TS'] ??
null;
194 $arNewFields[
'EXDATE'] =
$arFields[
"EXDATE"];
201 && (($bExchange && self::isExchangeMeetingEnabled()) ||
$params[
'handleMeetingParams'])
204 $arNewFields[
'IS_MEETING'] =
$arFields[
'IS_MEETING'];
205 $arNewFields[
'MEETING_HOST'] =
$arFields[
'MEETING_HOST'];
206 $arNewFields[
'MEETING'] =
$arFields[
'MEETING'];
207 $arNewFields[
'ATTENDEES_CODES'] =
$arFields[
'ATTENDEES_CODES'];
210 $eventId = CCalendar::SaveEvent([
211 'arFields' => $arNewFields,
213 'bAffectToDav' =>
false,
214 'bSilentAccessMeeting' =>
true,
215 'autoDetectSection' =>
false,
216 'sendInvitations' => (
$params[
'sendInvitations'] ??
null) !==
false,
217 'syncCaldav' =>
$params[
'caldav'] ??
null,
228 && $currentEvent[
'ID']
229 && (
int)$sectionId !== (
int)$currentEvent[
'SECTION_ID']
230 && !$currentEvent[
'RECURRENCE_ID']
231 && $arNewFields[
'OWNER_ID'] === $currentEvent[
'OWNER_ID']
234 CCalendar::DeleteEvent($currentEvent[
'ID']);
239 CCalendarSect::UpdateModificationLabel($sectionId);
245 && (
$arFields[
'ATTENDEES_RESPONSE'] ??
null)
247 && self::isExchangeMeetingEnabled()
252 CCalendarEvent::SetMeetingStatus([
253 'userId' => $attendeeId,
254 'eventId' => $eventId,
256 'personalNotification' =>
false,
257 'hostNotification' =>
false,
258 'affectRecRelatedEvents' =>
false,
259 'updateDescription' =>
false,
260 'doSendMail' =>
false,
266 CCalendar::SetSilentErrorMode(
false);
273 CCalendar::SetSilentErrorMode();
274 $parentEvent = CCalendarEvent::GetById(
$params[
'parentId']);
276 if ($parentEvent && CCalendarEvent::CheckRecurcion($parentEvent))
278 $excludeDates = CCalendarEvent::GetExDate($parentEvent[
'EXDATE']);
282 if (isset($parentEvent[
'IS_MEETING']) && $parentEvent[
'IS_MEETING'])
284 $arFields[
'IS_MEETING'] = $parentEvent[
'IS_MEETING'];
285 $arFields[
'MEETING_HOST'] = $parentEvent[
'MEETING_HOST'];
286 $arFields[
'MEETING'] = $parentEvent[
'MEETING'];
287 $arFields[
'ATTENDEES_CODES'] = $parentEvent[
'ATTENDEES_CODES'];
290 $arFields[
'RECURRENCE_ID'] = $parentEvent[
'ID'];
295 'handleMeetingParams' => $parentEvent[
'IS_MEETING'],
296 'sendInvitations' =>
false,
301 $excludeDates[] = CCalendar::Date(CCalendar::Timestamp(
$arFields[
'RECURRENCE_ID_DATE']),
false);
307 'ID' => $parentEvent[
'ID'],
308 'EXDATE' => CCalendarEvent::SetExDate($excludeDates)
310 'bSilentAccessMeeting' =>
true,
311 'recursionEditMode' =>
'skip',
312 'silentErrorMode' =>
true,
313 'sendInvitations' =>
false,
314 'bAffectToDav' =>
false,
315 'sendEditNotification' =>
false
319 CCalendar::SetSilentErrorMode(
false);
324 $sectionId =
$params[
'sectionId'];
325 $modeSync =
$params[
'modeSync'];
326 $parameters[
'editInstance'] =
$params[
'editInstance'];
327 $bExchange =
$params[
'bExchange'];
329 $parameters[
'syncCaldav'] =
$params[
'syncCaldav'];
331 if (isset(
$event[
'DAV_XML_ID']))
335 if (isset(
$event[
'DAV_EXCH_LABEL']))
339 if (isset(
$event[
'CAL_DAV_LABEL']))
352 $section = CCalendarSect::GetById($sectionId,
false);
354 if (
$event && (
int)
$event[
'SECT_ID'] !== (
int)$sectionId)
356 $bCalDavCur = CCalendar::IsCalDAVEnabled() &&
$event[
'CAL_TYPE'] ===
'user' &&
$event[
'CAL_DAV_LABEL'] <>
'';
357 $bExchangeEnabledCur = CCalendar::IsExchangeEnabled() &&
$event[
'CAL_TYPE'] ===
'user';
359 if ($bExchangeEnabledCur || $bCalDavCur)
362 'bCalDav' => $bCalDavCur,
363 'bExchangeEnabled' => $bExchangeEnabledCur,
364 'sectionId' =>
$event[
'SECT_ID']
367 if (
$event[
'DAV_EXCH_LABEL'])
369 $event[
'DAV_EXCH_LABEL'] =
'';
374 return CCalendar::ThrowError(
$res);
378 $newSection = CCalendarSect::GetById(
$event[
'SECT_ID'],
false);
380 if ($section[
'CAL_DAV_CON'] === $newSection[
'CAL_DAV_CON']
381 && $section[
'ID'] !== $newSection[
'ID'])
389 CCalendarEvent::CheckFields($arDavFields);
391 if ($arDavFields[
'RRULE'] !=
'')
393 $arDavFields[
'RRULE'] =
$arFields[
'RRULE'];
396 if ($arDavFields[
'LOCATION'][
'NEW'] !==
'')
398 $arDavFields[
'LOCATION'][
'NEW'] = CCalendar::GetTextLocation($arDavFields[
'LOCATION'][
'NEW']);
400 $arDavFields[
'PROPERTY_IMPORTANCE'] = $arDavFields[
'IMPORTANCE'];
401 $arDavFields[
'PROPERTY_LOCATION'] = $arDavFields[
'LOCATION'][
'NEW'];
403 $arDavFields[
'PROPERTY_REMIND_SETTINGS'] =
'';
406 $arDavFields[
'PROPERTY_REMIND_SETTINGS'] = floatVal(
$arFields[
'REMIND'][0][
'count'] ??
null)
410 if (isset($arDavFields[
'RRULE'][
'BYDAY']) && is_array($arDavFields[
'RRULE'][
'BYDAY']))
412 $arDavFields[
'RRULE'][
'BYDAY'] = implode(
',',$arDavFields[
'RRULE'][
'BYDAY']);
416 if ($bCalDav && ($section[
'CAL_DAV_CON'] ??
null) > 0 && empty($parameters[
'syncCaldav']))
421 $DAVRes = CDavGroupdavClientCalendar::DoAddItem(
422 $section[
'CAL_DAV_CON'],
423 $section[
'CAL_DAV_CAL'] ??
null,
429 $DAVRes = CDavGroupdavClientCalendar::DoUpdateItem(
430 $section[
'CAL_DAV_CON'],
431 $section[
'CAL_DAV_CAL'] ??
null,
432 $event[
'DAV_XML_ID'] ??
null,
433 $event[
'CAL_DAV_LABEL'] ??
null,
438 if (!is_array($DAVRes) || !isset($DAVRes[
'XML_ID']))
440 return CCalendar::CollectCalDAVErros($DAVRes);
444 $arFields[
'DAV_XML_ID'] = $DAVRes[
'XML_ID'];
445 $arFields[
'CAL_DAV_LABEL'] = $DAVRes[
'MODIFICATION_LABEL'];
448 elseif ($bExchange && $section[
'IS_EXCHANGE'] && $section[
'DAV_EXCH_CAL'] <>
'' && $section[
'DAV_EXCH_CAL'] !== 0 && $modeSync)
450 $ownerId =
$arFields[
'OWNER_ID'] ??
null;
456 self::isExchangeMeetingEnabled()
458 && (
$arFields[
'MEETING_HOST'] ??
null) != $ownerId
459 && CCalendar::IsExchangeEnabled(
$arFields[
'MEETING_HOST'] ??
null)
462 $parentEvent = CCalendarEvent::GetById(
$arFields[
'PARENT_ID']);
463 if ($parentEvent[
'DAV_EXCH_LABEL'])
465 $parentSection = CCalendarSect::GetById($parentEvent[
'SECT_ID'],
false);
467 $parentSection[
'IS_EXCHANGE']
468 && $parentSection[
'DAV_EXCH_CAL'] <>
''
469 && $parentSection[
'DAV_EXCH_CAL'] !== 0)
477 self::isExchangeMeetingEnabled()
479 && (
int)
$arFields[
'MEETING_HOST'] === (
int)$ownerId
484 if (empty($arDavFields[
'REQUIRED_ATTENDEES']))
486 unset($arDavFields[
'REQUIRED_ATTENDEES']);
490 $fromTo = CCalendarEvent::GetEventFromToForUser($arDavFields, $ownerId);
491 $arDavFields[
"DATE_FROM"] = $fromTo[
'DATE_FROM'];
492 $arDavFields[
"DATE_TO"] = $fromTo[
'DATE_TO'];
495 $arDavFields[
"DESCRIPTION"] = CCalendarEvent::ParseText($arDavFields[
'DESCRIPTION']);
496 $updateEvent = !(
$params[
'editInstance']);
498 if (
$params[
'editParentEvents'] && !empty($arDavFields[
'RRULE'][
'UNTIL']))
501 $arDavFields[
'DATE_TO_TS_UTC'] = $until->add(
'-1 day')->getTimestamp();
507 || (
$event && !
$event[
'DAV_EXCH_LABEL'] && $updateEvent)
510 $exchRes = CDavExchangeCalendar::DoAddItem($ownerId, $section[
'DAV_EXCH_CAL'], $arDavFields);
514 $exchRes = CDavExchangeCalendar::DoUpdateItem($ownerId,
$event[
'DAV_XML_ID'],
$event[
'DAV_EXCH_LABEL'], $arDavFields,
$params);
517 if (!is_array($exchRes) || !array_key_exists(
"XML_ID", $exchRes))
519 return CCalendar::CollectExchangeErrors($exchRes);
523 $arFields[
'DAV_XML_ID'] = $exchRes[
'XML_ID'];
524 $arFields[
'DAV_EXCH_LABEL'] = $exchRes[
'MODIFICATION_LABEL'];
532 $sectionId =
$params[
'sectionId'];
533 $section = CCalendarSect::GetById($sectionId,
false);
535 $bExchangeEnabled =
$params[
'bExchangeEnabled'];
539 if ($bCalDav && $section[
'CAL_DAV_CON'] > 0 &&
$event[
'CAL_DAV_LABEL'])
541 $DAVRes = CDavGroupdavClientCalendar::DoDeleteItem($section[
'CAL_DAV_CON'], $section[
'CAL_DAV_CAL'],
$event[
'DAV_XML_ID']);
$service = new \Bitrix\Calendar\Sync\Icloud\VendorSyncService();
542 if ($DAVRes !==
true)
544 return CCalendar::CollectCalDAVErros($DAVRes);
548 if ($bExchangeEnabled && $section[
'IS_EXCHANGE'])
550 $exchRes = CDavExchangeCalendar::DoDeleteItem(
$event[
'OWNER_ID'],
$event[
'DAV_XML_ID']);
551 if ($exchRes !==
true)
552 return CCalendar::CollectExchangeErrors($exchRes);
580 CCalendar::SetSilentErrorMode();
581 $entityType = mb_strtolower($entityType);
584 $tempUser = CCalendar::TempUser(
false,
true);
586 foreach ($arCalendars as $value)
588 $calendarNames[$value[
"XML_ID"]] = $value;
594 'CAL_TYPE' => $entityType,
596 '!CAL_DAV_CAL' =>
false,
597 'CAL_DAV_CON' => $connectionId
599 $xmlIdField =
"CAL_DAV_CAL";
600 $xmlIdModLabel =
"CAL_DAV_MOD";
605 'CAL_TYPE' => $entityType,
607 '!DAV_EXCH_CAL' =>
false,
610 $xmlIdField =
"DAV_EXCH_CAL";
611 $xmlIdModLabel =
"DAV_EXCH_MOD";
614 $res = CCalendarSect::GetList([
616 'checkPermissions' =>
false,
617 'getPermissions' =>
false
620 foreach(
$res as $section)
622 $xmlId = $section[$xmlIdField];
623 $modificationLabel = $section[$xmlIdModLabel];
633 if (!array_key_exists($xmlId, $calendarNames))
635 CCalendarSect::Delete($section[
"ID"]);
639 if ($modificationLabel !== $calendarNames[$xmlId][
"MODIFICATION_LABEL"])
641 CCalendarSect::Edit([
643 "ID" => $section[
"ID"],
644 "NAME" => $calendarNames[$xmlId][
"NAME"],
645 "OWNER_ID" => $entityType ===
'user' ?
$entityId : 0,
646 "CREATED_BY" => $entityType ===
'user' ?
$entityId : 0,
647 "DESCRIPTION" => $calendarNames[$xmlId][
"DESCRIPTION"],
648 "COLOR" => $calendarNames[$xmlId][
"COLOR"],
649 $xmlIdModLabel => $calendarNames[$xmlId][
"MODIFICATION_LABEL"],
654 if (empty($modificationLabel) || ($modificationLabel !== $calendarNames[$xmlId][
"MODIFICATION_LABEL"]))
658 "CALENDAR_ID" => [$section[
"ID"], $entityType,
$entityId]
662 unset($calendarNames[$xmlId]);
666 foreach($calendarNames as
$key => $value)
669 'CAL_TYPE' => $entityType,
671 'NAME' => $value[
"NAME"],
672 'DESCRIPTION' => $value[
"DESCRIPTION"] ??
null,
673 'COLOR' => $value[
"COLOR"] ??
null,
674 'EXPORT' => [
'ALLOW' =>
false],
675 'CREATED_BY' => $entityType ===
'user' ?
$entityId : 0,
677 'EXTERNAL_TYPE' => $connectionType,
679 $xmlIdModLabel => $value[
"MODIFICATION_LABEL"] ?? null
684 $arFields[
"CAL_DAV_CON"] = $connectionId;
686 if ($entityType ===
'user')
695 $id = (int)CCalendar::SaveSection([
'arFields' =>
$arFields,
'bAffectToDav' =>
false]);
710 CCalendar::TempUser($tempUser,
false);
711 CCalendar::SetSilentErrorMode(
false);
723 if (CCalendar::IsSocNet())
725 if(is_array($idList))
727 $idList = array_unique($idList);
731 $idList =
array($idList);
735 foreach($idList as $id)
739 $strIdList .=
','.(int)$id;
742 $strIdList = trim($strIdList,
', ');
746 $exchangeMailbox = COption::GetOptionString(
"dav",
"exchange_mailbox",
"");
747 $exchangeUseLogin = COption::GetOptionString(
"dav",
"exchange_use_login",
"Y");
749 $strSql =
"SELECT U.ID, U.LOGIN, U.EMAIL, BUF.UF_BXDAVEX_MAILBOX
751 LEFT JOIN b_uts_user BUF ON (BUF.VALUE_ID = U.ID)
754 U.ID in (".$strIdList.
")";
757 while($entry =
$res->Fetch())
759 $users[$entry[
'ID']] = (($exchangeUseLogin ===
"Y")
760 ? $entry[
"LOGIN"].$exchangeMailbox
761 : $entry[
"UF_BXDAVEX_MAILBOX"])
763 if (empty($users[$entry[
'ID']]))
765 $users[$entry[
'ID']] = $entry[
'EMAIL'];
776 if (!isset(self::$handleExchangeMeeting))
778 self::$handleExchangeMeeting = COption::GetOptionString(
'calendar',
'sync_exchange_meeting',
false);
780 return self::$handleExchangeMeeting;
786 return $userSettings[
'showTasks'] ===
'Y' && $userSettings[
'syncTasks'] ===
'Y';
800 ?
array $attendeesCodes,
804 if (empty($attendeesCodes))
812 $countSeparators =
count($attendeesCodes) - 1;
816 return trim(preg_replace(
"%,%",
"",
$description, $countSeparators));
826 if (is_array($attendeesCodes))
828 return $attendeesCodes;
831 if (is_string($attendeesCodes) &&
$res = explode(
',', $attendeesCodes))
841 $offset = \CTimeZone::GetOffset(
$userId,
true);
842 return static function($date) use ($offset) {
844 ? \CCalendar::Timestamp($date,
false,
true) - $offset
851 $userId = \CCalendar::getCurUserId();
859 $bExchangeConnected =
false;
863 $bExchange = \CCalendar::IsExchangeEnabled() &&
$params[
'type'] ===
'user';
864 $bExchangeConnected = $bExchange && \CDavExchangeCalendar::IsExchangeEnabledForUser(
$userId);
873 'connected' => $macSyncInfo[
'connected'],
874 'status' => $macSyncInfo[
'status'],
875 'syncOffset' => time() - $calculateTimestamp($macSyncInfo[
'date']),
880 'connected' => $iphoneSyncInfo[
'connected'],
881 'status' => $iphoneSyncInfo[
'status'],
882 'syncOffset' => time() - $calculateTimestamp($iphoneSyncInfo[
'date']),
887 'connected' => $androidSyncInfo[
'connected'],
888 'status' => $androidSyncInfo[
'status'],
889 'syncOffset' => time() - $calculateTimestamp($androidSyncInfo[
'date']),
896 $syncInfo[
'outlook'] = [
899 'connected' => $outlookSyncInfo[
'connected'],
900 'status' => $outlookSyncInfo[
'status'],
901 'infoBySections' => ($outlookSyncInfo[
'infoBySections'] ??
''),
902 'syncOffset' => time() - $calculateTimestamp($outlookSyncInfo[
'date'] ??
false),
908 $syncInfo[
'exchange'] = [
909 'type' =>
'exchange',
910 'active' => $bExchange,
911 'connected' => $bExchangeConnected,
912 'status' => $exchangeSyncInfo[
'status'],
913 'syncOffset' => time() - $calculateTimestamp($exchangeSyncInfo[
'date']),
917 $caldavConnections = self::GetCaldavItemsInfo(
$userId,
$params[
'type'], $calculateTimestamp);
918 if (is_array($caldavConnections))
920 $syncInfo = array_merge($syncInfo, $caldavConnections);
923 $newSyncConnections = self::getNewSyncItemsInfo(
$userId, $calculateTimestamp);
924 if (!empty($newSyncConnections))
926 $syncInfo = array_merge($syncInfo, $newSyncConnections);
943 $activeSyncPeriod = self::SYNC_TIME;
944 $syncTypes =
array(
'iphone',
'android',
'mac',
'exchange');
946 'connected' =>
false,
950 if (in_array($syncType, $syncTypes,
true))
952 $result[
'date'] = CUserOptions::GetOption(
"calendar",
"last_sync_".$syncType,
false,
$userId);
957 $result[
'date'] = CCalendar::Date(CCalendar::Timestamp(
$result[
'date']) + CCalendar::GetOffset(
$userId),
true,
true,
true);
958 $period = time() - CCalendar::Timestamp(
$result[
'date']);
960 if ($period <= $activeSyncPeriod)
977 $activeSyncPeriod = 604800;
978 $syncTypes = [
'outlook'];
981 'connected' =>
false,
983 'syncOffset' => $activeSyncPeriod
986 if (in_array($syncType, $syncTypes,
true))
988 $options = CUserOptions::GetOption(
"calendar",
"last_sync_".$syncType,
false,
$userId);
997 $dateTs = \CCalendar::Timestamp($date,
false);
998 $period = time() - $dateTs;
1000 if ($dateTs > $lastSync)
1002 $lastSync = $dateTs;
1005 if ($period <= $activeSyncPeriod)
1009 $result[
'syncOffset'] = $period;
1017 $lastSync = \CCalendar::Timestamp(
$options,
false);
1018 $period = time() - $lastSync;
1019 if ($period <= $activeSyncPeriod)
1023 $result[
'syncOffset'] = $period;
1039 public static function GetCaldavItemsInfo(
$userId,
$type, $calculateTimestamp): ?
array
1042 $bCalDAV = CCalendar::IsCalDAVEnabled() &&
$type ===
'user';
1043 $bGoogleApi = CCalendar::isGoogleApiEnabled() &&
$type ===
'user';
1045 if ($bCalDAV || $bGoogleApi)
1047 $res = CDavConnection::GetList(
1050 'ENTITY_TYPE' =>
'user',
1059 $isRussian = Util::checkRuZone();
1061 $googleHelper = ServiceLocator::getInstance()->get(
'calendar.service.google.helper');
1063 $caldavHelper = ServiceLocator::getInstance()->get(
'calendar.service.caldav.helper');
1069 if ($caldavHelper->isYandex(
$connection[
'SERVER_HOST']) && $isRussian)
1074 'connected' =>
true,
1080 'syncOffset' => time() - $calculateTimestamp(
$connection[
'SYNCHRONIZED']),
1085 $connections[Bitrix\Calendar\Sync\Caldav\Helper::CALDAV_TYPE .
$connection[
'ID']] = [
1088 'connected' =>
true,
1091 'type' => Bitrix\Calendar\Sync\Caldav\Helper::CALDAV_TYPE,
1094 'syncOffset' => time() - $calculateTimestamp(
$connection[
'SYNCHRONIZED']),
1100 return $connections;
1106 public static function getNewSyncItemsInfo(
$userId, $calculateTimestamp):
array
1110 if (!Loader::includeModule(
'dav'))
1115 $connections = CDavConnection::GetList(
1118 'ENTITY_TYPE' =>
'user',
1120 'ACCOUNT_TYPE' => Sync\Dictionary::NEW_SYNC_PROVIDERS_TYPE,
1126 $googleHelper = ServiceLocator::getInstance()->get(
'calendar.service.google.helper');
1128 $iCloudHelper = ServiceLocator::getInstance()->get(
'calendar.service.icloud.helper');
1130 $office365Helper = ServiceLocator::getInstance()->get(
'calendar.service.office365.helper');
1135 $iCloudHelper->isVendorConnection(
$connection[
'ACCOUNT_TYPE'])
1136 || $office365Helper->isVendorConnection(
$connection[
'ACCOUNT_TYPE'])
1142 'connected' =>
true,
1148 'syncOffset' => time() - $calculateTimestamp(
$connection[
'SYNCHRONIZED']),
1151 else if ($googleHelper->isGoogleConnection(
$connection[
'ACCOUNT_TYPE']))
1153 $result[$googleHelper::CONNECTION_NAME] = [
1154 'type' => $googleHelper::CONNECTION_NAME,
1157 'connected' =>
true,
1158 'userName' =>
$connection[
'SERVER_USERNAME'] ??
null,
1161 'syncOffset' => time() - $calculateTimestamp(
$connection[
'SYNCHRONIZED']),
1172 $googleService = Bitrix\Calendar\Core\Oauth\Factory::getInstance()->getByName(
'google');
1173 $office365Service = Bitrix\Calendar\Core\Oauth\Factory::getInstance()->getByName(
'office365');
1176 'google' => $googleService ? $googleService->getUrl() :
'',
1177 'office365' => $office365Service ? $office365Service->getUrl() :
'',
1187 if (is_array($sectionsStatus))
1189 foreach ($sectionsStatus as $id =>
$status)
1191 $section = CCalendarSect::GetById($id);
1193 if ((
int)$section[
'OWNER_ID'] ===
$userId)
1202 $params[
'arFields'] = $sectionStatus;
1204 \CCalendarSect::Edit(
$params);
1216 $userId = \CCalendar::getCurUserId();
1219 \CDavGroupdavClientCalendar::DataSync(
"user",
$userId);
1223 if (\CCalendar::isGoogleApiEnabled() || \CCalendar::isOffice365ApiEnabled())
1226 FactoriesCollection::createByUserId(
1237 if (CCalendar::IsExchangeEnabled(
$userId))
1261 return (!is_null($lastResult) && preg_match(
"/^\[(2\d\d|0)\][a-z0-9 _]*/i", $lastResult));
1264 public static function deactivateConnection(
int $connectionId)
1267 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
1268 $connection = $mapperFactory->getConnection()->getMap([
1269 '=ID' => $connectionId,
1270 '=ENTITY_TYPE' =>
'user',
1271 '=ENTITY_ID' => \CCalendar::getCurUserId(),
1272 '=IS_DELETED' =>
'N'
1290 private static function prepareRemind(
$ar,
array $arNewFields):
array
1294 $arNewFields[
"REMIND"][] = [
1296 'value' =>
new DateTime(
$ar[0],
'Ymd\\THis\\Z'),
1301 $arNewFields[
"REMIND"][] =
1304 'count' => floatVal(
$ar[0])
1308 return $arNewFields;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
const COUNTER_SYNC_ERRORS
static addEvent(string $type, array $data)
static getAttendees(array $codeAttendees=null, string $stringWrapper='')
static includeModule($moduleName)
static getMessage($code, $replace=null, $language=null)
static createFromTimestamp($timestamp)
static getTimestampWithUserOffset($userId)
static getAttendeesCodesForCut($attendeesCodes)
static DoDeleteToDav($params, $event)
static UpdateUserConnections()
static ModifyReccurentInstances($params=array())
static isTaskListSyncEnabled()
static ModifyEvent($calendarId, $arFields, $params=[])
static GetSyncInfo($params=[])
static GetMultipleSyncInfoItem($userId, $syncType)
static isConnectionSuccess(string $lastResult=null)
static $handleExchangeMeeting
static SetSectionStatus(?int $userId=0, ?array $sectionsStatus=[])
static isExchangeMeetingEnabled()
static SyncCalendarSections($connectionType, $arCalendars, $entityType, $entityId, $connectionId=null)
static $doNotSendToGoogle
static GetSyncInfoItem($userId, $syncType)
static CutAttendeesFromDescription(?string $description, ?array $attendeesCodes, ?string $languageId)
static GetExchangeEmailForUser($idList=[])
static DoSaveToDav(&$arFields, $params=[], $event=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
$_SERVER["DOCUMENT_ROOT"]
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']