Code

Added ACL speed optimization
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Sep 2007 07:31:31 +0000 (07:31 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Sep 2007 07:31:31 +0000 (07:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7344 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_userinfo.inc

index f2aa91d85dd4d1d0800962910d337dd14150e30f..749d905f5b52a5f3ff409007539b08d64a2a4c8a 100644 (file)
@@ -64,6 +64,9 @@ class userinfo
     $this->dn= $userdn;
     $this->uid= $attrs['uid'][0];
     $this->ip= $_SERVER['REMOTE_ADDR'];
+
+    /* Initialize ACL_CACHE */
+    $_SESSION['ACL_CACHE']= array();
   }
 
 
@@ -178,6 +181,11 @@ class userinfo
 
   function get_permissions($dn, $object, $attribute= "", $skip_write= FALSE)
   {
+    /* Push cache answer? */
+    if (isset($_SESSION['ACL_CACHE']["$dn+$object+$attribute"])){
+      return ($_SESSION['ACL_CACHE']["$dn+$object+$attribute"]);
+    }
+
     $acl= array("r" => "", "w" => "", "c" => "", "d" => "", "m" => "", "a" => "");
 
     /* Build dn array */
@@ -255,6 +263,7 @@ class userinfo
       $ret= preg_replace('/w/', '', $ret);
     }
 
+    $_SESSION['ACL_CACHE']["$dn+$object+$attribute"]= $ret;
     return ($ret);
   }