Code

Updated for dhcpPlugin
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Aug 2007 15:57:38 +0000 (15:57 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Aug 2007 15:57:38 +0000 (15:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7008 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_dhcpSharedNetwork.inc
plugins/admin/systems/class_dhcpSubnet.inc

index 3e82b815a373ed41d35e3445de25f31c192be10c..30a800cca063eef6d96678fa1aa9fdd2ae4b3f0e 100644 (file)
 
 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)
index 3734e2d4edeba30bc77d51df27a1d6b25d574a9b..098b01ee2942e3c079bd05fc8d6de2d68b9bbeda 100644 (file)
   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);
   }