Code

-Little performance improvement. class_userinfo.inc get_module_departments
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Nov 2008 13:33:38 +0000 (13:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Nov 2008 13:33:38 +0000 (13:33 +0000)
Do not spend too much time with in_array check the array index instead

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12968 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_userinfo.inc

index bec139e58cc9afc352cedd4e0356893e5da3a590..2b987ad1ef501ea6cd3d1b124480753e46b23b16 100644 (file)
@@ -557,7 +557,7 @@ class userinfo
               $dn = preg_replace("/^[^,]+,/","",$dn);
             }
             if(isset($this->config->idepartments[$dn])){
-              $deps[] = $dn;
+              $deps[$dn] = $dn;
             }
           }
         }
@@ -565,7 +565,7 @@ class userinfo
 
       /* For all gosaDepartments */
       foreach ($this->config->departments as $dn){
-        if(in_array($dn,$deps)) continue;
+        if(isset($deps[$dn])) continue;
         $acl = "";
         if(strpos($mod, '/')){
           $acl.=  $this->get_permissions($dn,$mod);
@@ -573,14 +573,15 @@ class userinfo
           $acl.=  $this->get_category_permissions($dn,$mod,TRUE);
         }
         if(!empty($acl)) {
-          $deps[] = $dn;
+          $deps[$dn] = $dn;
         }
       }
 
       $ACL_CACHE['MODULE_DEPARTMENTS'][$mod] = $deps;
       $res = array_merge($res,$deps);
-    } 
-    return ($res);
+    }
+
+    return (array_values($res));
   }