Commit bcdb22cf authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge "Update navigation blocks when copying collections (bug #898923)"

parents 45f2009d 480b38d4
......@@ -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