}
}
- // 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');
$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
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)) {
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
}
/// 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