]> git.mjollnir.org Git - moodle.git/commitdiff
add admin_tree to front page during install and upgrade
authorskodak <skodak>
Sun, 3 Sep 2006 18:37:41 +0000 (18:37 +0000)
committerskodak <skodak>
Sun, 3 Sep 2006 18:37:41 +0000 (18:37 +0000)
admin/index.php
lib/blocklib.php
lib/pagelib.php

index 9261b2c92dc6b43d3198c95a965edc0f450b8214..2aa6d0a8b398fc3f4dcda512cbabd2f984cc8834 100644 (file)
         }
     }
 
-    // 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
index fd094f99e30fe15206041a0ecee872283825c0d6..7b3f7b5489f3c7e667a194d8c07910be489628cb 100644 (file)
@@ -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
index 669724dd596ba4860e1c62d47a72e976de124884..3a19602f9537eb53d5b94e42ed61e6e09b26369e 100644 (file)
@@ -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