19 return get_called_class();
24 if (Loader::includeModule(
"calendar")
25 && Option::get(
'calendar',
'needEventIndex',
'Y') ===
'N')
30 $status = $this->loadCurrentStatus();
32 if ($status[
'finished'])
38 'count' => $status[
'count'],
39 'steps' => $status[
'steps'],
40 'sectionFinished' => $status[
'sectionFinished'],
41 'finished' => $status[
'finished']
45 if (!$status[
'sectionFinished'])
47 $sections = \CCalendarSect::GetList(array(
49 '>ID' => $status[
'sectionLastId']
51 'arOrder' => array(
'ID' =>
'asc'),
52 'checkPermissions' =>
false,
53 'getPermissions' =>
false,
54 'limit' => self::PORTION
57 foreach ($sections as $section)
61 if (mb_strtolower($color) != mb_strtolower($section[
'COLOR']))
63 \CCalendarSect::Edit(array(
65 'ID' => $section[
'ID'],
70 $newStatus[
'sectionLastId'] = $section[
'ID'];
71 $newStatus[
'steps']++;
75 if (!empty($newStatus[
'sectionLastId']))
77 Option::set(
'calendar',
'eventindex', serialize($newStatus));
80 'count' => $newStatus[
'count'],
81 'steps' => $newStatus[
'steps']
87 $newStatus[
'sectionFinished'] =
true;
88 Option::set(
'calendar',
'eventindex', serialize($newStatus));
92 $events = \CCalendarEvent::GetList(array(
94 '>ID' => $status[
'eventLastId'],
97 'arOrder' => array(
'ID' =>
'asc'),
98 'fetchAttendees' =>
true,
99 'parseRecursion' =>
false,
100 'checkPermissions' =>
false,
101 'parseDescription' =>
false,
102 'fetchSection' =>
true,
103 'limit' => self::PORTION
107 foreach ($events as $event)
111 if (mb_strtolower($color) != mb_strtolower($event[
'COLOR']))
113 \CCalendarEvent::updateColor($event[
'ID'], $color);
117 \CCalendarEvent::updateSearchIndex($event[
'ID'], array(
118 'events' => array($event)
121 $newStatus[
'eventLastId'] = $event[
'ID'];
122 $newStatus[
'steps']++;
125 if (!empty($newStatus[
'eventLastId']))
127 Option::set(
'calendar',
'eventindex', serialize($newStatus));
130 'count' => $newStatus[
'count'],
131 'steps' => $newStatus[
'steps']
136 Option::set(
'calendar',
'needEventIndex',
'N');
137 Option::delete(
'calendar', array(
'name' =>
'eventindex'));
142 private function loadCurrentStatus()
144 $status = Option::get(
'calendar',
'eventindex',
'default');
145 $status = ($status !==
'default' ? @unserialize($status, [
'allowed_classes' =>
false]) : array());
146 $status = (is_array($status) ? $status : array());
151 'count' => self::getTotalCount(),
154 'sectionLastId' => 0,
157 'sectionFinished' =>
false,
165 private function getTotalCount()
167 Loader::includeModule(
"calendar");
168 return \CCalendarEvent::GetCount() + \CCalendarSect::GetCount();
173 $color = mb_strtolower($color);
176 '#daa187' =>
'#af7e00',
177 '#b47153' =>
'#af7e00',
179 '#78d4f1' =>
'#2fc6f6',
180 '#2fc7f7' =>
'#2fc6f6',
182 '#c8cdd3' =>
'#a8adb4',
183 '#a7abb0' =>
'#a8adb4',
185 '#43dad2' =>
'#47e4c2',
186 '#04b4ab' =>
'#47e4c2',
188 '#eece8f' =>
'#ffa900',
189 '#ffa801' =>
'#ffa900',
191 '#5cd1df' =>
'#56d1e0',
192 '#aee5ec' =>
'#56d1e0',
194 '#b6a5f6' =>
'#9985dd',
195 '#6e54d1' =>
'#9985dd',
197 '#f0b1a1' =>
'#f87396',
198 '#f73200' =>
'#f87396',
199 '#ee9b9a' =>
'#f87396',
200 '#fe5957' =>
'#f87396',
202 '#82dc98' =>
'#9dcf00',
203 '#29ad49' =>
'#9dcf00',
204 '#cee669' =>
'#9dcf00'
206 if ($color && isset($colorTable[$color]))
207 return $colorTable[$color];
static getMessage($code, $replace=null, $language=null)