Code

Slight performance improvements
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 15:21:31 +0000 (15:21 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 15:21:31 +0000 (15:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12807 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_pluglist.inc
gosa-core/include/class_userinfo.inc

index 81f4a3102bd32d0b87dfcb5eb4d47630a551d002..48233fbc07c643c3504cf08d96b2219f4bff12f1 100644 (file)
@@ -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);
        }
 
index d5bc7419dad377772bd2fd4794a0bfb5420f47a0..b2e27116169ef3bcbf36034ef31d6bfb880f37c6 100644 (file)
@@ -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);