MDL-47189 my: Fix the addition of default blocks to my/ page

Fixing the upgrade script so that they attach the new blocks
to the right my_pages entry. An upgrade script has also been
added to fix the existing bad data.
This commit is contained in:
Frederic Massart 2014-10-06 18:57:17 +08:00
parent d3ff82257e
commit 00fd3c1aad
6 changed files with 97 additions and 38 deletions

View file

@ -2178,7 +2178,13 @@ function blocks_add_default_system_blocks() {
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('navigation', 'settings')), '*', null, true);
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('admin_bookmarks')), 'admin-*', null, null, 2);
if ($defaultmypage = $DB->get_record('my_pages', array('userid' => null, 'name' => '__default', 'private' => 1))) {
$subpagepattern = $defaultmypage->id;
} else {
$subpagepattern = null;
}
$newblocks = array('private_files', 'online_users', 'badges', 'calendar_month', 'calendar_upcoming');
$newcontent = array('course_overview');
$page->blocks->add_blocks(array(BLOCK_POS_RIGHT => $newblocks, 'content' => $newcontent), 'my-index');
$page->blocks->add_blocks(array(BLOCK_POS_RIGHT => $newblocks, 'content' => $newcontent), 'my-index', $subpagepattern);
}