From: cajus Date: Wed, 8 Aug 2007 15:57:38 +0000 (+0000) Subject: Updated for dhcpPlugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0a60d36a46ed1745e65290bf08c678adf8f829a7;p=gosa.git Updated for dhcpPlugin git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7008 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_dhcpSharedNetwork.inc b/plugins/admin/systems/class_dhcpSharedNetwork.inc index 3e82b815a..30a800cca 100644 --- a/plugins/admin/systems/class_dhcpSharedNetwork.inc +++ b/plugins/admin/systems/class_dhcpSharedNetwork.inc @@ -20,17 +20,7 @@ class dhcpSharedNetwork extends plugin { - /* Used attributes */ - var $cn= ""; - var $options= array(); - var $statements= array(); - - /* Subobjects */ - var $network; - var $advanced; - /* attribute list for save action */ - var $attributes= array(); var $objectclasses= array(); function dhcpSharedNetwork($attrs) diff --git a/plugins/admin/systems/class_dhcpSubnet.inc b/plugins/admin/systems/class_dhcpSubnet.inc index 3734e2d4e..098b01ee2 100644 --- a/plugins/admin/systems/class_dhcpSubnet.inc +++ b/plugins/admin/systems/class_dhcpSubnet.inc @@ -18,35 +18,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class dhcpSubnet extends plugin +class dhcpSubnet extends dhcpPlugin { /* Used attributes */ - var $cn= ""; - var $orig_cn= ""; var $dhcpNetMask= 24; var $dhcpRange= ""; var $range_start= ""; var $range_stop= ""; - var $options= array(); - var $statements= array(); var $use_range= FALSE; - /* Subobjects */ - var $network; - var $advanced; - /* attribute list for save action */ - var $attributes= array(); - var $objectclasses= array(); + var $objectclasses= array('top', 'dhcpSubnet', 'dhcpOptions'); function dhcpSubnet($attrs) { - if (is_array($attrs)){ - $this->dn= $attrs['dn']; - + dhcpPlugin::dhcpPlugin($attrs); + if (!$this->new){ /* Load attributes */ - foreach (array("cn", "dhcpNetMask", "dhcpRange") as $attr){ + foreach (array("dhcpNetMask", "dhcpRange") as $attr){ if (isset($attrs[$attr][0])){ $this->$attr= $attrs[$attr][0]; } @@ -55,41 +45,8 @@ class dhcpSubnet extends plugin $this->use_range= TRUE; list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange); } - - /* Load options */ - if (isset($attrs['dhcpOption'])){ - foreach ($attrs['dhcpOption'] as $opt){ - $idx= preg_replace('/\s.+$/', '', $opt); - $value= preg_replace('/^[^\s]+\s/', '', $opt); - $this->options[$idx]= $value; - } - } - - /* Load statements */ - if (isset($attrs['dhcpStatements'])){ - foreach ($attrs['dhcpStatements'] as $opt){ - $idx= preg_replace('/\s.+$/', '', $opt); - $value= preg_replace('/^[^\s]+\s/', '', $opt); - $this->statements[$idx]= $value; - } - } - - } else { - /* We keep the parent dn here if it's new */ - $this->dn= $attrs; - $this->new= TRUE; } - /* Load network module */ - $this->network= new dhcpNetwork(); - $this->network->options= $this->options; - $this->network->statements= $this->statements; - $this->advanced= new dhcpAdvanced(); - $this->advanced->options= $this->options; - $this->advanced->statements= $this->statements; - - /* Save CN for later reference */ - $this->orig_cn= $this->cn; $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask); } @@ -159,16 +116,7 @@ class dhcpSubnet extends plugin $this->use_range= FALSE; } - /* Save sub-objects */ - $this->network->save_object(); - $this->advanced->save_object(); - - /* Merge arrays for advanced view */ - foreach (array("options", "statements") as $type){ - $tmp= array_merge($this->$type, $this->network->$type); - $this->advanced->$type= $tmp; - } - + dhcpPlugin::save_object(); } @@ -210,46 +158,15 @@ class dhcpSubnet extends plugin /* Save to LDAP */ function save() { - /* 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; - } - - /* Add cn if we're new */ - if ($this->new){ - $this->dn= "cn=".$this->cn.",".$this->dn; - } else { - $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn); - } - - /* Assemble new entry - options */ - $this->attrs['dhcpOption']= array(); - if (isset ($this->options) && count ($this->options)){ - foreach ($this->options as $key => $val){ - $this->attrs['dhcpOption'][]= "$key $val"; - } - } - - /* Assemble new entry - statements */ - $this->attrs['dhcpStatements']= array(); - if (isset ($this->statements) && count ($this->statements)){ - foreach ($this->statements as $key => $val){ - $this->attrs['dhcpStatements'][]= "$key $val"; - } - } + dhcpPlugin::save(); /* Move dn to the result */ - $this->attrs['dn']= $this->dn; - $this->attrs['cn']= array($this->cn); $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask)); if ($this->dhcpRange != ""){ $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop); } else { $this->attrs['dhcpRange']= array(); } - $this->attrs['objectClass']= array('top', 'dhcpSubnet', 'dhcpOptions'); - $this->attrs['MODIFIED']= TRUE; return ($this->attrs); }