Code

Replaced print_red with msg_dialog, for testing
[gosa.git] / include / class_config.inc
index e16945b88eb1415d26b23a78da6a8d3d11b8405b..036872656097e5a8e376521e14ff64081267e1d1 100644 (file)
@@ -308,7 +308,7 @@ class config  {
   function load_servers ()
   {
     /* Only perform actions if current is set */
-    if ($this->current == NULL){
+    if ($this->current === NULL){
       return;
     }
 
@@ -751,6 +751,46 @@ class config  {
     return FALSE;
   }
 
+
+  function __search(&$arr, $name, $return)
+  {
+    $return= strtoupper($return);
+    if (is_array($arr)){
+      foreach ($arr as &$a){
+        if (isset($a['CLASS']) && strcasecmp($name, $a['CLASS']) == 0){
+          return(isset($a[$return])?$a[$return]:"");
+        } else {
+          $res= $this->__search ($a, $name, $return);
+          if ($res != ""){
+            return $res;
+          }
+        }
+      }
+    }
+    return ("");
+  }
+
+
+  function search($class, $value, $categories= "")
+  {
+    if (is_array($categories)){
+      foreach ($categories as $category){
+        $res= $this->__search($this->data[strtoupper($category)], $class, $value);
+        if ($res != ""){
+          return $res;
+        }
+      }
+    } else {
+      if ($categories == "") {
+        return $this->__search($this->data, $class, $value);
+      } else {
+        return $this->__search($this->data[strtoupper($categories)], $class, $value);
+      }
+    } 
+
+    return ("");
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: