Code

Updated function_dns.inc
[gosa.git] / include / class_dhcpPlugin.inc
index c0da9bf10bbcbd0fb1826e45f35e6a62cdf70fc1..b9d48b25fa2b01a92e0d8b1f6a1b2034a5ffe2b3 100644 (file)
@@ -46,7 +46,11 @@ class dhcpPlugin extends plugin
       if (isset($attrs['dhcpOption'])){
         foreach ($attrs['dhcpOption'] as $opt){
           $idx= preg_replace('/\s.+$/', '', $opt);
-          $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          if ($idx == $opt){
+            $value= "";
+          } else {
+            $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          }
           $this->options[$idx]= $value;
         }
       }
@@ -55,7 +59,11 @@ class dhcpPlugin extends plugin
       if (isset($attrs['dhcpStatements'])){
         foreach ($attrs['dhcpStatements'] as $opt){
           $idx= preg_replace('/\s.+$/', '', $opt);
-          $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          if ($idx == $opt){
+            $value= "";
+          } else {
+            $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          }
           $this->statements[$idx]= $value;
         }
       }
@@ -106,8 +114,7 @@ class dhcpPlugin extends plugin
 
     /* Merge arrays for advanced view */
     foreach (array("options", "statements") as $type){
-      $tmp= array_merge($this->$type, $this->network->$type);
-      $this->advanced->$type= $tmp;
+      $this->advanced->$type= $this->$type + $this->network->$type;;
     }
   }
 
@@ -116,7 +123,6 @@ class dhcpPlugin extends plugin
   function check($cache)
   {
     $message= array();
-
     return $message;
   }
 
@@ -126,8 +132,7 @@ class dhcpPlugin extends plugin
   {
     /* Merge arrays for network and advanced view */
     foreach (array("options", "statements") as $type){
-      $tmp= array_merge($this->$type, $this->network->$type, $this->advanced->$type);
-      $this->$type= $tmp;
+      $this->$type= $this->$type + $this->network->$type + $this->advanced->$type;
     }
 
     /* Add cn if we're new */
@@ -166,6 +171,30 @@ class dhcpPlugin extends plugin
     return ($this->attrs);
   }
 
+
+  function removeAttrs($name, $type)
+  {
+    $new= array();
+    foreach ($this->attrs[$type] as $value){
+      if (!preg_match("/^$name /", $value)){
+        $new[]= $value;
+      }
+    }
+    $this->attrs[$type]= $new;
+  }
+
+
+  function removeOption($name)
+  {
+    $this->removeAttrs($name, 'dhcpOption');
+  }
+
+
+  function removeStatement($name)
+  {
+    $this->removeAttrs($name, 'dhcpStatement');
+  }
+
 }
 
 ?>