From: skodak Date: Sun, 3 Sep 2006 18:37:41 +0000 (+0000) Subject: add admin_tree to front page during install and upgrade X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b1631fef28a8ee83cce4391b121890b11ca599b1;p=moodle.git add admin_tree to front page during install and upgrade --- diff --git a/admin/index.php b/admin/index.php index 9261b2c92d..2aa6d0a8b3 100644 --- a/admin/index.php +++ b/admin/index.php @@ -352,7 +352,7 @@ } } - // initialise default blocks on admin page if needed + // initialise default blocks on admin and site page if needed if (empty($CFG->adminblocks_initialised)) { require_once("$CFG->dirroot/$CFG->admin/pagelib.php"); require_once($CFG->libdir.'/blocklib.php'); @@ -360,6 +360,14 @@ $page = page_create_object(PAGE_ADMIN, 0); // there must be some id number blocks_repopulate_page($page); set_config('adminblocks_initialised', 1); + + //add admin_tree block to site if not already present + if ($admintree = get_record('block', 'name', 'admin_tree')) { + require_once("$CFG->dirroot/$CFG->admin/pagelib.php"); + require_once($CFG->libdir.'/blocklib.php'); + $page = page_create_object(PAGE_COURSE_VIEW, SITEID); + blocks_execute_action($page, blocks_get_by_page($page), 'add', (int)$admintree->id, false, false); + } } /// Define the unique site ID code if it isn't already diff --git a/lib/blocklib.php b/lib/blocklib.php index fd094f99e3..7b3f7b5489 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -431,7 +431,7 @@ function blocks_setup(&$PAGE,$pinned=BLOCKS_PINNED_FALSE) { return $pageblocks; } -function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, $pinned=false) { +function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, $pinned=false, $redirect=true) { global $CFG; if (is_int($instanceorid)) { @@ -674,8 +674,10 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; } - // In order to prevent accidental duplicate actions, redirect to a page with a clean url - redirect($page->url_get_full()); + if ($redirect) { + // In order to prevent accidental duplicate actions, redirect to a page with a clean url + redirect($page->url_get_full()); + } } // You can use this to get the blocks to respond to URL actions without much hassle diff --git a/lib/pagelib.php b/lib/pagelib.php index 669724dd59..3a19602f95 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -495,7 +495,7 @@ class page_course extends page_base { } /// Failsafe - in case nothing was defined. else { - $blocknames = 'site_main_menu,admin:course_summary,calendar_month'; + $blocknames = 'site_main_menu,admin,admin_tree:course_summary,calendar_month'; } } // It's a normal course, so do it according to the course format