24 $userId = \CCalendar::GetCurUserId();
27 Loader::includeModule(
'intranet')
28 && !ToolsManager::getInstance()->checkAvailabilityByToolId(
'calendar')
34 'isAvailable' =>
false,
40 $entry = \CCalendarEvent::getEventForViewInterface($entryId, [
41 'eventDate' => $dateFrom,
42 'timezoneOffset' => $timezoneOffset,
52 if (!$entry || !$entry[
'ID'])
58 $responseParams[
'userId'] = $userId;
59 $responseParams[
'userTimezone'] = \CCalendar::GetUserTimezoneName($userId);
60 $responseParams[
'entry'] = $entry;
61 $responseParams[
'userIndex'] = \CCalendarEvent::getUserIndex();
63 $responseParams[
'plannerFeatureEnabled'] = Bitrix24Manager::isPlannerFeatureEnabled();
64 $responseParams[
'entryUrl'] = \CHTTP::urlAddParams(
65 \CCalendar::GetPath($entry[
'CAL_TYPE'], $entry[
'OWNER_ID'],
true),
67 'EVENT_ID' => (
int)$entry[
'ID'],
68 'EVENT_DATE' => urlencode($entry[
'DATE_FROM'])
71 $responseParams[
'dayOfWeekMonthFormat'] = stripslashes(
74 ->getDayOfWeekMonthFormat()
77 $sections = \CCalendarSect::GetList([
79 'ID' => $entry[
'SECTION_ID'],
82 'checkPermissions' =>
false,
83 'getPermissions' =>
true
85 $responseParams[
'section'] = $sections[0] ??
null;
87 if (!$responseParams[
'section'])
93 $params = array_merge([
95 'type' => \CCalendar::GetType(),
96 'bIntranet' => \CCalendar::IsIntranetEnabled(),
97 'bSocNet' => \CCalendar::IsSocNet(),
101 $userId = \CCalendar::GetCurUserId();
102 $event = $params[
'event'];
106 $UF = \CCalendarEvent::GetEventUserFields($event);
108 if (isset($event[
'UF_CRM_CAL_EVENT']))
110 $event[
'UF_CRM_CAL_EVENT'] = $UF[
'UF_CRM_CAL_EVENT'];
111 if (empty($event[
'UF_CRM_CAL_EVENT'][
'VALUE']))
113 $event[
'UF_CRM_CAL_EVENT'] =
false;
117 if (isset($event[
'UF_WEBDAV_CAL_EVENT']))
119 $event[
'UF_WEBDAV_CAL_EVENT'] = $UF[
'UF_WEBDAV_CAL_EVENT'];
120 if(empty($event[
'UF_WEBDAV_CAL_EVENT'][
'VALUE']))
122 $event[
'UF_WEBDAV_CAL_EVENT'] =
false;
126 $event[
'REMIND'] = \CCalendarReminder::GetTextReminders($event[
'REMIND'] ?? []);
128 $event[
'permissions'] = \CCalendarEvent::getEventPermissions($event, $userId);
131 $userId = \CCalendar::GetCurUserId();
133 $viewComments = $event[
'permissions'][
'view_comments'];
136 $meetingHost =
false;
137 if ($event[
'IS_MEETING'])
139 $userIndex = \CCalendarEvent::getUserIndex();
140 $attendees = [
'y' => [],
'n' => [],
'q' => [],
'i' => []];
142 if (isset($event[
'ATTENDEE_LIST']) && is_array($event[
'ATTENDEE_LIST']))
144 foreach ($event[
'ATTENDEE_LIST'] as $attendee)
146 if ($userId === (
int)$attendee[
'id'])
148 $curUserStatus = $attendee[
'status'];
149 $viewComments =
true;
152 $status = (mb_strtolower($attendee[
'status']) ===
'h' || empty($attendee[
'status']))
154 : $attendee[
'status']
156 $attendees[mb_strtolower($status)][] = $userIndex[$attendee[
'id']];
157 if ($attendee[
'status'] ===
'H')
159 $meetingHost = $userIndex[$attendee[
'id']];
160 $meetingHost[
'ID'] = $attendee[
'id'];
166 if (!$meetingHost && isset($event[
'MEETING_HOST']))
168 $meetingHost = \CCalendar::GetUser($event[
'MEETING_HOST'],
true);
171 if ($meetingHost && is_array($meetingHost))
173 $meetingHost[
'DISPLAY_NAME'] = \CCalendar::GetUserName($meetingHost);
174 if (!isset($meetingHost[
'AVATAR']))
176 $meetingHost[
'AVATAR'] = \CCalendar::GetUserAvatarSrc($meetingHost);
178 $meetingHost[
'URL'] = \CCalendar::GetUserUrl($meetingHost[
"ID"], ($params[
"PATH_TO_USER"] ??
''));
181 $params[
'id'] =
'calendar_view_slider_'.mt_rand();
182 $params[
'event'] = $event;
183 $params[
'eventId'] = $event[
'ID'];
184 $params[
'parentId'] = $event[
'PARENT_ID'];
185 $params[
'name'] = $event[
'NAME'];
186 $params[
'fromToHtml'] = $this->getFromToHtml($event);
187 $params[
'timezoneHint'] = $timezoneHint;
188 $params[
'isMeeting'] = $event[
'IS_MEETING'];
189 $params[
'isRemind'] = $event[
'REMIND'];
190 $params[
'isRrule'] = $event[
'RRULE'];
191 $params[
'rruleDescription'] = \CCalendarEvent::GetRRULEDescription($event,
false);
193 $params[
'avatarSize'] = 34;
194 $params[
'attendees'] = $attendees ?? [];
196 $params[
'curUserStatus'] = $curUserStatus;
197 $params[
'meetingHost'] = $meetingHost;
198 $params[
'meetingHostDisplayName'] = $meetingHost[
'DISPLAY_NAME'] ??
null;
199 $params[
'meetingHostWorkPosition'] = htmlspecialcharsbx($meetingHost[
'WORK_POSITION'] ??
null);
201 $meetingCreator = $this->getMeetingCreator($event);
202 $params[
'meetingCreatorUrl'] = $meetingCreator[
'URL'] ??
null;
203 $params[
'meetingCreatorDisplayName'] = $meetingCreator[
'DISPLAY_NAME'] ??
null;
205 $params[
'isHighImportance'] = $event[
'IMPORTANCE'] ===
'high';
206 $params[
'description'] = $event[
'~DESCRIPTION'] ??
null;
208 $params[
'isWebdavEvent'] = $event[
'UF_WEBDAV_CAL_EVENT'] ??
null;
209 $params[
'isCrmEvent'] = $event[
'UF_CRM_CAL_EVENT'] ??
null;
211 $params[
'accessibility'] = $event[
'ACCESSIBILITY'];
212 $params[
'isIntranetEnabled'] = \CCalendar::IsIntranetEnabled();
213 $params[
'isPrivate'] = $event[
'PRIVATE_EVENT'];
215 $params[
'location'] = htmlspecialcharsbx(\CCalendar::GetTextLocation($event[
'LOCATION'] ??
null));
217 $params[
'canEditCalendar'] = $event[
'permissions'][
'edit'];
218 $params[
'canDeleteEvent'] = $event[
'permissions'][
'delete'];
220 $params[
'showComments'] = $viewComments;
223 if (!empty($params[
'isWebdavEvent']))
225 $params[
'filesView'] = $this->getFilesView($event)->getContent();
227 if (!empty($params[
'isCrmEvent']))
229 $params[
'crmView'] = $this->getCrmView($event)->getContent();
233 'UF_CRM_CAL_EVENT' => $params[
'event'][
'UF_CRM_CAL_EVENT'] ??
null,
234 'UF_WEBDAV_CAL_EVENT' => $params[
'event'][
'UF_WEBDAV_CAL_EVENT'] ??
null,
235 'PARENT_ID' => $params[
'event'][
'PARENT_ID'],
236 'ID' => $params[
'event'][
'ID'],
237 'CREATED_BY' => $params[
'event'][
'CREATED_BY'],
240 $params[
'event'] = \CCalendarEvent::FixCommentsIfEventIsBroken($params[
'event']);
243 isset($params[
'event'][
'RELATIONS'][
'COMMENT_XML_ID'])
244 && $params[
'event'][
'RELATIONS'][
'COMMENT_XML_ID']
247 $signedEvent[
'ENTITY_XML_ID'] = $params[
'event'][
'RELATIONS'][
'COMMENT_XML_ID'];
251 $signedEvent[
'ENTITY_XML_ID'] = \CCalendarEvent::GetEventCommentXmlId($params[
'event']);
254 $params[
'signedEvent'] = (
new Signer())->sign(Json::encode($signedEvent));