From 55ab5e663ad6ec7b6e9deb4769e761987bbcc4a1 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 10 Apr 2008 09:15:45 +0000 Subject: [PATCH] Updated network class -Allow saving of multiple IP addresses git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10313 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/admin/systems/class_termDNS.inc | 85 ++++++++++++++++--- .../systems/admin/systems/network.tpl | 8 +- 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/gosa-plugins/systems/admin/systems/class_termDNS.inc b/gosa-plugins/systems/admin/systems/class_termDNS.inc index f40e6d5d2..8a9d47998 100644 --- a/gosa-plugins/systems/admin/systems/class_termDNS.inc +++ b/gosa-plugins/systems/admin/systems/class_termDNS.inc @@ -84,7 +84,8 @@ class termDNS extends plugin $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); } - + /* Create list of additional ipHostNumber. + */ $this->additionalHostNumbers = array(); if(isset($this->attrs['ipHostNumber']) && $this->attrs['ipHostNumber']['count'] > 1){ for($i = 1 ; $i < $this->attrs['ipHostNumber']['count']; $i ++){ @@ -251,21 +252,45 @@ class termDNS extends plugin $display= ""; + /********** + * Additional ipHostNumber handling + **********/ + + /* Add a new one */ + if(isset($_POST['additionalHostNumbers_add'])){ + if(!is_array($this->additionalHostNumbers)){ + $this->additionalHostNumbers=array(); + } + $this->additionalHostNumbers[] = ""; + } + + /* Delete given entry */ + foreach($this->additionalHostNumbers as $id => $value){ + if(isset($_POST['additionalHostNumbers_del_'.$id])){ + unset($this->additionalHostNumbers[$id]); + $this->additionalHostNumbers = array_values($this->additionalHostNumbers); + } + } + $smarty->assign("additionalHostNumbers",$this->additionalHostNumbers); $smarty->assign("staticAddress", ""); + /********** + * Autonet completion + **********/ + /* Check for autonet button */ if (isset($_POST['autonet'])){ - $d= new gosaSupportDaemon(TRUE, 0.5); - $res= $d->_send("
gosa_network_completition
GOSAGOSA".$this->cn."
", TRUE); - if (isset($res['XML']['IP'])){ - $this->ipHostNumber= $res['XML']['IP']; - } - if (isset($res['XML']['MAC'])){ - $this->macAddress= $res['XML']['MAC']; - } + $d= new gosaSupportDaemon(TRUE, 0.5); + $res= $d->_send("
gosa_network_completition
GOSAGOSA".$this->cn."
", TRUE); + if (isset($res['XML']['IP'])){ + $this->ipHostNumber= $res['XML']['IP']; + } + if (isset($res['XML']['MAC'])){ + $this->macAddress= $res['XML']['MAC']; + } } - + /********** * DHCP Handling @@ -452,7 +477,22 @@ class termDNS extends plugin /* Save all posted vars */ plugin::save_object(); - /* Handle DHCP Posts*/ + /****** + Additional IP Host Numbers + ******/ + + /* Get posts for all additionally added ipHostNumbers */ + foreach($this->additionalHostNumbers as $id => $value){ + if(isset($_POST['additionalHostNumbers_'.$id])){ + $this->additionalHostNumbers[$id] = get_post('additionalHostNumbers_'.$id); + } + } + + + /****** + DHCP posts + ******/ + if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){ foreach($this->dhcpAttributes as $attr){ if(isset($_POST[$attr])){ @@ -473,6 +513,11 @@ class termDNS extends plugin } } + + /****** + DNS posts + ******/ + /* Check if DNS should be enabled / disabled */ if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){ $this->DNS_is_account = false; @@ -519,6 +564,17 @@ class termDNS extends plugin /* Call common method to give check the hook */ $message= plugin::check(); + /****** + check additional IP Host Numbers + ******/ + + foreach($this->additionalHostNumbers as $id => $value){ + if(!tests::is_ip($value)){ + $message[]= msgPool::invalid(sprintf(_("IP address #%s"),($id +2)), "", "", "192.168.1.10"); + } + } + + /* Check if mac and ip are already used */ if(!empty($this->ipHostNumber) && $this->DNS_is_account && $this->ipHostNumber != $this->orig_ipHostNumber && @@ -628,6 +684,13 @@ class termDNS extends plugin /* Save DNS setting & ip/Mac*/ plugin::save(); + /* Add all additional ipHostNumbers now + */ + $this->attrs['ipHostNumber'] = array($this->ipHostNumber); + foreach($this->additionalHostNumbers as $value){ + $this->attrs['ipHostNumber'][] = $value; + } + /* Write back to ldap */ $ldap->cd($this->dn); $this->cleanup(); diff --git a/gosa-plugins/systems/admin/systems/network.tpl b/gosa-plugins/systems/admin/systems/network.tpl index 6132c8a8f..f1f309dc0 100644 --- a/gosa-plugins/systems/admin/systems/network.tpl +++ b/gosa-plugins/systems/admin/systems/network.tpl @@ -6,15 +6,17 @@ - +
{render acl=$ipHostNumberACL} {/render} - {foreach from=$additionalHostNumbers item=item key=key} -
{$item} +
+ + {/foreach} + {render acl=$ipHostNumberACL} {if $DNS_is_account == true} -- 2.30.2