Code

Merged changeset:13498
[gosa.git] / gosa-core / include / class_userinfo.inc
index 08e232de746e1c7f0b263c45eac5c3995d2d5d5f..992f3da004b79c77a9db20bd85d77452b4b13287 100644 (file)
@@ -80,7 +80,7 @@ class userinfo
   public function reset_acl_cache()
   {
     /* Initialize ACL_CACHE */
-    session::set('ACL_CACHE',array());
+    session::global_set('ACL_CACHE',array());
   }
 
   function loadACL()
@@ -158,8 +158,9 @@ class userinfo
 
           /* Inspect members... */
           foreach ($type['members'] as $grp => $grpdsc){
+
             /* Some group inside the members that is relevant for us? */
-            if (in_array_ics(preg_replace('/^G:/', '', $grp), $this->groups)){
+            if (in_array_ics(@LDAP::convert(preg_replace('/^G:/', '', $grp)), $this->groups)){
               $interresting= TRUE;
             }
 
@@ -196,8 +197,9 @@ class userinfo
     $without_self_acl = $all_acl = array();
     foreach($this->ACL as $dn => $acl){
       $sdn =$dn;
-      while(strpos($dn,",") !== FALSE){
-
+      $first= TRUE; // Run at least once 
+      while(strpos($dn,",") !== FALSE || $first){
+        $first = FALSE;
         if(isset($this->ACL[$dn])){
           $all_acl[$sdn][$dn] = $this->ACL[$dn];
           $without_self_acl[$sdn][$dn] = $this->ACL[$dn]; 
@@ -328,7 +330,7 @@ class userinfo
     }
 
     /* Push cache answer? */
-    $ACL_CACHE = &session::get('ACL_CACHE');
+    $ACL_CACHE = &session::global_get('ACL_CACHE');
     if (isset($ACL_CACHE["$dn+$object+$attribute"])){
       $ret = $ACL_CACHE["$dn+$object+$attribute"];
       if($skip_write){
@@ -422,7 +424,7 @@ class userinfo
 
           /* Self ACLs? 
            */
-          if($dn != $this->dn && isset($subacl['acl'][$object][0]) && strpos($subacl['acl'][$object][0],"s")){
+          if($dn != $this->dn && isset($subacl['acl'][$object][0]) && (strpos($subacl['acl'][$object][0],"s") !== FALSE)){
             continue;
           }
 
@@ -466,6 +468,9 @@ class userinfo
               if($attribute == ""){    
                 foreach($this->ocMapping[$ocs] as $oc){
                   if (isset($subacl['acl'][$ocs.'/'.$oc])){
+
+                    if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
+
                     foreach($subacl['acl'][$ocs.'/'.$oc] as $attr => $dummy){
                       $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][$attr]);
                     }
@@ -474,6 +479,7 @@ class userinfo
                 }
               }else{
                 if(isset($subacl['acl'][$ocs.'/'.$oc][0])){
+                  if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
                   $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][0]);
                 }
               }
@@ -522,7 +528,7 @@ class userinfo
     }
 
     /* Use cached results if possilbe */
-    $ACL_CACHE = &session::get('ACL_CACHE');
+    $ACL_CACHE = &session::global_get('ACL_CACHE');
 
     if(!is_array($module)){
       $module = array($module);
@@ -545,7 +551,7 @@ class userinfo
           foreach($info['acl'] as $cat => $data){
 
             /* Skip self acls? */
-            if($skip_self_acls && isset($data['0']) && strpos($data['0'], "s")) continue;
+            if($skip_self_acls && isset($data['0']) && (strpos($data['0'], "s") !== FALSE)) continue;
             if(preg_match("/^".preg_quote($mod, '/')."/",$cat)){
               $found =TRUE;
               break;
@@ -598,6 +604,11 @@ class userinfo
 
     foreach(str_split($newACL) as $char){
 
+      /* Skip "self" ACLs without combination of rwcdm, they have no effect.
+         -self flag without read/write/create/...
+       */
+      if(empty($char)) continue;
+
       /* Skip permanent and subtree entries */
       if (preg_match('/[sp]/', $acl[$char])){
         continue;