Code

Updated dhcp service.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Sep 2007 07:49:47 +0000 (07:49 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Sep 2007 07:49:47 +0000 (07:49 +0000)
Don't save dhcpOption: server-name for service base object (cn=dhcp,cn=server...).
Save this attribute to all child objects instead. (host,group,subnet,sharedNetwork).

Fixed saving for newly created savers with dhcp service,
some attributes were not available while editing an entry like cn and dn.
This caused PHP Warnings and empty server-name options

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7396 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_dhcpService.inc
plugins/admin/systems/class_servDHCP.inc

index b3d7e0b0bc8624f3573c1b2cf7ba651650d58d31..57f76cc9e19f43440605f282931cfdac49ec679c 100644 (file)
@@ -171,7 +171,7 @@ class dhcpService extends dhcpPlugin
 
     $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
     $this->removeOption('server-name');
-    $this->attrs['dhcpOption'][]= "server-name $server_name";
+#    $this->attrs['dhcpOption'][]= "server-name $server_name";
 
     return ($this->attrs);
   }
index d883bf4ae9173537b704eee070159493f9c8463d..d5048eea961bacb80e0c970045de34b6750af808 100644 (file)
@@ -462,6 +462,27 @@ class servdhcp extends plugin
         continue;
       }
 
+      /* Opdate dhcp option 'server-name' to actual server name */
+      if($this->dn != $this->orig_dn){
+        $fixed = FALSE;
+        foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
+          if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
+            foreach($data['dhcpOption'] as $key => $option){
+              if(preg_match("/^server-name /",$option)){
+                $data['dhcpOption'][$key] = "server-name ".$this->cn;
+                $data['MODIFIED'] = TRUE; 
+                break;
+              }
+            }
+          }
+
+          /* Skip next loops if entry is updated */
+          if($fixed){
+            break;
+          }
+        }
+      }
+
       /* Modify existing entry? */
       if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){