From: hickert Date: Wed, 23 Dec 2009 09:30:54 +0000 (+0000) Subject: Added a 'method' tag to filter class. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=099fb791bb6d2c03127ac3d547d1540a456218e1;p=gosa.git Added a 'method' tag to filter class. -This tag is forwarded to the selected filter method e.g. filterLDAP and allows to implement special search methods like 'cat', which is required for the ACL listing for example. Else, we wont be able to edit ACLs setting appended the the ldap base object. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14926 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index 9b2fed545..286725978 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -383,6 +383,9 @@ class filter { $filter= $query['filter']; $attributes= $query['attribute']; + $method = ""; + if(isset($query['method'])) $method = $query['method']; + // Generate final filter foreach ($this->elements as $tag => $element) { if (!isset($element['set']) || !isset($element['unset'])) { @@ -408,7 +411,8 @@ class filter { } } - $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, $this->category, $this->objectStorage)); + $result= array_merge($result, call_user_func(array($backend, 'query'), $this->base, $this->scope, $filter, $attributes, $this->category,$method, $this->objectStorage)); + $result = call_user_func(array($backend, 'unifyResults'), $result); } return ($result); diff --git a/gosa-core/include/class_filterLDAP.inc b/gosa-core/include/class_filterLDAP.inc index 769746204..d49463ae6 100644 --- a/gosa-core/include/class_filterLDAP.inc +++ b/gosa-core/include/class_filterLDAP.inc @@ -2,17 +2,29 @@ class filterLDAP { - static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "") + static function query($base, $scope, $filter, $attributes, $category, $method,$objectStorage= "") { $config= session::global_get('config'); $ldap= $config->get_ldap_link(TRUE); $flag= ($scope == "sub")?GL_SUBSEARCH:0; - $result= filterLDAP::get_list($base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT); + $result= filterLDAP::get_list($base, $filter, $attributes, $category, $objectStorage,$method, $flag | GL_SIZELIMIT); return $result; } + + static function unifyResults($results) + { + $res = array(); + foreach($results as $entry){ + if(!isset($res[$entry['dn']])){ + $res[$entry['dn']] = $entry; + } + } + return(array_values($res)); + } + - static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH) + static function get_list($base, $filter, $attributes, $category, $objectStorage, $method, $flags= GL_SUBSEARCH) { $ui= session::global_get('ui'); $config= session::global_get('config'); @@ -24,7 +36,9 @@ class filterLDAP { if (!is_array($objectStorage)) { $objectStorage= array($objectStorage); } - $method= (empty($objectStorage) && !($flags & GL_SUBSEARCH))?"ls":"search"; + if(empty($method)){ + $method= (empty($objectStorage) && !($flags & GL_SUBSEARCH))?"ls":"search"; + } // Initialize search bases $bases= array();