]> git.mjollnir.org Git - moodle.git/commitdiff
blocks/admin_tree: exit early for non-admins
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:22:24 +0000 (07:22 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:22:24 +0000 (07:22 +0000)
Saves >10DBq and 18 includes at the homepage for all nonadmin users.
For non admin users, this makes the homepage _much_ more lightweight.

  Before: inc 101  DBq 51 time 1.2s
  After:  inc  76  DBq 36 time 0.2s

So this commit shaves 1 full second for the non-logged-in homepage.

Still pretty bad on the includes, but shaved a good 25 files and 15 DBqs.

blocks/admin_tree/block_admin_tree.php

index 2a0126b8d26d64beed2db44793f3dfb22ebacfc4..6045f44637d00b9059a65e65321e16ce095098df 100644 (file)
@@ -100,13 +100,18 @@ class block_admin_tree extends block_base {
 
         global $CFG, $ADMIN;
 
-        require_once($CFG->libdir.'/adminlib.php');
-        $adminroot = admin_get_root();
+        if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+            $this->content = '';
+            return '';
+        }
 
         if ($this->content !== NULL) {
             return $this->content;
         }
 
+        require_once($CFG->libdir.'/adminlib.php');
+        $adminroot = admin_get_root();
+
         if ($this->pathtosection = $adminroot->path($this->section)) {
             $this->pathtosection = array_reverse($this->pathtosection);
             array_pop($this->pathtosection);