Code

Added dhcpServer class. closes #133, closes #134
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Aug 2007 16:02:56 +0000 (16:02 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Aug 2007 16:02:56 +0000 (16:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7125 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDHCP.inc

index 742ae553962f93849e3d3a44ff277913fd4fc022..3e70a80b96ce79c5b40c2a7ac4c6fe3400c4ad6f 100644 (file)
@@ -3,8 +3,10 @@
 class servdhcp extends plugin
 {
   /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
+  var $attributes= array("dhcpServiceDN");
+  var $objectclasses= array("dhcpServer");
+
+  var $dhcpServiceDN= "";
 
   /* Section storage */
   var $dhcpSections= array();
@@ -279,6 +281,12 @@ class servdhcp extends plugin
 
   function remove_from_parent()
   {
+    /* Cancel if there's nothing to do here */
+    if (!$this->initially_was_account){
+      return;
+    }
+
+    /* Remove subtrees */
     $ldap= $this->config->get_ldap_link();
     foreach ($this->dhcpObjectCache as $dn => $content){
       if ($this->objectType($dn) == 'dhcpService'){
@@ -286,6 +294,22 @@ class servdhcp extends plugin
         show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
       }
     }
+
+    /* Remove from self */
+    $ldap= $this->config->get_ldap_link();
+
+    /* Remove and write to LDAP */
+    plugin::remove_from_parent();
+    
+    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs);
+
+    show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events("remove");
   }
 
 
@@ -361,6 +385,27 @@ class servdhcp extends plugin
         }
       }
     }
+
+    /* Self modify and place service dn entry */
+    $this->dhcpServiceDN= $this->serviceDN;
+    plugin::save();
+    
+    /* Save data to LDAP */
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs);
+
+    show_ldap_error($ldap->get_error(), _("Saving DHCP service failed"));
+
+    /* Optionally execute a command after we're done */
+    if ($this->initially_was_account == $this->is_account){
+      if ($this->is_modified){
+        $this->handle_post_events("modify");
+      }
+    } else {
+      $this->handle_post_events("add");
+    }
   }