From: cajus Date: Fri, 21 Aug 2009 14:17:27 +0000 (+0000) Subject: Limit for autocompleter, sort autocompletition results X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9fd2e5d3dfc118c48d94bfec2b8faf5ebd663876;p=gosa.git Limit for autocompleter, sort autocompletition results git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14107 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index 0bea6c4a6..4a132154c 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -29,7 +29,6 @@ class filter { var $autocompleter= array(); var $category= ""; var $objectStorage= array(); - var $objectBase= ""; var $base= ""; var $scope= ""; var $query; @@ -243,11 +242,6 @@ class filter { } - function setObjectBase($base) { - $this->objectBase= $base; - } - - function setBase($base) { $this->base= $base; } @@ -383,7 +377,7 @@ class filter { } $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, - $this->category, $this->objectStorage, $this->objectBase)); + $this->category, $this->objectStorage)); } @@ -458,13 +452,12 @@ class filter { // Make filter $filter= preg_replace("/\\$$tag/", normalizeLDAP($value), $filter); - if (isset($config['base']) && isset($config['scope']) - && isset($config['category']) && isset($config['objectbase']) ) { + if (isset($config['base']) && isset($config['scope']) && isset($config['category'])) { $result= call_user_func(array($backend, 'query'), $config['base'], $config['scope'], $filter, $attributes, - $config["category"], $config["objectbase"]); + $config["category"], $config["objectStorage"]); } else { $result= call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, - $this->category, $this->objectStorage, $this->objectBase); + $this->category, $this->objectStorage); } foreach ($result as $entry) { @@ -488,18 +481,25 @@ class filter { global $class_mapping; $result= array(); + // Introduce maximum number of entries + $max= 10; + foreach ($this->autocompleters as $tag => $config) { if(isset($_POST[$tag])){ $result= $this->getCompletitionList($config, $tag, $_POST[$tag]); + $result= array_unique($result); + asort($result); echo ''; } - } } diff --git a/gosa-core/include/class_filterLDAP.inc b/gosa-core/include/class_filterLDAP.inc index 3636af9f3..5a6701d65 100644 --- a/gosa-core/include/class_filterLDAP.inc +++ b/gosa-core/include/class_filterLDAP.inc @@ -29,24 +29,28 @@ class filterLDAP { $bases= array(); // Get list of sub bases to search on - foreach ($objectStorage as $oc) { - $oc= preg_replace('/,$/', '', $oc); - $tmp= split(',', $oc); - if (count($tmp) == 1) { - preg_match('/([^=]+)=(.*)$/', $oc, $m); - if ($flags & GL_SUBSEARCH) { - $bases[$base][]= $m[1].":dn:=".$m[2]; - } else { - $bases["$oc,$base"][]= $m[1].":dn:=".$m[2]; - } - } else { - // No, there's no \, in pre defined RDN values - preg_match('/^([^,]+),(.*)$/', $oc, $matches); - preg_match('/([^=]+)=(.*)$/', $matches[1], $m); - if ($flags & GL_SUBSEARCH) { - $bases[$base][]= $m[1].":dn:=".$m[2]; + if (count($objectStorage) == 0) { + $bases[$base]= ""; + } else { + foreach ($objectStorage as $oc) { + $oc= preg_replace('/,$/', '', $oc); + $tmp= split(',', $oc); + if (count($tmp) == 1) { + preg_match('/([^=]+)=(.*)$/', $oc, $m); + if ($flags & GL_SUBSEARCH) { + $bases[$base][]= $m[1].":dn:=".$m[2]; + } else { + $bases["$oc,$base"][]= $m[1].":dn:=".$m[2]; + } } else { - $bases[$matches[2].",$base"][]= $m[1].":dn:=".$m[2]; + // No, there's no \, in pre defined RDN values + preg_match('/^([^,]+),(.*)$/', $oc, $matches); + preg_match('/([^=]+)=(.*)$/', $matches[1], $m); + if ($flags & GL_SUBSEARCH) { + $bases[$base][]= $m[1].":dn:=".$m[2]; + } else { + $bases[$matches[2].",$base"][]= $m[1].":dn:=".$m[2]; + } } } } @@ -66,11 +70,15 @@ class filterLDAP { // Switch to new base and search $ldap->cd($base); - $dnFilter= "(|"; - foreach ($dnFilters as $df) { - $dnFilter.= "($df)"; + if (is_array($dnFilters)){ + $dnFilter= "(|"; + foreach ($dnFilters as $df) { + $dnFilter.= "($df)"; + } + $dnFilter.= ")"; + } else { + $dnFilter= ""; } - $dnFilter.= ")"; $ldap->search ("(&$filter$dnFilter)", $attributes); // Check for size limit exceeded messages for GUI feedback