Commit c14edee7 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add status message when copying from a template

parent 617691b6
......@@ -237,5 +237,5 @@ $string['noaccesstoview'] = 'You do not have permission to access this view';
// Templates
$string['Template'] = 'Template';
$string['templatedescription'] = 'If you would like the people who can see your view to be able to make their own copies of it, check the Template box.';
$string['copiedblocksandartefactsfromtemplate'] = 'Copied %d blocks and %d artefacts from %s';
?>
......@@ -1705,6 +1705,7 @@ class View {
$this->set('numcolumns', $template->get('numcolumns'));
$this->set('layout', $template->get('layout'));
$blocks = get_records_array('block_instance', 'view', $template->get('id'));
$numcopied = array('blocks' => 0, 'artefacts' => 0);
if ($blocks) {
$newowner = $this->ownership();
$oldowner = $template->ownership();
......@@ -1756,6 +1757,7 @@ class View {
}
$newblock->set('configdata', $configdata);
$newblock->commit();
$numcopied['blocks']++;
}
}
// Go back and fix up the parents of the new artefacts so
......@@ -1767,7 +1769,9 @@ class View {
$a->commit();
}
}
$numcopied['artefacts'] = count($artefactcopies);
}
return $numcopied;
}
}
......
......@@ -230,7 +230,8 @@ function editview_submit(Pieform $form, $values) {
$template = new View($values['usetemplate']);
if (!$template->get('deleted') && ($template->get('template') && can_view_view($values['usetemplate'])) || $USER->can_edit_view($template)) {
$view->set('dirty', true);
$view->copy_contents($template);
$copystatus = $view->copy_contents($template);
$SESSION->add_ok_msg(get_string('copiedblocksandartefactsfromtemplate', 'view', $copystatus['blocks'], $copystatus['artefacts'], $template->get('title')));
}
}
if ($group) {
......
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