Code

Optimize group listing:
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 13 Mar 2009 15:33:52 +0000 (15:33 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 13 Mar 2009 15:33:52 +0000 (15:33 +0000)
Only fetch the items that are needed to decide weither to show an
application item or not, instead of fetching all items from the ldap,
which takes a lot of time in larger environments.
(Fixes performance problems where group listing might fail at all, because
its runtime exceeds the max_execution_time, Trac #2232)

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13543 594d385d-05f5-0310-b6e9-bd551577e9d8

trunk/gosa-core/plugins/admin/groups/class_divListGroup.inc

index 2ee9518e86b05ae1c04993a459963255f9ef569a..c53613cc0a6be36f0346481300ef83dba6fcd65d 100644 (file)
@@ -205,21 +205,11 @@ class divListGroup extends MultiSelectWindow
 
     $ui = get_userinfo();
 
-    /* Fetch all application menu entries 
-     */
-    $base = get_groups_ou().$this->selectedBase;
     $ldap = $this->config->get_ldap_link();
-    $ldap->cd ($base);
-    $ldap->search("(objectClass=gotoMenuEntry)",array("dn"));
-    $configured_apps = array();
-    while($entry = $ldap->fetch()){
-      $dn = preg_replace("/^.*(cn=[^,]+,".preg_quote(get_groups_ou(), '/').")/","\\1",$entry['dn']);
-      $configured_apps[$dn] = $dn;
-    }
 
     // Test Every Entry and generate divlist Array
     foreach($groups as $key => $val){
-    
+        
       /* Create action icons - copy & paste icons */
       $acl = $ui->get_permissions($val['dn'],"groups/group");
       $acl_all  = $ui->has_complete_category_acls($val['dn'],"groups");
@@ -246,6 +236,20 @@ class divListGroup extends MultiSelectWindow
 
       $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
 
+      /* Set ldap base to dn of this group */
+      $ldap->cd ($val['dn']);
+
+      /* Set ldap size limit to 1, because we only need one entry */
+      $ldap->set_size_limit(1);
+
+      /* Search for applications. */
+      $ldap->search("(objectClass=gotoMenuEntry)",array("dn"));
+      $entry = $ldap->fetch();
+
+      if (isset($entry['dn'])) {
+        $appl  = $applimg;
+      }
+
       if(isset($val['objectClass'])){
         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;
         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;
@@ -254,10 +258,6 @@ class divListGroup extends MultiSelectWindow
         if(in_array("gotoEnvironment",      $val['objectClass']))   $enviro= $envimg;
       }
 
-      if(isset($configured_apps[$val['dn']])){
-          $appl  = $applimg;
-      }
-
       $title = "title='".preg_replace('/ /', '&nbsp;', LDAP::fix($val['dn']))."'";
 
       if(!isset($val['description'][0])){