From 555d0f13a2240b7a79b8b8d1f361fd4306270d4c Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 29 Oct 2008 15:21:31 +0000 Subject: [PATCH] Slight performance improvements git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12807 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_pluglist.inc | 16 ++++++++++++++-- gosa-core/include/class_userinfo.inc | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gosa-core/include/class_pluglist.inc b/gosa-core/include/class_pluglist.inc index 81f4a3102..48233fbc0 100644 --- a/gosa-core/include/class_pluglist.inc +++ b/gosa-core/include/class_pluglist.inc @@ -32,6 +32,7 @@ class pluglist { var $info= array(); var $headlines = array(); var $allowed_plugins = array(); + var $silly_cache= array(); function pluglist(&$config, &$ui) { @@ -81,7 +82,7 @@ class pluglist { } - /*! \brief Check whether we are allowed to modify the given acl or nit.. + /*! \brief Check whether we are allowed to modify the given acl or not.. This function is used to check which plugins are visible. @param The acl tag to test, eg. "users/user:self", "systems", ... @@ -89,6 +90,10 @@ class pluglist { */ function check_access($aclname) { + if (isset($this->silly_cache[$aclname])) { + return $this->silly_cache[$aclname]; + } + /* Split given acl string into an array. e.g. "user,systems" => array("users","systems"); */ @@ -108,17 +113,24 @@ class pluglist { if(preg_match("/:self$/",$acl_to_check)){ $acl_to_check = preg_replace("/:self$/","",$acl_to_check); if($this->ui->get_permissions($this->ui->dn,$acl_to_check,"") != ""){ + $this->silly_cache[$aclname]= TRUE; return(TRUE); } + $this->silly_cache[$aclname]= FALSE; return(FALSE); }else{ /* No self acls. Check if we have any acls for the given ACL type */ $deps = $this->ui->get_module_departments($acl_to_check,TRUE); - if(count($deps)) return TRUE; + if(count($deps)){ + $this->silly_cache[$aclname]= TRUE; + return TRUE; + } } } + + $this->silly_cache[$aclname]= FALSE; return (FALSE); } diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index d5bc7419d..b2e271161 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -420,7 +420,7 @@ class userinfo accessible department) */ function get_module_departments($module, $skip_self_acls = FALSE ) { - + /* If we are forced to skip ACLs checks for the current user then return all departments as valid. */ @@ -468,7 +468,7 @@ class userinfo foreach($info['acl'] as $cat => $data){ /* Skip self acls? */ - if($skip_self_acls && isset($data['0']) && preg_match("//s",$data['0'])) continue; + if($skip_self_acls && isset($data['0']) && strpos($data['0'], "s")) continue; if(is_array($module)){ foreach($module as $mod){ @@ -486,7 +486,7 @@ class userinfo } if($found && !isset($this->config->idepartments[$dn])){ - while(!isset($this->config->idepartments[$dn]) && preg_match("/,/",$dn)){ + while(!isset($this->config->idepartments[$dn]) && strpos($dn, ",")){ $dn = preg_replace("/^[^,]+,/","",$dn); } if(isset($this->config->idepartments[$dn])){ @@ -503,7 +503,7 @@ class userinfo } $acl = ""; foreach($module as $mod){ - if(preg_match("/\//",$mod)){ + if(strpos($mod, '/')){ $acl.= $this->get_permissions($dn,$mod); }else{ $acl.= $this->get_category_permissions($dn,$mod); -- 2.30.2