Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
correcteventingoogle.php
1<?php
2
4
8
10{
11 protected static $moduleId = "calendar";
12
13 public static function className()
14 {
15 return get_called_class();
16 }
17
23 public function execute(array &$result): bool
24 {
26 }
27
31 private function getLocalEventWronglySent(): array
32 {
33 global $DB;
34
35 $events = [];
36 $strSql = "SELECT"
37 . " e.ID as ID,"
38 . " e.G_EVENT_ID as G_EVENT_ID,"
39 . " e.OWNER_ID as OWNER_ID,"
40 . " s.GAPI_CALENDAR_ID as GAPI_CALENDAR_ID,"
41 . " c.ID as CONNECTION_ID,"
42 . " s.ID as SECTION_ID"
43 . " FROM b_calendar_event e"
44 . " INNER JOIN b_calendar_section s"
45 . " ON e.SECTION_ID = s.ID"
46 . " INNER JOIN b_dav_connections c"
47 . " ON s.CAL_DAV_CON = c.ID"
48 . " WHERE"
49 . " e.MEETING_STATUS = 'N'"
50 . " AND e.G_EVENT_ID IS NOT NULL"
51 . " AND e.DATE_TO_TS_UTC >= " . $this->getSyncTimestamp()
52 . " AND e.SYNC_STATUS != '" . Dictionary::SYNC_STATUS['deleted'] . "'"
53 . " AND s.GAPI_CALENDAR_ID IS NOT NULL"
54 . " AND s.CAL_DAV_CON IS NOT NULL"
55 . " AND s.EXTERNAL_TYPE = 'local'"
56 . " LIMIT 10"
57 . ";"
58 ;
59
60 $eventsDb = $DB->Query($strSql);
61 while ($event = $eventsDb->Fetch())
62 {
63 $events[] = $event;
64 }
65
66 return $events;
67 }
68
69
74 public function getRecurrentEvents(): array
75 {
76 global $DB;
77
78 $events = [];
79 $strSql = "SELECT DISTINCT "
80 . "p.*"
81 . ", " . $DB->DateToCharFunction('p.DATE_FROM') . " as DATE_FROM"
82 . ", " . $DB->DateToCharFunction('p.DATE_TO') . " as DATE_TO"
83 . ", " . $DB->DateToCharFunction('p.DATE_CREATE') . " as DATE_CREATE"
84 . ", " . $DB->DateToCharFunction('p.TIMESTAMP_X') . " as TIMESTAMP_X"
85 . ", s.CAL_DAV_CON as CONNECTION_ID"
86 . ", s.GAPI_CALENDAR_ID as GAPI_CALENDAR_ID"
87 . ", GROUP_CONCAT(". $DB->DateToCharFunction('i.DATE_FROM')." SEPARATOR ';') as EXDATE"
88 . " FROM b_calendar_event p"
89 . " INNER JOIN b_calendar_event i"
90 . " ON i.RECURRENCE_ID = p.PARENT_ID"
91 . " AND p.OWNER_ID = i.OWNER_ID"
92 . " INNER JOIN b_calendar_section s"
93 . " ON s.ID = p.SECTION_ID"
94 . " WHERE"
95 . " p.RRULE IS NOT NULL"
96 . " AND p.DATE_TO_TS_UTC >= " . $this->getSyncTimestamp()
97 . " AND p.G_EVENT_ID IS NOT NULL"
98 . " AND p.SYNC_STATUS != '" . Dictionary::SYNC_STATUS['exdated'] . "'"
99 . " AND p.SYNC_STATUS != '" . Dictionary::SYNC_STATUS['delete'] . "'"
100 . " AND p.SYNC_STATUS != '" . Dictionary::SYNC_STATUS['deleted'] . "'"
101 . " AND i.MEETING_STATUS = 'N'"
102 . " AND s.EXTERNAL_TYPE = 'local'"
103 . " AND s.CAL_DAV_CON IS NOT NULL"
104 . " AND s.GAPI_CALENDAR_ID IS NOT NULL"
105 . " GROUP BY p.ID"
106 . " LIMIT 10"
107 . ";"
108 ;
109 $eventsDb = $DB->Query($strSql);
110
111 while ($event = $eventsDb->Fetch())
112 {
113 if (isset($event['REMIND']) && $event['REMIND'] !== "")
114 {
115 $event['REMIND'] = unserialize($event['REMIND'], ['allowed_classes' => false]);
116 }
117
118 $event['RRULE'] = \CCalendarEvent::ParseRRULE($event['RRULE']);
119
120 $events[] = $event;
121 }
122
123 return $events;
124 }
125
130 private function getSyncTimestamp(): int
131 {
132 return (new Type\Date())->add('-2 months')->getTimestamp();
133 }
134}