summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e39dc93)
raw | patch | inline | side by side (parent: e39dc93)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 26 Jun 2009 09:27:14 +0000 (09:27 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 26 Jun 2009 09:27:14 +0000 (09:27 +0000) |
-We are now able to set variables twice.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13800 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13800 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc
index 755214411ca6755a50ef79febf51316bd4c0c99d..8dd90a62774767c2d53641b9caaf539082c78e1f 100644 (file)
var $objectclasses= array();
var $parent;
+ static function getOption($needle, $heystack, $value_only = false){
+ foreach($heystack as $key => $val){
+ if($val != $key){
+ echo "<b>$key => $val</b>";
+ }
+
+ if(preg_match("/^{$needle} /i",$val)){
+ if($value_only){
+ return(trim(preg_replace('/^[^\s]*/')));
+ }else{
+ return($val);
+ }
+ }
+ }
+ return("");
+ }
+
function dhcpAdvanced()
{
/* This is always an account */
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);
+ msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
} else {
unset($this->statements[$key]);
}
}
if ($acl_writeable && isset($_POST['add_option']) && $_POST['addoption'] != ""){
- $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
- $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
- $this->options[$key]= $val;
+ $val= trim(get_post('addoption'));
+ $this->options[$val]= $val;
}
if ($acl_writeable && isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
$key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
+ $val= get_post('dhcpoptions');
if (in_array($key, $this->autoOptions)){
- msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
+ msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
} else {
- unset($this->options[$key]);
+ unset($this->options[$val]);
}
}
$smarty->assign("dhcpstatements", $statements);
$options= array();
foreach ($this->options as $key => $val){
+ $key = preg_replace("/ .*$/","",$val);
if (in_array($key, $this->autoOptions)){
- $options[$key]= "$key $val ["._("automatic")."]";
+ $options[$val]= "$val ["._("automatic")."]";
} else {
- $options[$key]= "$key $val";
+ $options[$val]= "$val";
}
}
$smarty->assign("dhcpoptions", $options);
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc
index c7569d2c95f46da2445ff64076f60cc721ba2dd5..e407ba54d2bbbaed06379cb6438916c56f9c704f 100644 (file)
unset ($this->statements['fixed-address']);
}
}
- $this->options['host-name']= $this->cn;
+ $hn = "host-name {$this->cn}";
+ $this->options[$hn]= $hn;
}
dhcpPlugin::save_object();
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc
index 0f99ce23b3b6ec4f4b99525ef4bc26391b78b756..dce548ba3a5af1b64fb58e103c8ca6ee4613dc91 100644 (file)
htmlentities(get_post('addserver')),"/[0-9a-z.-]/"), ERROR_DIALOG);
} else {
$servers= array();
- if (isset($this->options['domain-name-servers'])){
- foreach(split(",", $this->options['domain-name-servers']) as $val){
+ $chk = dhcpAdvanced::getOption('domain-name-servers',$this->options,true);
+ if($chk != ""){
+ foreach(split(",", $chk) as $val){
$servers[$val]= $val;
}
}
foreach($servers as $val){
$tmp.= $val.",";
}
- $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
+ $chk = dhcpAdvanced::getOption('domain-name-servers',$this->options);
+ if($chk != ""){
+ unset($this->options[$chk]);
+ }
+ $new = "domain-name-servers ".preg_replace('/,$/', '', $tmp);
+ $this->options[$new]=$new;
}
}
if ($acl_writeable && isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
- $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
- $this->options['domain-name-servers']);
- $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
- if ($tmp != ""){
- $this->options['domain-name-servers']= $tmp;
- } else {
- unset($this->options['domain-name-servers']);
+ $val = dhcpAdvanced::getOption('domain-name-servers', $this->options, true);
+ $key = dhcpAdvanced::getOption('domain-name-servers', $this->options);
+
+ if($key != ""){
+ unset($this->options[$key]);
+ $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i",'', $val);
+ $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
+ if ($tmp != ""){
+ $tmp ="domain-name-servers {$tmp}";
+ $this->options[$tmp]= $tmp;
+ }
}
+
}
/* Show main page */
*/
/* Router */
- if (isset($this->options['routers'])){
- $smarty->assign("routers", $this->options['routers']);
- } else {
- $smarty->assign("routers", "");
- }
+ $smarty->assign("routers", dhcpAdvanced::getOption('router',$this->options));
/* DNS */
- if (isset($this->options['domain-name'])){
- $smarty->assign("domain", trim($this->options['domain-name'], '"'));
- } else {
- $smarty->assign("domain", "");
- }
- if (isset($this->options['domain-name-servers'])){
+ $smarty->assign("domain", dhcpAdvanced::getOption('domain-name',$this->options));
+ if (dhcpAdvanced::getOption('domain-name-servers',$this->options) != ""){
$servers= array();
- foreach(split(",", $this->options['domain-name-servers']) as $val){
+ foreach(split(",", dhcpAdvanced::getOption('domain-name-servers',$this->options, true)) as $val){
$servers[$val]= $val;
}
$smarty->assign("dnsservers", $servers);
}
/* Netmask / Broadcast */
- if (isset($this->options['subnet-mask'])){
- $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']);
- $smarty->assign("subnet_mask", $this->options['subnet-mask']);
+ if (dhcpAdvanced::getOption('subnet-mask', $this->options) != ""){
+ $key = dhcpAdvanced::getOption('subnet-mask', $this->options);
+ $val = dhcpAdvanced::getOption('subnet-mask', $this->options,true);
+
+ unset($this->options[$key]);
+ $new = 'subnet-mask '.normalize_netmask($val);
+ $this->options[$new]=$new;
+ $smarty->assign("subnet_mask", $new);
} else {
$smarty->assign("subnet_mask", "");
}
- if (isset($this->options['broadcast-address'])){
- $smarty->assign("broadcast_address", $this->options['broadcast-address']);
- } else {
- $smarty->assign("broadcast_address", "");
- }
+ $smarty->assign("broadcast_address", dhcpAdvanced::getOption('broadcast-address',$this->options));
/* Boot stuff */
if (isset($this->statements['filename'])){
foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask",
"broadcast-address" => "broadcast_address") as $key => $val){
- if ($_POST["$val"] == ''){
- unset($this->options["$key"]);
- } else {
- $this->options["$key"]= get_post("$val");
+ $ikey = dhcpAdvanced::getOption($key, $this->options);
+ if($ikey != ""){
+ unset($this->options[$ikey]);
+ }
+ if ($_POST["$val"] != ''){
+ $new = $key." ".$get_post($val);
+ $this->options[$new]=$new;
}
}
/* Check netmask and broadcast */
foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){
- if (!isset($this->options["$key"])){
+ $ikey = dhcpAdvanced::getOption($key,$this->options);
+ $ival = dhcpAdvanced::getOption($key,$this->options,true);
+ if ($ikey == ""){
continue;
}
- $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]);
-
+ $tmp= preg_replace('/^[^\s]+\s/', '', $ival);
if (!tests::is_ip($tmp)){
$message[]= sprintf(_("Error in definition of '%s'!"), $typ);
}
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPlugin.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPlugin.inc
index f6b9f39b3c5d0e819e37e97b388cce5d35ae349e..89575229dc8911978a0ad446a71643cf9ab9a8f7 100644 (file)
/* Load options */
if (isset($attrs['dhcpOption'])){
foreach ($attrs['dhcpOption'] as $opt){
- $idx= preg_replace('/\s.+$/', '', $opt);
- if ($idx == $opt){
- $value= "";
- } else {
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
- }
- $this->options[$idx]= $value;
+ $opt = trim($opt);
+ $this->options[$opt]= $opt;
}
}
{
/* Strip network objects */
foreach (array("routers", "domain-name", "subnet-mask", "broadcast-address") as $toberemoved){
- unset($this->options[$toberemoved]);
+ $ikey = dhcpAdvanced::getOption($toberemoved, $this->options);
+ if($ikey != ""){
+ unset($this->options[$ikey]);
+ }
}
foreach (array("filename", "next-server","get-lease-hostnames","use-host-decl-names") as $toberemoved){
unset($this->statements[$toberemoved]);
$this->attrs['dhcpOption']= array();
if (isset ($this->options) && count ($this->options)){
foreach ($this->options as $key => $val){
- $this->attrs['dhcpOption'][]= "$key $val";
+ $this->attrs['dhcpOption'][]= "$val";
}
}
function fix_options()
{
foreach (array('domain-name-servers') as $key){
- unset ($this->options[$key]);
+ $ikey = dhcpAdvanced::getOption($key,$this->options);
+ if($ikey != ""){
+ unset ($this->options[$ikey]);
+ }
}
}