From 84a34f6ed33c58e9e348114d75a30eb365d7933e Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:22:24 +0000 Subject: [PATCH] blocks/admin_tree: exit early for non-admins 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blocks/admin_tree/block_admin_tree.php b/blocks/admin_tree/block_admin_tree.php index 2a0126b8d2..6045f44637 100644 --- a/blocks/admin_tree/block_admin_tree.php +++ b/blocks/admin_tree/block_admin_tree.php @@ -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); -- 2.39.5