Code

Improved speed of department listings.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Oct 2008 08:26:35 +0000 (08:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Oct 2008 08:26:35 +0000 (08:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12820 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/departments/class_departmentManagement.inc
gosa-core/plugins/admin/departments/class_divListDepartment.inc

index a5e1e394575174ed80628d75683752a686c86401..677c43f37a71b551e77bdc99beecba37f71db318 100644 (file)
@@ -405,19 +405,22 @@ class departmentManagement extends plugin
 
     /* Create search filter for each department type
      */
-    $res = array();
+
+    /* Get all departments within this subtree */
+    $s_filter = "";
+    $s_attrs  = array("description","objectClass");
+    $s_acls   = array();
+    foreach($types as $oc => $data){
+      $s_filter.= "(&(objectClass=gosaDepartment)(objectClass=".$data['OC'].")".
+        "(|(".$data['ATTR']."=".$Regex.")(description=".$Regex.")))";
+      $s_attrs[]= $data['ATTR'];
+      $s_acls[] = "department/".$data['ACL'];
+    }
+
     if($this->DivListDepartment->SubSearch){
-      foreach($types as $oc => $data){
-        $oc_f = "(&(objectClass=".$data['OC'].")(objectClass=gosaDepartment))";
-        $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$oc_f.")",
-            "department", $base, array($data['ATTR'],"objectClass", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-      }
+      $res = get_list("(|".$s_filter.")",$s_acls,$base,$s_attrs,GL_SIZELIMIT | GL_SUBSEARCH);
     }else{
-      foreach($types as $oc => $data){
-        $oc_f = "(&(objectClass=".$data['OC'].")(objectClass=gosaDepartment))";
-        $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$oc_f.")",
-            "department", $base, array($data['ATTR'], "objectClass","description"), GL_SIZELIMIT ));
-      }
+      $res = get_list("(|".$s_filter.")",$s_acls,$base,$s_attrs,GL_SIZELIMIT);
     }
 
     /* Prepare list (sortable index) 
index 5104c9ee487ad6cb7a32ea803340d18e732d49d1..7e0d9a420db864cb9591582440df64576cf3f15d 100644 (file)
@@ -76,67 +76,11 @@ class divListDepartment extends MultiSelectWindow
 
   function GenHeader()
   {
-    /* Prepare departments,
-       which are shown in the listbox on top of the listbox
-    */
-    $options= "";
-
     /* Get all departments within this subtree */
     $ui= get_userinfo();
-    $first = "";
-    $found = FALSE;
     $base = $this->config->current['BASE'];
-
-    /* Add base */
-    $tmp = array();
-    $tmp[] = array("dn"=>$this->config->current['BASE']);
-    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-
-    $deps = array();
-    foreach($tmp as $tm){
-      $deps[$tm['dn']] = $tm['dn'];
-    }
-
-    /* Load possible departments */
-    $ui= get_userinfo();
-    $tdeps= $ui->get_module_departments("department");
-    $ids = $this->config->idepartments;
-    $first = "";
-    $found = FALSE;
-    foreach($ids as $dep => $name){
-      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
-
-        /* Keep first base dn in mind, we could need this
-         *  info if no valid base was found
-         */
-        if(empty($first)) {
-          $first = $dep['dn'];
-        }
-
-        $value = $ids[$dep];
-        if ($this->selectedBase == $dep){
-          $found = TRUE;
-          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
-        } else {
-          $options.= "<option value='".$dep."'>$value</option>";
-        }
-      }
-    }
-
-    /* The currently used base is not visible with your acl setup.
-     * Set base to first useable base.
-     */
-    if(!$found){
-      $this->selectedBase = $first;
-    }
-
-    /* Generate list head */
-    $ui = get_userinfo();
-      
-    /* Add default header */
+    $options  = $this->create_department_list($this->module);
     $listhead = MultiSelectWindow::get_default_header();
-
     $listhead .=  
       " "._("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
       " <input class='center' type='image' src='images/lists/submit.png' align='middle' ".
@@ -179,9 +123,7 @@ class divListDepartment extends MultiSelectWindow
   function setEntries($list)
   {
     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;post_id=".$this->post_id."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
-
     $types = $this->parent->get_support_departments();
-
     $this->departments = $list;
 
     $ui = get_userinfo();
@@ -209,7 +151,6 @@ class divListDepartment extends MultiSelectWindow
       /* Get permissions 
        */
       $acl = $ui->get_permissions($val['dn'],"department/".$dep_data['ACL']);
-      $acl_all = $ui->has_complete_category_acls($val['dn'],"department");
 
       /* Create actions 
        */
@@ -220,16 +161,6 @@ class divListDepartment extends MultiSelectWindow
           alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
       }
 
-      /* Check if this department contains sub-departments
-         Display different image in this case
-       */
-      $sub_folders= FALSE;
-      foreach($this->config->departments as $keyd){
-        if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){
-          $sub_folders = TRUE;
-        }
-      }
-
       /* Create entry name 
        */      
       $name = $val[$dep_data['ATTR']][0];
@@ -239,7 +170,7 @@ class divListDepartment extends MultiSelectWindow
 
       /* Create title
        */
-      $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']));
+      $title = @LDAP::fix($val['dn']);
 
       /* Create checkboxes infront of the entry 
        */
@@ -251,15 +182,8 @@ class divListDepartment extends MultiSelectWindow
             "attach" => "style='width:20px;'");
       }
 
-      /* Create image 
-       */
-      if($sub_folders){
-        $img =  "<img alt='".$dep_data['ATTR']."' src='".$dep_data['IMG_FULL']."' 
-          class='center' title='".$dep_data['TITLE']."'>";
-      }else{
-        $img =  "<img alt='".$dep_data['ATTR']."' src='".$dep_data['IMG']."' 
-          class='center' title='".$dep_data['TITLE']."'>";
-      }
+      $img =  "<img alt='".$dep_data['ATTR']."' src='".$dep_data['IMG']."' 
+        class='center' title='".$dep_data['TITLE']."'>";
      
       /* Append data to the listing 
        */