Commit be267176 authored by Robert Lyon's avatar Robert Lyon

Bug 1689931: Updating the artefact_annotation mapping

When copying a page with an annotation artefact on it

behatnotneeded

Change-Id: Ib40e6c4fdf2c31830c3855dcd5b5eedbcebce875
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 69b04f36
......@@ -274,6 +274,23 @@ class ArtefactTypeAnnotation extends ArtefactType {
return $url;
}
public function update_artefact_references(&$view, &$template, &$artefactcopies, $oldid) {
parent::update_artefact_references($view, $template, $artefactcopies, $oldid);
// If we have some artefact mapping data
if (isset($artefactcopies[$oldid]->newid)) {
if ($viewid = get_field('view_artefact', 'view', 'artefact', $artefactcopies[$oldid]->newid, 'view', $view->get('id'))) {
// And the mapping data relates to this particular view (useful if in collection)
// Attach copies of the annotation artefact to correct view in artefact_annotation table.
$data = (object)array(
'annotation' => $artefactcopies[$oldid]->newid,
'view' => $view->get('id'),
'artefact' => $this->get('artefact'),
);
update_record('artefact_annotation', $data, 'annotation');
}
}
}
public function commit() {
if (empty($this->dirty)) {
return;
......
......@@ -4959,5 +4959,21 @@ function xmldb_core_upgrade($oldversion=0) {
clear_menu_cache();
}
if ($oldversion < 2017051100) {
if ($records = get_records_sql_assoc("SELECT aa.annotation, va.view
FROM {artefact_annotation} aa
JOIN {view_artefact} va ON va.artefact = aa.annotation
WHERE aa.view != va.view", array())) {
log_debug('Fix artefact_annotation table data for copied collections');
foreach ($records as $record) {
$data = (object)array(
'annotation' => $record->annotation,
'view' => $record->view,
);
update_record('artefact_annotation', $data, 'annotation');
}
}
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2017031600;
$config->version = 2017051100;
$config->series = '17.10';
$config->release = '17.10dev';
$config->minupgradefrom = 2012080604;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment