Skip to content

Commit 6999ab2

Browse files
Maintenance: Fix calendar events don't copy (missing properties) from backup - refs BT#20503
Author: @christianbeeznest
1 parent b6a43d2 commit 6999ab2

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,40 @@ public function restore_events($sessionId = 0)
15811581
$sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
15821582
Database::query($sql);
15831583

1584+
// Choose default visibility
1585+
$toolVisibility = api_get_setting('tool_visible_by_default_at_creation');
1586+
$defaultLpVisibility = 'invisible';
1587+
if (isset($toolVisibility['learning_path']) && $toolVisibility['learning_path'] == 'true') {
1588+
$defaultLpVisibility = 'visible';
1589+
}
1590+
1591+
api_item_property_update(
1592+
$this->destination_course_info,
1593+
TOOL_CALENDAR_EVENT,
1594+
$new_event_id,
1595+
'AgendaAdded',
1596+
api_get_user_id(),
1597+
0,
1598+
0,
1599+
0,
1600+
0,
1601+
$sessionId
1602+
);
1603+
1604+
// Set the new Agenda to visible
1605+
api_item_property_update(
1606+
$this->destination_course_info,
1607+
TOOL_CALENDAR_EVENT,
1608+
$new_event_id,
1609+
$defaultLpVisibility,
1610+
api_get_user_id(),
1611+
0,
1612+
0,
1613+
0,
1614+
0,
1615+
$sessionId
1616+
);
1617+
15841618
if (!isset($this->course->resources[RESOURCE_EVENT][$id])) {
15851619
$this->course->resources[RESOURCE_EVENT][$id] = new stdClass();
15861620
}
@@ -1644,15 +1678,23 @@ public function restore_events($sessionId = 0)
16441678
'c_id' => $this->destination_course_id,
16451679
'path' => self::DBUTF8($new_filename),
16461680
'comment' => self::DBUTF8($event->attachment_comment),
1647-
'size' => isset($event->size) ? $event->size : '',
1648-
'filename' => isset($event->filename) ? $event->filename : '',
1681+
'size' => isset($event->attachment_size) ? $event->attachment_size : '',
1682+
'filename' => isset($event->attachment_filename) ? $event->attachment_filename : '',
16491683
'agenda_id' => $new_event_id,
16501684
];
16511685
$id = Database::insert($table_attachment, $params);
16521686

16531687
if ($id) {
16541688
$sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
16551689
Database::query($sql);
1690+
1691+
api_item_property_update(
1692+
$this->destination_course_info,
1693+
'calendar_event_attachment',
1694+
$id,
1695+
'AgendaAttachmentAdded',
1696+
api_get_user_id()
1697+
);
16561698
}
16571699
}
16581700
}

0 commit comments

Comments
 (0)