From 8662654b40694c2e5e91414a8537beabdf4b470f Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 6 Oct 2008 10:21:53 +0000 Subject: A massive speed increase for access permissions. :) git-svn-id: https://code.elgg.org/elgg/trunk@2184 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/access.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/access.php b/engine/lib/access.php index f6fefe3bf..f52d839de 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -24,15 +24,18 @@ function get_access_list($user_id = 0, $site_id = 0, $flush = false) { global $CONFIG, $init_finished; + static $access_list; if (!isset($access_list) || !$init_finished) $access_list = array(); - + if ($user_id == 0) $user_id = $_SESSION['id']; if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id; $user_id = (int) $user_id; $site_id = (int) $site_id; + if (isset($access_list[$user_id])) return $access_list[$user_id]; + $access_list[$user_id] = "(" . implode(",",get_access_array($user_id, $site_id, $flush)) . ")"; return $access_list[$user_id]; @@ -54,7 +57,7 @@ if (!isset($access_array) || !$init_finished) $access_array = array(); - + if ($user_id == 0) $user_id = $_SESSION['guid']; if (($site_id == 0) && (isset($CONFIG->site_guid))) $site_id = $CONFIG->site_guid; -- cgit v1.2.3