- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/update/indexcalendar.php
- Класс: BitrixCalendarUpdateIndexCalendar
- Вызов: IndexCalendar::execute
public function execute(array &$result)
{
if (Loader::includeModule("calendar")
&& Option::get('calendar', 'needEventIndex', 'Y') === 'N')
{
return self::FINISH_EXECUTION;
}
$status = $this->loadCurrentStatus();
if ($status['finished'])
{
return self::FINISH_EXECUTION;
}
$newStatus = array(
'count' => $status['count'],
'steps' => $status['steps'],
'sectionFinished' => $status['sectionFinished'],
'finished' => $status['finished']
);
// 1. Update sections
if (!$status['sectionFinished'])
{
$sections = CCalendarSect::GetList(array(
'arFilter' => array(
'>ID' => $status['sectionLastId']
),
'arOrder' => array('ID' => 'asc'),
'checkPermissions' => false,
'getPermissions' => false,
'limit' => self::PORTION
));
foreach ($sections as $section)
{
// 1. Replace colors
$color = self::getNewColor($section['COLOR']);
if (mb_strtolower($color) != mb_strtolower($section['COLOR']))
{
CCalendarSect::Edit(array(
'arFields' => array(
'ID' => $section['ID'],
'COLOR' => $color
)
));
}
$newStatus['sectionLastId'] = $section['ID'];
$newStatus['steps']++;
}
if (!empty($newStatus['sectionLastId']))
{
Option::set('calendar', 'eventindex', serialize($newStatus));
$result = array(
'title' => Loc::getMessage("CALENDAR_INDEX_TITLE"),
'count' => $newStatus['count'],
'steps' => $newStatus['steps']
);
return self::CONTINUE_EXECUTION;
}
$newStatus['sectionFinished'] = true;
Option::set('calendar', 'eventindex', serialize($newStatus));
}
// 2. Update events
$events = CCalendarEvent::GetList(array(
'arFilter' => array(
'>ID' => $status['eventLastId'],
'DELETED' => false
),
'arOrder' => array('ID' => 'asc'),
'fetchAttendees' => true,
'parseRecursion' => false,
'checkPermissions' => false,
'parseDescription' => false,
'fetchSection' => true,
'limit' => self::PORTION
)
);
foreach ($events as $event)
{
// 1. Replace colors
$color = self::getNewColor($event['COLOR']);
if (mb_strtolower($color) != mb_strtolower($event['COLOR']))
{
CCalendarEvent::updateColor($event['ID'], $color);
}
// 2. Fill searchable content
CCalendarEvent::updateSearchIndex($event['ID'], array(
'events' => array($event)
));
$newStatus['eventLastId'] = $event['ID'];
$newStatus['steps']++;
}
if (!empty($newStatus['eventLastId']))
{
Option::set('calendar', 'eventindex', serialize($newStatus));
$result = array(
'title' => Loc::getMessage("CALENDAR_INDEX_TITLE"),
'count' => $newStatus['count'],
'steps' => $newStatus['steps']
);
return self::CONTINUE_EXECUTION;
}
Option::set('calendar', 'needEventIndex', 'N');
Option::delete('calendar', array('name' => 'eventindex'));
return self::FINISH_EXECUTION;
}