1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
syncadapter.php
См. документацию.
1<?
5
6namespace Bitrix\Calendar\Integration\Dav;
7
8use Bitrix\Calendar\Integration\Tasks\TaskQueryParameter;
9use Bitrix\Calendar\Integration\Tasks\TaskUser;
10use Bitrix\Calendar\UserSettings;
11use Bitrix\Main\Loader;
12
13IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/calendar/classes/general/calendar.php");
14
16{
17 private static
18 $sectionIndex = [];
19
28 public static function getSectionList($entityType, $entityId, $params = [])
29 {
30 $sectionId = $params['sectionId'];
31 $sectionList = [];
32
33 if ($sectionId && self::$sectionIndex[$sectionId])
34 {
35 $sectionList[] = self::$sectionIndex[$sectionId];
36 }
37 else
38 {
39 if ($sectionId !== \CCalendar::TASK_SECTION_ID)
40 {
41 $filter = [
42 'CAL_TYPE' => $entityType,
43 'OWNER_ID' => $entityId
44 ];
45
46 if (!is_array($params))
47 {
48 $params = [];
49 }
50
51 if ($sectionId > 0)
52 {
53 $filter['ID'] = $sectionId;
54 }
55
56 \CCalendar::SetSilentErrorMode(true);
57 if (isset($params['active']))
58 {
59 $filter['ACTIVE'] = $params['active'] ? 'Y' : 'N';
60 }
61
62 $res = \CCalendarSect::GetList(['arFilter' => $filter]);
63 \CCalendar::SetSilentErrorMode(false);
64
65 foreach($res as $calendar)
66 {
67 if ($params['skipExchange'] == true && $calendar['DAV_EXCH_CAL'] <> '')
68 {
69 continue;
70 }
71
72 $section = [
73 'ID' => $calendar['ID'],
74 '~NAME' => $calendar['NAME'],
75 'NAME' => htmlspecialcharsbx($calendar['NAME']),
76 'COLOR' => htmlspecialcharsbx($calendar['COLOR'])
77 ];
78 $sectionList[] = $section;
79 self::$sectionIndex[$section['ID']] = $section;
80 }
81
82 // Temporary hide it, while waiting for new interface.
83 if (!$sectionId && false)
84 {
85 $followedSectionIdList = UserSettings::getFollowedSectionIdList($entityId);
86 if (count($followedSectionIdList) > 0)
87 {
88 $followedSectionList = \CCalendarSect::GetList(['arFilter' => [
89 'CAL_TYPE' => $entityType,
90 'OWNER_ID' => $entityId,
91 'ACTIVE' => 'Y',
92 'ADDITIONAL_IDS' => $followedSectionIdList
93 ]]);
94
95 foreach($followedSectionList as $calendar)
96 {
97 $section = [
98 'ID' => $calendar['ID'],
99 '~NAME' => $calendar['NAME'],
100 'NAME' => htmlspecialcharsbx($calendar['NAME']),
101 'COLOR' => htmlspecialcharsbx($calendar['COLOR'])
102 ];
103 $sectionList[] = $section;
104 self::$sectionIndex[$section['ID']] = $section;
105 }
106 }
107 }
108 }
109
110 if (\CCalendarSync::isTaskListSyncEnabled() && $entityType == 'user' && ($sectionId === \CCalendar::TASK_SECTION_ID || !$sectionId))
111 {
113 $taskSectionTitle = (isset($sectionsUserData['tasks']) && !empty($sectionsUserData['tasks']['name']))
114 ? $sectionsUserData['tasks']['name']
116
117 $section = [
118 'ID' => \CCalendar::TASK_SECTION_ID,
119 '~NAME' => $taskSectionTitle,
120 'NAME' => htmlspecialcharsbx($taskSectionTitle),
121 'COLOR' => (isset($sectionsUserData['tasks']) && !empty($sectionsUserData['tasks']['color'])) ?
122 htmlspecialcharsbx($sectionsUserData['tasks']['color']) : \CCalendar::DEFAULT_TASK_COLOR
123 ];
124 $sectionList[] = $section;
125 self::$sectionIndex[$section['ID']] = $section;
126 }
127 }
128
129 return $sectionList;
130 }
131
132
140 public static function getEventList($sectionId = false, $params = [])
141 {
142 $entryList = [];
143
144 if ($params['entityType'] === 'user')
145 {
146 $userId = $params['entityId'];
147 if ($sectionId === \CCalendar::TASK_SECTION_ID)
148 {
149 $entryList = self::getTaskList($userId);
150 }
151 else
152 {
153 \CCalendar::SetOffset(false, 0);
154 $filter = [
155 'DELETED' => 'N'
156 ];
157
158 if (isset($params['filter']['DAV_XML_ID']))
159 {
160 $filter['DAV_XML_ID'] = $params['filter']['DAV_XML_ID'];
161 }
162 else
163 {
164 if (isset($params['filter']['DATE_START']))
165 {
166 $filter['FROM_LIMIT'] = $params['filter']['DATE_START'];
167 }
168 if (isset($params['filter']['DATE_END']))
169 {
170 $filter['TO_LIMIT'] = $params['filter']['DATE_END'];
171 }
172 }
173
174 if ($sectionId > 0)
175 {
176 $filter['SECTION'] = $sectionId;
177 }
178
179 $events = \CCalendarEvent::GetList(
180 array(
181 'arFilter' => $filter,
182 'getUserfields' => false,
183 'parseRecursion' => false,
184 'fetchAttendees' => false,
185 'fetchMeetings' => !$sectionId || \CCalendar::getMeetingSection($userId, true) == $sectionId,
186 'userId' => $userId
187 )
188 );
189
190 foreach ($events as $event)
191 {
192 // Skip events from where owner is host of the meeting and it's meeting from other section
193 // or declined events
194 if($event['IS_MEETING'] && ($event["MEETING_STATUS"] == 'N' || ($event['MEETING_HOST'] == $userId && $event['SECTION_ID'] != $sectionId)))
195 {
196 continue;
197 }
198
199 $event['XML_ID'] = $event['DAV_XML_ID'];
200 $event['LOCATION'] = \CCalendar::GetTextLocation($event['LOCATION']);
201 $event['RRULE'] = \CCalendarEvent::ParseRRULE($event['RRULE']);
202 $entryList[] = $event;
203 }
204 }
205 }
206
207 return $entryList;
208 }
209
217 public static function getTaskList($userId, $params = [])
218 {
219 $tasksEntries = [];
220 if (Loader::includeModule('tasks'))
221 {
222 $tasksEntries = \CCalendar::getTaskList(
223 (new TaskQueryParameter(TaskUser::getId())) // <-- compatibility
224 ->setType(TaskQueryParameter::TYPE_USER)
225 ->setOwnerId($userId)
226 );
227
228 for ($i = 0, $l = count($tasksEntries); $i < $l; $i++)
229 {
230 $tasksEntries[$i]['TIMESTAMP_X'] = \CCalendar::Date(round(time() / 180) * 180);
231 $tasksEntries[$i]['DAV_XML_ID'] = 'task-'.$tasksEntries[$i]["ID"];
232 }
233 }
234
235 return $tasksEntries;
236 }
237
245 public static function deleteEvent($eventId, $params = [])
246 {
247 return \CCalendar::DeleteEvent($eventId);
248 }
249}
const BX_ROOT
Определения bx_root.php:3
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getSectionList($entityType, $entityId, $params=[])
Определения syncadapter.php:28
static getEventList($sectionId=false, $params=[])
Определения syncadapter.php:140
static deleteEvent($eventId, $params=[])
Определения syncadapter.php:245
static getTaskList($userId, $params=[])
Определения syncadapter.php:217
static getFollowedSectionIdList($userId=false)
Определения usersettings.php:330
static getSectionCustomization($userId=false)
Определения usersettings.php:288
static getMessage($code, $replace=null, $language=null)
Определения loc.php:30
static isTaskListSyncEnabled()
Определения calendar_sync.php:783
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$filter
Определения iblock_catalog_list.php:54
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$l
Определения options.php:783
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
$entityId
Определения payment.php:4
$event
Определения prolog_after.php:141
$i
Определения factura.php:643
</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."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799