]> git.mjollnir.org Git - moodle.git/commitdiff
fixes for new admin blocks
authorskodak <skodak>
Sat, 2 Sep 2006 23:55:56 +0000 (23:55 +0000)
committerskodak <skodak>
Sat, 2 Sep 2006 23:55:56 +0000 (23:55 +0000)
13 files changed:
admin/index.php
admin/pagelib.php
admin/settings.php
blocks/activity_modules/block_activity_modules.php
blocks/admin/block_admin.php
blocks/admin_bookmarks/block_admin_bookmarks.php
blocks/admin_tree/block_admin_tree.php [moved from blocks/admin_2/block_admin_2.php with 91% similarity]
blocks/admin_tree/closed.gif [moved from blocks/admin_2/closed.gif with 100% similarity]
blocks/admin_tree/item.gif [moved from blocks/admin_2/item.gif with 100% similarity]
blocks/admin_tree/open.gif [moved from blocks/admin_2/open.gif with 100% similarity]
blocks/moodleblock.class.php
lib/adminlib.php
lib/blocklib.php

index 870f1c634067752aa2576f5d72c1c1e967f2cc43..b1d479bd8c101f705105a9eb503bb6114fc87eb5 100644 (file)
 /// 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 = "";
         }
     }
 
+    // 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));
 
 
 
-?>
+?>
\ No newline at end of file
index 3fd7ba55d91ab2e92913affac26374ae3b6f2d88..fb4570e8a8f778cdb36d716f316f31d318f76c2c 100644 (file)
@@ -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
index 4302f14ab4adfba714d070d7fea8695600c67b78..28a61a61f61297be6b3aef09c56444f95c045d19 100644 (file)
@@ -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);
index 2f6b31b94d80c8e511893473663e2f495c2611b4..73d1c842630a2f281ceaf61796fa647840325fb7 100644 (file)
@@ -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);
     }
 }
 
index d9226170428a7aa7e01b894965f79a9a63a083b6..74aa15bcf826c0d8630a39d0c894f67372e7a3d6 100644 (file)
@@ -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);
     }
 }
 
index fa7ae9cabe867691e489102db6e6e233e8f5e9c8..868156f8e534b3f73754d4e2946b481f93f322af 100644 (file)
@@ -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() {
similarity index 91%
rename from blocks/admin_2/block_admin_2.php
rename to blocks/admin_tree/block_admin_tree.php
index bb1ed89200a379a6af3f89c05d05561f0a5767b8..9aa8f55b544c4cbb69a1cfbb68aa58d79d0c9376 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-class block_admin_2 extends block_base {
+class block_admin_tree extends block_base {
 
     var $currentdepth;
     var $spancounter;
@@ -11,8 +11,8 @@ class block_admin_2 extends block_base {
 
     function init() {
         global $PAGE;
-        $this->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 .= "&nbsp;&nbsp;&nbsp;";
         }
         $this->tempcontent .= '<a href="javascript:toggle(\'vh_span' . $this->spancounter . '\');">';
-        $this->tempcontent .= '<span id="vh_span' . $this->spancounter . 'indicator"><img src="' . $CFG->wwwroot . '/blocks/admin_2/open.gif" border="0" alt="[open folder]" /></span> ';
+        $this->tempcontent .= '<span id="vh_span' . $this->spancounter . 'indicator"><img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" border="0" alt="[open folder]" /></span> ';
         $this->tempcontent .= $visiblename . '</a><br /><span id="vh_span' . $this->spancounter . '">' . "\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 = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->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 = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->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 = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->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 = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+            $this->content->text .= '  getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
             $this->content->text .= '}' . "\n";
     
             $this->content->text .= 'function expandall() {' . "\n";
index 96ff056ce2520438fe6e99fb4e5bb39d2543008c..1926f27e7f5758504a8647ca37836edc7a646633 100644 (file)
@@ -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
index f7c4514bf8222e2e7c43ac83529f798b067314d6..e5c99a690acca618f155203429a50f5baa2bbd7a 100644 (file)
@@ -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);
 
index 229109068f08eced058b37efc0404172c7ad4d21..b7a0626411cdbcaad81fb7c6fb7f777859562dc2 100644 (file)
@@ -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;