Code

Only find adequat values
[gosa.git] / gosa-core / include / class_filter.inc
index 4d8260fc457e7b37938a64a68fa968b1dd79ad78..0b5f1778a9263186bbada5d718d35540cb2ffcd6 100644 (file)
@@ -54,11 +54,11 @@ class filter {
     $contents = file_get_contents($filename);
     $this->xmlData= xml::xml2array($contents, 1);
 
-    if (!isset($this->xmlData['filter'])) {
+    if (!isset($this->xmlData['filterdef'])) {
       return false;
     }
 
-    $this->xmlData= $this->xmlData["filter"];
+    $this->xmlData= $this->xmlData["filterdef"];
 
     // Load filter
     if (isset($this->xmlData['search'])) {
@@ -353,6 +353,12 @@ class filter {
     global $class_mapping;
     $result= array();
 
+    // Return empty list if initial is not set
+    if (!$this->initial) {
+      $this->initial= true;
+      return $result;
+    }
+
     // Go thru all queries and merge results
     foreach ($this->query as $query) {
       if (!isset($query['backend']) || !isset($query['filter']) || !isset($query['attribute'])) {
@@ -480,7 +486,9 @@ class filter {
       foreach ($attributes as $attribute) {
         if (is_array($entry[$attribute])) {
           for ($i= 0; $i<$entry[$attribute]['count']; $i++) {
-            $res[]= $entry[$attribute][$i];
+            if (mb_stristr($entry[$attribute][$i], $value)) {
+              $res[]= $entry[$attribute][$i];
+            }
           }
         } else {
           $res[]= $entry[$attribute];