diff --git a/admin/index.php b/admin/index.php
index 870f1c63406..b1d479bd8c1 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -325,7 +325,7 @@
/// Set up the blank site - to be customized later at the end of install.
if (! $site = get_site()) {
// We are about to create the site "course"
- require_once($CFG->dirroot.'/lib/blocklib.php');
+ require_once($CFG->libdir.'/blocklib.php');
$newsite = new Object();
$newsite->fullname = "";
@@ -358,6 +358,16 @@
}
}
+ // initialise default blocks on admin page if needed
+ if (empty($CFG->adminblocks_initialised)) {
+ require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
+ require_once($CFG->libdir.'/blocklib.php');
+ page_map_class(PAGE_ADMIN, 'page_admin');
+ $page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
+ blocks_repopulate_page($page);
+ set_config('adminblocks_initialised', 1);
+ }
+
/// Define the unique site ID code if it isn't already
if (empty($CFG->siteidentifier)) { // Unique site identification code
set_config('siteidentifier', random_string(32));
@@ -612,4 +622,4 @@
-?>
+?>
\ No newline at end of file
diff --git a/admin/pagelib.php b/admin/pagelib.php
index 3fd7ba55d91..fb4570e8a8f 100644
--- a/admin/pagelib.php
+++ b/admin/pagelib.php
@@ -2,7 +2,7 @@
require_once($CFG->libdir.'/pagelib.php');
-define('PAGE_ADMIN', 'admin-index');
+define('PAGE_ADMIN', 'admin');
page_map_class(PAGE_ADMIN, 'page_admin');
@@ -12,7 +12,10 @@ class page_admin extends page_base {
var $pathtosection;
var $visiblepathtosection;
- function init_full($section) {
+ // hack alert!
+ // this function works around the inability to store the section name
+ // in default block, maybe we should "improve" the blocks a bit?
+ function init_extra($section) {
global $CFG;
if($this->full_init_done) {
@@ -39,9 +42,9 @@ class page_admin extends page_base {
// all done
$this->full_init_done = true;
}
-
+
function blocks_get_default() {
- return 'admin_2,admin_bookmarks';
+ return 'admin_tree,admin_bookmarks';
}
// seems reasonable that the only people that can edit blocks on the admin pages
diff --git a/admin/settings.php b/admin/settings.php
index 4302f14ab4a..28a61a61f61 100644
--- a/admin/settings.php
+++ b/admin/settings.php
@@ -2,27 +2,23 @@
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir . '/blocklib.php');
-require_once($CFG->dirroot . '/admin/pagelib.php');
+require_once($CFG->libdir.'/blocklib.php');
+require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
if ($site = get_site()) {
require_login();
}
-define('TEMPORARY_ADMIN_PAGE_ID',26);
-
define('BLOCK_L_MIN_WIDTH',160);
define('BLOCK_L_MAX_WIDTH',210);
-$pagetype = PAGE_ADMIN;
-$pageclass = 'page_admin';
-page_map_class($pagetype, $pageclass);
+page_map_class(PAGE_ADMIN, 'page_admin');
-$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
+$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be some id number
$section = optional_param('section', '', PARAM_ALPHAEXT);
-$PAGE->init_full($section);
+$PAGE->init_extra($section); // hack alert!
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
$return = optional_param('return','', PARAM_ALPHA);
diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php
index 2f6b31b94d8..73d1c842630 100644
--- a/blocks/activity_modules/block_activity_modules.php
+++ b/blocks/activity_modules/block_activity_modules.php
@@ -45,7 +45,7 @@ class block_activity_modules extends block_list {
}
function applicable_formats() {
- return array('all' => true, 'mod' => false, 'my' => false);
+ return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
}
}
diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php
index d9226170428..74aa15bcf82 100644
--- a/blocks/admin/block_admin.php
+++ b/blocks/admin/block_admin.php
@@ -243,7 +243,7 @@ class block_admin extends block_list {
}
function applicable_formats() {
- return array('all' => true, 'mod' => false, 'my' => false);
+ return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
}
}
diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php
index fa7ae9cabe8..868156f8e53 100644
--- a/blocks/admin_bookmarks/block_admin_bookmarks.php
+++ b/blocks/admin_bookmarks/block_admin_bookmarks.php
@@ -7,8 +7,12 @@
class block_admin_bookmarks extends block_base {
function init() {
- $this->title = "Admin Bookmarks";
- $this->version = 2006081800;
+ $this->title = get_string('adminbookmarks');
+ $this->version = 2006090300;
+ }
+
+ function applicable_formats() {
+ return array('site' => true, 'admin' => true);
}
function preferred_width() {
diff --git a/blocks/admin_2/block_admin_2.php b/blocks/admin_tree/block_admin_tree.php
similarity index 91%
rename from blocks/admin_2/block_admin_2.php
rename to blocks/admin_tree/block_admin_tree.php
index bb1ed89200a..9aa8f55b544 100644
--- a/blocks/admin_2/block_admin_2.php
+++ b/blocks/admin_tree/block_admin_tree.php
@@ -1,6 +1,6 @@
title = "Administration (Beta)";
- $this->version = 2006081800;
+ $this->title = get_string('admintree');
+ $this->version = 2006090300;
$this->currentdepth = 0;
$this->spancounter = 1;
$this->tempcontent = '';
@@ -21,6 +21,10 @@ class block_admin_2 extends block_base {
$this->expandjavascript = '';
}
+ function applicable_formats() {
+ return array('site' => true, 'admin' => true);
+ }
+
function preferred_width() {
return 210;
}
@@ -31,7 +35,7 @@ class block_admin_2 extends block_base {
$this->tempcontent .= " ";
}
$this->tempcontent .= '';
- $this->tempcontent .= '
';
+ $this->tempcontent .= '
';
$this->tempcontent .= $visiblename . '
' . "\n";
$this->currentdepth++;
$this->spancounter++;
@@ -54,11 +58,11 @@ class block_admin_2 extends block_base {
global $CFG;
if (is_a($content, 'admin_settingpage')) {
if ($content->check_access()) {
- $this->create_item($content->visiblename,$CFG->wwwroot.'/admin/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_2/item.gif');
+ $this->create_item($content->visiblename,$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_tree/item.gif');
}
} else if (is_a($content, 'admin_externalpage')) {
if ($content->check_access()) {
- $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_2/item.gif');
+ $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_tree/item.gif');
}
} else if (is_a($content, 'admin_category')) {
if ($content->check_access()) {
@@ -131,11 +135,11 @@ class block_admin_2 extends block_base {
$this->content->text .= 'function toggle(spanid) {' . "\n";
$this->content->text .= ' if (getspan(spanid).innerHTML == "") {' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
$this->content->text .= ' } else {' . "\n";
$this->content->text .= ' vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = "";' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_tree/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
$this->content->text .= ' }' . "\n";
$this->content->text .= '}' . "\n";
@@ -143,13 +147,13 @@ class block_admin_2 extends block_base {
$this->content->text .= ' if (getspan(spanid).innerHTML !== "") {' . "\n";
$this->content->text .= ' vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = "";' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_tree/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
$this->content->text .= ' }' . "\n";
$this->content->text .= '}' . "\n";
$this->content->text .= 'function expand(spanid) {' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "
wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
$this->content->text .= '}' . "\n";
$this->content->text .= 'function expandall() {' . "\n";
diff --git a/blocks/admin_2/closed.gif b/blocks/admin_tree/closed.gif
similarity index 100%
rename from blocks/admin_2/closed.gif
rename to blocks/admin_tree/closed.gif
diff --git a/blocks/admin_2/item.gif b/blocks/admin_tree/item.gif
similarity index 100%
rename from blocks/admin_2/item.gif
rename to blocks/admin_tree/item.gif
diff --git a/blocks/admin_2/open.gif b/blocks/admin_tree/open.gif
similarity index 100%
rename from blocks/admin_2/open.gif
rename to blocks/admin_tree/open.gif
diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php
index 96ff056ce25..1926f27e7f5 100644
--- a/blocks/moodleblock.class.php
+++ b/blocks/moodleblock.class.php
@@ -289,7 +289,7 @@ class block_base {
*/
function _add_edit_controls($options) {
- global $CFG, $USER;
+ global $CFG, $USER, $PAGE;
// this is the context relevant to this particular block instance
$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
@@ -340,7 +340,11 @@ class block_base {
if (empty($this->instance->pageid)) {
$this->instance->pageid = 0;
}
- $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+ if (!empty($PAGE->type) and ($this->instance->pagetype == $PAGE->type) and $this->instance->pageid == $PAGE->id) {
+ $page = $PAGE;
+ } else {
+ $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+ }
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
// place holder for roles button
diff --git a/lib/adminlib.php b/lib/adminlib.php
index f7c4514bf82..e5c99a690ac 100644
--- a/lib/adminlib.php
+++ b/lib/adminlib.php
@@ -2181,20 +2181,16 @@ function admin_externalpage_setup($section, $adminroot) {
global $CFG, $PAGE, $USER;
require_once($CFG->libdir . '/blocklib.php');
- require_once($CFG->dirroot . '/admin/pagelib.php');
+ require_once($CFG->dirroot . '/'.$CFG->admin.'/pagelib.php');
- define('TEMPORARY_ADMIN_PAGE_ID',26);
-
define('BLOCK_L_MIN_WIDTH',160);
define('BLOCK_L_MAX_WIDTH',210);
- $pagetype = PAGE_ADMIN;
- $pageclass = 'page_admin';
- page_map_class($pagetype, $pageclass);
+ page_map_class(PAGE_ADMIN, 'page_admin');
- $PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
+ $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be some id number
- $PAGE->init_full($section);
+ $PAGE->init_extra($section); // hack alert!
$root = $adminroot->locate($PAGE->section);
diff --git a/lib/blocklib.php b/lib/blocklib.php
index 229109068f0..b7a0626411c 100644
--- a/lib/blocklib.php
+++ b/lib/blocklib.php
@@ -682,7 +682,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
// You can use this to get the blocks to respond to URL actions without much hassle
function blocks_execute_url_action(&$PAGE, &$pageblocks,$pinned=false) {
- $blockaction = optional_param('blockaction');
+ $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
if (empty($blockaction) || !$PAGE->user_allowed_editing() || !confirm_sesskey()) {
return;