27 Loader::includeModule(
"calendar")
28 && Option::get(
'calendar',
'sectionStructureConverted',
'N') ===
'Y'
31 return self::FINISH_EXECUTION;
34 $status = $this->loadCurrentStatus();
39 'lastEventId' =>
null,
40 'finished' =>
$status[
'finished']
45 $r =
$DB->Query(
'SELECT ID FROM b_calendar_event
46 WHERE SECTION_ID IS NULL ORDER BY ID ASC limit 1;'
49 if ($entry = $r->Fetch())
51 $newStatus[
'lastEventId'] = $entry[
'ID'];
52 if ((
int)
$status[
'lastEventId'] === (
int)$newStatus[
'lastEventId'])
54 Option::set(
'calendar',
'sectionStructureConverted',
'Y');
55 Option::delete(
'calendar', [
'name' =>
'sectionStructureUpdaterStatus']);
57 return self::FINISH_EXECUTION;
60 $DB->Query(
'UPDATE b_calendar_event CE
61 INNER JOIN b_calendar_event_sect CES ON CE.ID = CES.EVENT_ID
62 SET CE.SECTION_ID = CES.SECT_ID
63 WHERE CE.SECTION_ID is null and CE.ID < '.((
int)$entry[
'ID'] + $BATCH_SIZE)
66 $newStatus[
'steps'] = $newStatus[
'count'] - $this->getTotalCount();
68 Option::set(
'calendar',
'sectionStructureUpdaterStatus', serialize($newStatus));
70 'title' => Loc::getMessage(
"CALENDAR_UPDATE_STRUCTURE_TITLE"),
71 'count' => $newStatus[
'count'],
72 'steps' => $newStatus[
'steps']
74 return self::CONTINUE_EXECUTION;
77 Option::set(
'calendar',
'sectionStructureUpdaterStatus', serialize($newStatus));
80 Option::set(
'calendar',
'sectionStructureConverted',
'Y');
81 Option::delete(
'calendar', [
'name' =>
'sectionStructureUpdaterStatus']);
83 return self::FINISH_EXECUTION;