Commit 20186f34 authored by Mike Kelly's avatar Mike Kelly Committed by Gerrit Code Review
Browse files

Copy the custom layout where required when copying a view.



Bug #1266317

Change-Id: Ief7c8c5d2aef455d61e78feb5d3c7571d517c830
Signed-off-by: default avatarMike Kelly <m.f.kelly@arts.ac.uk>
parent eb14f430
......@@ -401,6 +401,35 @@ class View {
$view->commit();
// if layout is set, and it's not a default layout
// add an entry to usr_custom_layout if one does not already exist
if ($template->get('layout') !== null) {
$customlayout = get_record('view_layout', 'id', $template->get('layout'), 'iscustom', 1);
if ($customlayout !== false) {
// is the owner of the copy going to be a group or not?
$owner = $view->owner;
$group = null;
if (!empty($view->group)) {
$group = $view->group;
$owner = null;
$haslayout = get_record('usr_custom_layout', 'layout', $template->get('layout'), 'group', $group);
}
else if (isset($owner)) {
$haslayout = get_record('usr_custom_layout', 'layout', $template->get('layout'), 'usr', $owner);
}
else {
// owner is null and group is null
// we must be creating site or institution pages
$haslayout = get_record('usr_custom_layout', 'layout', $template->get('layout'), 'usr', $owner, 'group', $group);
}
if (!$haslayout) {
$newcustomlayout = insert_record('usr_custom_layout', (object) array('usr' => $owner, 'group' => $group, 'layout' => $template->get('layout')) );
}
}
}
$blocks = get_records_array('block_instance', 'view', $view->get('id'));
if ($blocks) {
foreach ($blocks as $b) {
......
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