Code

Added service base plugin
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Aug 2007 09:55:06 +0000 (09:55 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Aug 2007 09:55:06 +0000 (09:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6998 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index af2dffe3467c59735a90a4f20ab39612d48b68b5..6118e7e5717d5447b2f733311c62dc4ec40fdb13 100644 (file)
@@ -65,7 +65,11 @@ class dhcpService extends plugin
       if (isset($attrs['dhcpStatements'])){
         foreach ($attrs['dhcpStatements'] as $opt){
           $idx= preg_replace('/\s.+$/', '', $opt);
-          $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          if ($idx == $opt){
+            $value= "";
+          } else {
+            $value= preg_replace('/^[^\s]+\s/', '', $opt);
+          }
           $this->statements[$idx]= $value;
         }
       }
@@ -74,11 +78,11 @@ class dhcpService extends plugin
       /* We keep the parent dn here if it's new */
       $this->dn= $attrs;
       $this->new= TRUE;
-      $this->statements['default_lease_time']= 600;
-      $this->statements['max_lease_time']= 1700;
+      $this->statements['default-lease-time']= 600;
+      $this->statements['max-lease-time']= 1700;
       $this->statements['authoritative']= TRUE;
-      $this->statements['get_lease_hostnames']= TRUE;
-      $this->statements['ddns_update_style']= 'none';
+      $this->statements['get-lease-hostnames']= 'on';
+      $this->statements['ddns-update-style']= 'none';
     }
 
     /* Load network module */
@@ -88,7 +92,8 @@ class dhcpService extends plugin
     $this->advanced= new dhcpAdvanced();
     $this->advanced->options= $this->options;
     $this->advanced->statements= $this->statements;
-    $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-name", "get-lease-hostnames", "server-identifier", "ddns-update-style"));
+    $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "get-lease-hostnames", "server-identifier", "ddns-update-style"));
+    $this->advanced->setAutoOptions(array("server-name"));
 
     /* Save for later action */
     $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
@@ -213,10 +218,15 @@ class dhcpService extends plugin
   /* Save to LDAP */
   function save()
   {
+    global $config;
     $this->attrs= array();
-    echo "server-name";
-    echo "server-identifier";
 
+    /* Get and set server name */
+    $ldap= $config->get_ldap_link();
+    $ldap->cat($this->dhcpPrimaryDN, array('cn'));
+    $res= $ldap->fetch();
+    $server_name= $res['cn'][0];
+    
     /* Merge arrays for network and advanced view */
     foreach (array("options", "statements") as $type){
       $tmp= array_merge($this->$type, $this->network->$type, $this->advanced->$type);
@@ -227,7 +237,9 @@ class dhcpService extends plugin
     $this->attrs['dhcpOption']= array();
     if (isset ($this->options) && count ($this->options)){
       foreach ($this->options as $key => $val){
-        $this->attrs['dhcpOption'][]= "$key $val";
+        if ($key != "server-name"){
+          $this->attrs['dhcpOption'][]= "$key $val";
+        }
       }
     }
 
@@ -235,12 +247,20 @@ class dhcpService extends plugin
     $this->attrs['dhcpStatements']= array();
     if (isset ($this->statements) && count ($this->statements)){
       foreach ($this->statements as $key => $val){
-        $this->attrs['dhcpStatements'][]= "$key $val";
+        if ($val != ""){
+          $this->attrs['dhcpStatements'][]= "$key $val";
+        } else {
+          $this->attrs['dhcpStatements'][]= "$key";
+        }
       }
     }
 
+    $this->attrs['dn']= $this->dn;
+    $this->attrs['cn']= array($this->cn);
+    $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
     $this->attrs['objectClass']= array('top', 'dhcpService');
     $this->attrs['MODIFIED']= TRUE;
+    $this->attrs['dhcpOption'][]= "server-name $server_name";
 
     return ($this->attrs);
   }
index c3ee2fbb575025d8c48103a840139b5becc8fe5e..46ab2e4262c21ae8bb06934eca8df8b606aa7b28 100644 (file)
@@ -349,7 +349,7 @@ class servdhcp extends plugin
 
       /* Read all sub entries to place here */
       $ldap->cd($value['dn']);
-      $ldap->search("(|(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
+      $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
       $this->serviceDN= $value['dn'];
 
       while ($attrs= $ldap->fetch()){
index e4581ef283e2e29170ecebe1ee9af6d509d0034c..0f4731395f0ee03bd5fc2b21cbfc33ae4c282db0 100644 (file)
@@ -8,7 +8,7 @@
   <br>
   {t}Dynamic DNS update{/t} 
   <select name='ddns_update_style'  title='{t}Dynamic DNS update style{/t}' size="1">
-       {html_options options=$ddns_styles selected=$ddns_update_style}
+       {html_options values=$ddns_styles output=$ddns_styles selected=$ddns_update_style}
   </select>
   </td>