Code

Updated dhcp class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 29 Jun 2009 09:46:59 +0000 (09:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 29 Jun 2009 09:46:59 +0000 (09:46 +0000)
-Use the same way to store statements like used to store options.
-No array Merge anymore.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13814 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpGroup.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPlugin.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPool.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpService.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc

index 46eda0f6e96fe0dde7e970248d6307811cdf3373..1f40f9a6e3d2c28c0a856a10c212fc53c22e6ecf 100644 (file)
@@ -22,7 +22,7 @@ class dhcpAdvanced extends plugin
 {
   /* Used attributes */
   var $options= null;
-  var $statements= array();
+  var $statements= null;
   var $show_advanced= FALSE;
   var $autoStatements= array();
   var $autoOptions= array();
@@ -48,14 +48,15 @@ class dhcpAdvanced extends plugin
     if ($acl_writeable && isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
       $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
       $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
-      $this->statements[$key]= $val;
+      $this->statements->add($key,$val);
     }
     if ($acl_writeable && isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
-      $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
-      if (in_array($key, $this->autoStatements)){
-       msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
+      $name = preg_replace('/_[0-9]*$/', '', get_post('dhcpstatements'));
+      $key  = preg_replace('/^.*_/', '', get_post('dhcpstatements'));
+      if (in_array($name, $this->autoStatements)){
+        msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
       } else {
-        unset($this->statements[$key]);        
+        $this->statements->remove($name,$key); 
       }
     }
     if ($acl_writeable && isset($_POST['add_option']) && $_POST['addoption'] != ""){
@@ -75,19 +76,25 @@ class dhcpAdvanced extends plugin
 
     $smarty= get_smarty();
 
-       /* Assign ACLs */
-       $smarty->assign("acl",$this->parent->getacl(""));
+    /* Assign ACLs */
+    $smarty->assign("acl",$this->parent->getacl(""));
 
-    /* Assign arrays */
+    /* Assign statements  */
     $statements= array();
-    foreach ($this->statements as $key => $val){
+    foreach ($this->statements->getAll() as $key => $val){
       if (in_array($key, $this->autoStatements)){
-        $statements[$key]= "$key $val ["._("automatic")."]";
+        foreach($val as $id => $entry){
+          $statements[$key."_".$id]= "$key $entry ["._("automatic")."]";
+        }       
       } else {
-        $statements[$key]= "$key $val";
+        foreach($val as $id => $entry){
+          $statements[$key."_".$id]= "$key $entry";
+        }       
       }
     }
     $smarty->assign("dhcpstatements", $statements);
+
+    /* Assign options  */
     $options= array();
     foreach ($this->options->getAll() as $key => $val){
       if (in_array($key, $this->autoOptions)){
index 29148fdf9504cf77c448b756b79c6e3b601b0e4b..809a1cba0d75179ef7b50f30aa48c4f4e21b373c 100644 (file)
@@ -34,32 +34,21 @@ class dhcpGroup extends dhcpPlugin
     $smarty= get_smarty();
     $smarty->assign("cn", $this->cn);
 
-       /* Assign ACLs */
-       $smarty->assign("acl",$this->parent->getacl(""));
+    /* Assign ACLs */
+    $smarty->assign("acl",$this->parent->getacl(""));
 
     /* Show main page */
-    $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
-
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;
-    }
-
+    $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE, 
+      dirname(__FILE__))).$this->network->execute();
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
+    /* Add footer */
+    $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
+    if(preg_match("/w/",$this->parent->getacl(""))){
+      $display.=        "<input type=submit name='save_dhcp' value='".msgPool::saveButton()."'>&nbsp;";
     }
-
-       /* Add footer */
-       $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
-       if(preg_match("/w/",$this->parent->getacl(""))){
-               $display.=       "<input type=submit name='save_dhcp' value='".msgPool::saveButton()."'>&nbsp;";
-       }
-       $display.=   "<input type=submit name='cancel_dhcp' value='".msgPool::cancelButton()."'>";
-       $display.= "</div>";
+    $display.=   "<input type=submit name='cancel_dhcp' value='".msgPool::cancelButton()."'>";
+    $display.= "</div>";
 
     return ($display);
   }
index 12f4f559e58fc01b027e439d6f8ea63e35faec49..c3168ada75e8ba6cb99350a123fc02743c5abaf4 100644 (file)
@@ -39,7 +39,7 @@ class dhcpHost extends dhcpPlugin
     $this->advanced->setAutoOptions(array("host-name"));
     $this->advanced->setAutoStatements(array("fixed-address"));
 
-       $this->realGosaHost = $host_exists_in_gosa;
+    $this->realGosaHost = $host_exists_in_gosa;
   }
 
   function execute()
@@ -53,11 +53,7 @@ class dhcpHost extends dhcpPlugin
     $smarty->assign("acl",$this->parent->getacl(""));
 
     /* Create fixed address */
-    if (isset($this->statements['fixed-address'])){
-      $smarty->assign("fixedaddr", $this->statements['fixed-address']);
-    } else {
-      $smarty->assign("fixedaddr", "");
-    }
+    $smarty->assign("fixedaddr", $this->statements->get('fixed-address'));
 
     /* Prepare hw type selector */
     $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
@@ -68,18 +64,9 @@ class dhcpHost extends dhcpPlugin
     /* Show main page */
     $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
 
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;
-    }
+    /* Get advanced options */
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
-    }
-
     /* Add footer */
     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
 #    if(preg_match("/w/",$this->parent->getacl(""))){
@@ -115,9 +102,9 @@ class dhcpHost extends dhcpPlugin
       /* Save fixed address */
       if(!$this->realGosaHost){
         if ($_POST['fixedaddr'] != ""){
-          $this->statements['fixed-address']= get_post('fixedaddr');
+          $this->statements->set('fixed-address', get_post('fixedaddr'));
         } else {
-          unset ($this->statements['fixed-address']);
+          $this->statements->removeAll('fixed-address');
         }
       }
       $this->options->set('host-name',$this->cn);
index a1980bf15c76c7db1f497207626a0bd0d01bcad8..44227cb2bbc299af044e6589a5ade2db97808650 100644 (file)
@@ -22,7 +22,7 @@ class dhcpNetwork extends plugin
 {
   /* Used attributes */
   var $options= null;
-  var $statements= array();
+  var $statements= null;
 
   /* attribute list for save action */
   var $attributes= array();
@@ -106,27 +106,19 @@ class dhcpNetwork extends plugin
     $smarty->assign("broadcast_address", $this->options->get('broadcast-address'));
 
     /* Boot stuff */
-    if (isset($this->statements['filename'])){
-      $smarty->assign("filename", trim($this->statements['filename'], '"'));
-    } else {
-      $smarty->assign("filename", "");
-    }
-    if (isset($this->statements['next-server'])){
-      $smarty->assign("nextserver", $this->statements['next-server']);
-    } else {
-      $smarty->assign("nextserver", "");
-    }
+    $smarty->assign("filename", $this->statements->get('filename'));
+    $smarty->assign("nextserver", $this->statements->get('next-server'));
 
     /* Set flags */
     $smarty->assign("autohost", "");
-    if (isset($this->statements['get-lease-hostnames'])){
-      if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){
+    if ($this->statements->exists('get-lease-hostnames')){
+      if (preg_match('/^(true|on|yes)$/', $this->statements->get('get-lease-hostnames'))){
         $smarty->assign("autohost", "checked");
       }
     }
     $smarty->assign("autohostdecl", "");
-    if (isset($this->statements['use-host-decl-names'])){
-      if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){
+    if ($this->statements->exists('use-host-decl-names')){
+      if (preg_match('/^(true|on|yes)$/', $this->statements->get('use-host-decl-names'))){
         $smarty->assign("autohostdecl", "checked");
       }
     }
@@ -162,28 +154,28 @@ class dhcpNetwork extends plugin
       /* Statements */
       foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){
         if ($_POST["$val"] == ''){
-          unset($this->statements["$key"]);
+          $this->statements->removeAll($key);
         } else {
     
           /* Only quote filename values */
           if(in_array($key,array("filename"))){
-            $this->statements["$key"]= '"'.get_post("$val").'"';
+            $this->statements->set($key,'"'.trim(get_post($val),"\"").'"');
           }else{
-            $this->statements["$key"]= get_post("$val");
+            $this->statements->set($key,get_post($val));
           }
         }
       }
 
       /* Flags */
       if (isset ($_POST['autohost'])){
-        $this->statements['get-lease-hostnames']= "true";
+        $this->statements->set('get-lease-hostnames',"true");
       } else {
-        unset($this->statements['get-lease-hostnames']);
+        $this->statements->removeAll('get-lease-hostnames');
       }
       if (isset ($_POST['autohostdecl'])){
-        $this->statements['use-host-decl-names']= "on";
+        $this->statements->set('use-host-decl-names', "on");
       } else {
-        unset($this->statements['use-host-decl-names']);
+        $this->statements->removeAll('use-host-decl-names');
       }
     }
   }
index f0e3f8dc5c3d2eb857c571f2838ba39cfb371722..bef932108f1dd494fdbf34b028042061b8c6a4a0 100644 (file)
@@ -39,6 +39,7 @@ class dhcpPlugin extends plugin
     $this->parent = $parent;
 
     $this->options = new dhcpOption();
+    $this->statements = new dhcpOption();
 
     /* Load statements / options */
     if (is_array($attrs)){
@@ -55,19 +56,8 @@ class dhcpPlugin extends plugin
 
       /* Load statements */
       if (isset($attrs['dhcpStatements'])){
-        foreach ($attrs['dhcpStatements'] as $opt){
-          $idx= preg_replace('/\s.+$/', '', $opt);
-          if ($idx == $opt){
-            $value= "";
-          } else {
-            $value= preg_replace('/^[^\s]+\s/', '', $opt);
-          }
-
-          if(preg_match("/^allow\s/",$opt) || preg_match("/^deny\s/",$opt)){
-            $this->statements[$opt]= "";
-          }else{
-            $this->statements[$idx]= $value;
-          }
+        foreach($attrs['dhcpStatements'] as $opt){
+          $this->statements->add(trim($opt));
         }
       }
     } else {
@@ -79,10 +69,10 @@ class dhcpPlugin extends plugin
     /* Load network module */
     $this->network= new dhcpNetwork();
     $this->network->options= &$this->options;
-    $this->network->statements= $this->statements;
+    $this->network->statements= &$this->statements;
     $this->advanced= new dhcpAdvanced();
     $this->advanced->options= &$this->options;
-    $this->advanced->statements= $this->statements;
+    $this->advanced->statements= &$this->statements;
 
     $this->network->parent = $parent;
     $this->advanced->parent = $parent;
@@ -105,18 +95,14 @@ class dhcpPlugin extends plugin
   /* Save data to object */
   function save_object()
   {
-    foreach (array("filename", "next-server","get-lease-hostnames","use-host-decl-names") as $toberemoved){
-      unset($this->statements[$toberemoved]);
-    }
+ # // CHECK
+ #   foreach (array("filename", "next-server","get-lease-hostnames","use-host-decl-names") as $toberemoved){
+ #     unset($this->statements[$toberemoved]);
+ #   }
 
     /* Save sub-objects */
     $this->network->save_object();
     $this->advanced->save_object();
-
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;;
-    }
   }
 
 
@@ -131,11 +117,6 @@ class dhcpPlugin extends plugin
   /* Save to LDAP */
   function save()
   {
-    /* Merge arrays for network and advanced view */
-    foreach (array("statements") as $type){
-      $this->$type= $this->$type + $this->network->$type + $this->advanced->$type;
-    }
-
     /* Add cn if we're new */
     if ($this->new){
       $this->dn= "cn=".$this->cn.",".$this->dn;
@@ -147,16 +128,7 @@ class dhcpPlugin extends plugin
     $this->attrs['dhcpOption']= $this->options->save();
 
     /* Assemble new entry - statements */
-    $this->attrs['dhcpStatements']= array();
-    if (isset ($this->statements) && count ($this->statements)){
-      foreach ($this->statements as $key => $val){
-        if ($val != ""){
-          $this->attrs['dhcpStatements'][]= "$key $val";
-        } else {
-          $this->attrs['dhcpStatements'][]= "$key";
-        }
-      }
-    }
+    $this->attrs['dhcpStatements']= $this->statements->save();
 
     /* Move dn to the result */
     $this->attrs['dn']= $this->dn;
index 4d0a5c791bb08d79be9a9887c6ea1b3266b74a85..96870e7c583d3bb4c0e301c4590b7fb267813af1 100644 (file)
@@ -55,19 +55,8 @@ class dhcpPool extends dhcpPlugin
     /* Show main page */
     $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
 
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;;
-    }
-
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
-    }
-
     /* Add footer */
     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
     if(preg_match("/w/",$this->parent->getacl(""))){
index 36ca957630c74762579742e0af7253e548bfbdf8..925e6ac50090d27f7c6a4b4a73267a324d7cbf0f 100644 (file)
@@ -39,14 +39,15 @@ class dhcpService extends dhcpPlugin
       $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
     } else {
       /* We keep the parent dn here if it's new */
-      $this->statements['default-lease-time']= 600;
-      $this->statements['max-lease-time']= 1700;
-      $this->statements['authoritative']= TRUE;
-      $this->statements['ddns-update-style']= 'none';
+      $this->statements->set('default-lease-time', 600);
+      $this->statements->set('max-lease-time', 1700);
+      $this->statements->set('authoritative', TRUE);
+      $this->statements->set('ddns-update-style', 'none');
     }
 
-    $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style"));
     $this->advanced->setAutoOptions(array("server-name"));
+    $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", 
+          "authoritative", "server-identifier", "ddns-update-style"));
 
     /* Save for later action */
     $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
@@ -63,35 +64,16 @@ class dhcpService extends dhcpPlugin
 
     $smarty->assign('ddns_styles', $this->ddns_styles);
     foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
-      if (isset($this->statements[preg_replace('/_/', '-', $value)])){
-        $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
-      } else {
-        $smarty->assign("$value", "");
-      }
+      $smarty->assign("$value", $this->statements->get(preg_replace('/_/', '-', $value)));
     }
 
-    if (isset($this->statements['authoritative'])){
-      $smarty->assign("authoritative", "checked");
-    } else {
-      $smarty->assign("authoritative", "");
-    }
+    $smarty->assign("authoritative", $this->statements->get('authoritative'));
 
     /* Show main page */
     $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
 
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;;
-    }
-
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
-    }
-
     /* Add footer */
     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
     if(preg_match("/w/",$this->parent->getacl(""))){
@@ -119,15 +101,15 @@ class dhcpService extends dhcpPlugin
       foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
         $tval= preg_replace('/_/', '-', $val);
         if ($_POST[$val] != ""){
-          $this->statements[$tval]= validate(get_post($val));
+          $this->statements->set($tval,validate(get_post($val)));
         } else {
-          unset ($this->statements[$tval]);
+          $this->statements->removeAll($tval);
         }
       }
       if (isset($_POST['authoritative'])){
-        $this->statements['authoritative']= "";
+        $this->statements->set('authoritative', "");
       } else {
-        unset($this->statements['authoritative']);
+        $this->statements->removeAll('authoritative');
       }
     }
 
@@ -140,13 +122,13 @@ class dhcpService extends dhcpPlugin
   {
     $message= array();
 
-    if (!tests::is_id($this->statements['default-lease-time'])){
-      $message[]= msgPool::invalid(_("Lease time"),$this->statements['default-lease-time'],"/[0-9]/");
+    if (!tests::is_id($this->statements->get('default-lease-time'))){
+      $message[]= msgPool::invalid(_("Lease time"),$this->statements->get('default-lease-time'),"/[0-9]/");
     }
-    if (!tests::is_id($this->statements['max-lease-time'])){
-      $message[]= msgPool::invalid(_("Max lease time"),$this->statements['max-lease-time'],"/[0-9]/");
+    if (!tests::is_id($this->statements->get('max-lease-time'))){
+      $message[]= msgPool::invalid(_("Max lease time"),$this->statements->get('max-lease-time'),"/[0-9]/");
     }
-    if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){
+    if ($this->statements->get('default-lease-time') > $this->statements->get('max-lease-time')){
       $message[]= msgPool::toobig(_("Default lease time"),_("Maximum lease time"));
     }
 
@@ -154,7 +136,6 @@ class dhcpService extends dhcpPlugin
     $net= $this->network->check();
     $adv= $this->advanced->check();
     $message= array_merge($message, $net, $adv);
-
     return $message;
   }
 
index b60ebdd33a3774e3664ebd5f92b63096d6d10a3f..6f7964832f56c2296738c61f8459bcfdfcd50a51 100644 (file)
@@ -44,28 +44,25 @@ class dhcpSharedNetwork extends dhcpPlugin
     /* Fill template */
     $smarty->assign ("cn", $this->cn);
     foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){
-      if (isset($this->statements[$attr])){
-        $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]);
-      } else {
-        $smarty->assign(preg_replace('/-/', '_', $attr), "");
-      }
+      $name = preg_replace('/-/', '_', $attr);
+      $smarty->assign($name, $this->statements->get($attr));
     }
-    if (isset($this->statements["authoritative"])){
+    if ($this->statements->exists("authoritative")){
       $smarty->assign("authoritative", "checked");
     } else {
       $smarty->assign("authoritative", "");
     }
-    if (!isset($this->statements["deny unknown-clients"])){
+    if (!$this->statements->exists("deny unknown-clients")){
       $smarty->assign("allow_unknown_state", "checked");
     } else {
       $smarty->assign("allow_unknown_state", "");
     }
-    if (!isset($this->statements["deny bootp"])){
+    if (!$this->statements->exists("deny bootp")){
       $smarty->assign("allow_bootp_state", "checked");
     } else {
       $smarty->assign("allow_bootp_state", "");
     }
-    if (!isset($this->statements["deny booting"])){
+    if (!$this->statements->exists("deny booting")){
       $smarty->assign("allow_booting_state", "checked");
     } else {
       $smarty->assign("allow_booting_state", "");
@@ -79,24 +76,13 @@ class dhcpSharedNetwork extends dhcpPlugin
     foreach(array("deny unknown-clients",
           "deny bootp", "deny booting", "allow unknown-clients",
           "allow bootp", "allow booting") as $name){
-      if(isset($this->advanced->statements[$name])){
-        unset($this->advanced->statements[$name]);
-        unset($this->network->statements[$name]);
+      if($this->statements->exists($name)){
+        $this->statements->remove($name);
       }
     }
 
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;
-    }
-
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
-    }
-
     /* Add footer */
     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
     if(preg_match("/w/",$this->parent->getacl(""))){
@@ -129,25 +115,25 @@ class dhcpSharedNetwork extends dhcpPlugin
       foreach (array("server-identifier", "default-lease-time",
             "max-lease-time", "min-lease-time") as $attr){
         if (isset($_POST[$attr]) && $_POST[$attr] != ""){
-          $this->statements[$attr]= get_post($attr);
+          $this->statements->set($attr,get_post($attr));
         } else {
-          unset($this->statements[$attr]);
+          $this->statements->removeAll($attr);
         }
       }
 
       if (isset($_POST["authoritative"])){
-        $this->statements["authoritative"]= "";
+        $this->statements->set("authoritative", "");
       } else {
-        unset ($this->statements["authoritative"]);
+        $this->statements->removeAll("authoritative");
       }
 
       foreach(array("unknown-clients", "bootp", "booting") as $name){
         if (isset($_POST[$name])){
-          $this->statements["allow $name"]= "";
-          unset($this->statements["deny $name"]);
+          $this->statements->removeAll("deny $name");
+          $this->statements->set("allow $name","");
         } else {
-          $this->statements["deny $name"]= "";
-          unset($this->statements["allow $name"]);
+          $this->statements->removeAll("allow $name");
+          $this->statements->set("deny $name","");
         }
       }
     }
@@ -170,9 +156,9 @@ class dhcpSharedNetwork extends dhcpPlugin
     foreach (array("default-lease-time" => _("Default lease time"),
           "max-lease-time" => _("Max. lease time"),
           "min-lease-time" => _("Min. lease time")) as $key => $val){
-      if (isset($this->statements[$key]) && $this->statements[$key] != "" && 
-          !tests::is_id($this->statements[$key])){
-        $message[]= msgPool::invalid($val,$this->statements[$key],"/[0-9]/");
+      if ($this->statements->exists($key) && $this->statements->get($key) != "" && 
+          !tests::is_id($this->statements->get($key))){
+        $message[]= msgPool::invalid($val,$this->statements->get($key),"/[0-9]/");
       }
     }
 
index 1a900cdf699e05b79b1e1fe2c8b545186fde5511..8a8131c1542816b19aa2e04eeef465d2e4bd3a6a 100644 (file)
@@ -74,19 +74,8 @@ class dhcpSubnet extends dhcpPlugin
     /* Show main page */
     $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
 
-    /* Merge arrays for advanced view */
-    foreach (array("statements") as $type){
-      $this->advanced->$type= $this->$type + $this->network->$type;
-    }
-
     $display.= $this->advanced->execute();
 
-    /* Merge back for removals */
-    foreach (array("statements") as $type){
-      $this->$type= $this->advanced->$type;
-      $this->network->$type= $this->advanced->$type;
-    }
-
     /* Add footer */
     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
     if(preg_match("/w/",$this->parent->getacl(""))){