Commit bf1139f1 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1904352: Save navigation block correctly



Depending if the other pages in collection are in old or new layout

Change-Id: Ic6a395e391614e285338b8f6e3c900383cec4113
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 7ce0fe80
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -164,21 +164,29 @@ class PluginBlocktypeNavigation extends MaharaCoreBlocktype {
                        if ($needsblock) {
                            // need to add new navigation block
                            $otherview = new View($vid);
                            $bi = new BlockInstance(0,
                                array(
                            $bidata = array(
                                'blocktype'  => 'navigation',
                                'title'      => $values['title'],
                                    'positionx'  => 0,
                                    'positiony'  => 0,
                                    'width'      => 4,
                                    'height'     => 3,
                                'configdata' => array(
                                    'collection' => $values['collection'],
                                    'retractable' => $values['retractable'],
                                    'retractedonload' => $values['retractedonload'],
                                ),
                                )
                            );
                            if ($otherview->uses_new_layout()) {
                                // Save block with dimensions
                                $bidata['positionx'] = 0;
                                $bidata['positiony'] = 0;
                                $bidata['width'] = 4;
                                $bidata['height'] = 3;
                            }
                            else {
                                // Save block in old layout
                                $bidata['row'] = 1;
                                $bidata['column'] = 1;
                                $bidata['order'] = get_field_sql("SELECT MAX(bi.order) + 1 FROM {block_instance} bi WHERE bi.view = ?", array($vid));
                            }
                            $bi = new BlockInstance(0, $bidata);
                            $otherview->addblockinstance($bi);
                        }
                    }