From 700852f694fd2928e66275b3e2c4cdd5573cf0e2 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 30 Oct 2008 08:26:35 +0000 Subject: [PATCH] Improved speed of department listings. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12820 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_departmentManagement.inc | 25 +++--- .../departments/class_divListDepartment.inc | 84 +------------------ 2 files changed, 18 insertions(+), 91 deletions(-) diff --git a/gosa-core/plugins/admin/departments/class_departmentManagement.inc b/gosa-core/plugins/admin/departments/class_departmentManagement.inc index a5e1e3945..677c43f37 100644 --- a/gosa-core/plugins/admin/departments/class_departmentManagement.inc +++ b/gosa-core/plugins/admin/departments/class_departmentManagement.inc @@ -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) diff --git a/gosa-core/plugins/admin/departments/class_divListDepartment.inc b/gosa-core/plugins/admin/departments/class_divListDepartment.inc index 5104c9ee4..7e0d9a420 100644 --- a/gosa-core/plugins/admin/departments/class_divListDepartment.inc +++ b/gosa-core/plugins/admin/departments/class_divListDepartment.inc @@ -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.= ""; - } else { - $options.= ""; - } - } - } - - /* 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")." ". " %s"; - $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('/ /', ' ', @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 = "".$dep_data["; - }else{ - $img = "".$dep_data["; - } + $img = "".$dep_data["; /* Append data to the listing */ -- 2.30.2