Commit 480b38d4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Update navigation blocks when copying collections (bug #898923)



When copying a collection, navigation blocks in the copied pages
should be updated to point at the new copy of the collection.

After all the pages are copied, all the newly copied navigation blocks
are examined to see if they navigate the collection being copied.  If
so, they are updated to navigate the new copy of the collection.  When
a navigation block points at some collection other than the one being
copied, it is left alone.

Change-Id: I4b817acfa2cbefafc37f98f3f3f7fc12e54f61c0
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 827fed1c
......@@ -247,6 +247,27 @@ class Collection {
$collection->add_views($copyviews);
// Update all the navigation blocks referring to this collection
if ($viewids = get_column('collection_view', 'view', 'collection', $collection->get('id'))) {
$navblocks = get_records_select_array(
'block_instance',
'view IN (' . join(',', array_fill(0, count($viewids), '?')) . ") AND blocktype = 'navigation'",
$viewids
);
if ($navblocks) {
safe_require('blocktype', 'navigation');
foreach ($navblocks as $b) {
$bi = new BlockInstance($b->id, $b);
$configdata = $bi->get('configdata');
if (isset($configdata['collection']) && $configdata['collection'] == $templateid) {
$bi->set('configdata', array('collection' => $collection->get('id')));
$bi->commit();
}
}
}
}
db_commit();
return array(
......
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