Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
calendareventviewformhelper.php
1<?php
2
4
7use CCalendar;
8use CCalendarEvent;
9use COption;
10
12{
13 //get parameters
14 public static function getTimezoneHint($userId, $event): string
15 {
16 $skipTime = $event['DT_SKIP_TIME'] === "Y";
17 $timezoneHint = '';
18 if (
19 !$skipTime
20 && (
21 (int)$event['~USER_OFFSET_FROM'] !== 0
22 || (int)$event['~USER_OFFSET_TO'] !== 0
23 || $event['TZ_FROM'] !== $event['TZ_TO']
24 || $event['TZ_FROM'] !== CCalendar::GetUserTimezoneName($userId)
25 )
26 )
27 {
28 if ($event['TZ_FROM'] === $event['TZ_TO'])
29 {
30 $timezoneHint = CCalendar::GetFromToHtml(
31 CCalendar::Timestamp($event['DATE_FROM']),
32 CCalendar::Timestamp($event['DATE_TO']),
33 false,
34 $event['DT_LENGTH']
35 );
36 if ($event['TZ_FROM'])
37 {
38 $timezoneHint .= ' (' . $event['TZ_FROM'] . ')';
39 }
40 }
41 else
42 {
43 $timezoneHint = Loc::getMessage('EC_VIEW_DATE_FROM_TO', array('#DATE_FROM#' => $event['DATE_FROM'].' ('.$event['TZ_FROM'].')', '#DATE_TO#' => $event['DATE_TO'].' ('.$event['TZ_TO'].')'));
44 }
45 }
46 return $timezoneHint;
47 }
48
49 public static function getFromToHtml(array $event): string
50 {
51 $skipTime = $event['DT_SKIP_TIME'] === "Y";
52 $fromTs = CCalendar::Timestamp($event['DATE_FROM']);
53 $toTs = CCalendar::Timestamp($event['DATE_TO']);
54 if ($skipTime)
55 {
56 $toTs += CCalendar::DAY_LENGTH;
57 }
58 else
59 {
60 $fromTs -= $event['~USER_OFFSET_FROM'];
61 $toTs -= $event['~USER_OFFSET_TO'];
62 }
63 return CCalendar::GetFromToHtml($fromTs, $toTs, $skipTime, $event['DT_LENGTH']);
64 }
65
66 public static function getMeetingCreator(array $event): array
67 {
68 $meetingCreator = [];
69 if (
70 $event['IS_MEETING']
71 && $event['MEETING']['MEETING_CREATOR']
72 && $event['MEETING']['MEETING_CREATOR'] !== $event['MEETING_HOST']
73 )
74 {
75 $meetingCreator = CCalendar::GetUser($event['MEETING']['MEETING_CREATOR'], true);
76 $meetingCreator['DISPLAY_NAME'] = CCalendar::GetUserName($meetingCreator);
77 $meetingCreator['URL'] = CCalendar::GetUserUrl(
78 $meetingCreator["ID"],
79 $meetingCreator["PATH_TO_USER"] ?? null
80 );
81 }
82 return $meetingCreator;
83 }
84
85 //get components
86 public static function getCrmView(array $event): Component
87 {
88 return new Component(
89 "bitrix:system.field.view",
90 $event['UF_CRM_CAL_EVENT']["USER_TYPE"]["USER_TYPE_ID"],
91 array("arUserField" => $event['UF_CRM_CAL_EVENT']),
92 array("HIDE_ICONS"=>"Y")
93 );
94 }
95
96 public static function getFilesView(array $event): Component
97 {
98 return new Component(
99 "bitrix:system.field.view",
100 $event['UF_WEBDAV_CAL_EVENT']["USER_TYPE"]["USER_TYPE_ID"],
101 array("arUserField" => $event['UF_WEBDAV_CAL_EVENT']),
102 array("HIDE_ICONS"=>"Y")
103 );
104 }
105
106 public static function getCommentsView(array $event): Component
107 {
108 $userId = CCalendar::GetCurUserId();
109 if (
110 $userId === (int)$event['CREATED_BY']
111 && ((int)$event['PARENT_ID'] === (int)$event['ID'] || !$event['PARENT_ID'])
112 )
113 {
114 $permission = "Y";
115 }
116 else
117 {
118 $permission = 'M';
119 }
120 $set = CCalendar::GetSettings();
121 $eventCommentId = $event['PARENT_ID'] ?: $event['ID'];
122
123 return new Component(
124 "bitrix:forum.comments", "bitrix24", [
125 "FORUM_ID" => $set['forum_id'],
126 "ENTITY_TYPE" => "EV",
127 "ENTITY_ID" => $eventCommentId,
128 "ENTITY_XML_ID" => $event['ENTITY_XML_ID'],
129 "PERMISSION" => $permission,
130 "URL_TEMPLATES_PROFILE_VIEW" => $set['path_to_user'],
131 "SHOW_RATING" => COption::GetOptionString('main', 'rating_vote_show', 'N'),
132 "SHOW_LINK_TO_MESSAGE" => "N",
133 "BIND_VIEWER" => "Y"
134 ],
135 ['HIDE_ICONS' => 'Y']
136 );
137 }
138
139}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29