28 if (Loader::includeModule(
"calendar")
29 && Option::get(
'calendar',
'needChangeColor',
'Y') ===
'N')
31 return self::FINISH_EXECUTION;
34 $status = $this->loadCurrentStatus();
38 \CCalendar::ClearCache([
'section_list',
'event_list']);
40 return self::FINISH_EXECUTION;
46 'sectionFinished' =>
$status[
'sectionFinished'],
47 'finished' =>
$status[
'finished']
51 if (!
$status[
'sectionFinished'])
53 $sections = SectionTable::getList([
55 '>ID' =>
$status[
'sectionLastId'],
57 'limit' => self::PORTION,
63 foreach ($sections as $section)
67 if (strtolower($color) != strtolower($section[
'COLOR']))
69 \CCalendarSect::Edit(
array(
71 'ID' => $section[
'ID'],
76 $newStatus[
'sectionLastId'] = $section[
'ID'];
77 $newStatus[
'steps']++;
81 if (!empty($newStatus[
'sectionLastId']))
83 Option::set(
'calendar',
'changecolor', serialize($newStatus));
85 return self::CONTINUE_EXECUTION;
88 $newStatus[
'sectionFinished'] =
true;
89 Option::set(
'calendar',
'eventindex', serialize($newStatus));
93 $events = EventTable::getList([
95 '>ID' =>
$status[
'eventLastId'] ??
null,
101 'limit' => self::PORTION,
105 foreach ($events as
$event)
109 if (strtolower($color) != strtolower(
$event[
'COLOR']))
111 \CCalendarEvent::updateColor(
$event[
'ID'], $color);
114 $newStatus[
'eventLastId'] =
$event[
'ID'];
115 $newStatus[
'steps']++;
118 if (!empty($newStatus[
'eventLastId']))
120 Option::set(
'calendar',
'changecolor', serialize($newStatus));
122 return self::CONTINUE_EXECUTION;
125 Option::set(
'calendar',
'needChangeColor',
'N');
126 Option::delete(
'calendar',
array(
'name' =>
'changecolor'));
128 return self::FINISH_EXECUTION;