Code

Updated dhcp client side.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 10 Aug 2007 13:44:04 +0000 (13:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 10 Aug 2007 13:44:04 +0000 (13:44 +0000)
IP address and hostname will be inherited from parent object.
Input fields are grey out

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

plugins/admin/systems/class_dhcpHost.inc
plugins/admin/systems/class_termDNS.inc
plugins/admin/systems/dhcp_host.tpl

index 36d833176cbae363b5a7a4d32d78062c47b78806..2bca1bba783fb3215aefb9f5614701cfd90b199e 100644 (file)
@@ -22,11 +22,12 @@ class dhcpHost extends dhcpPlugin
 {
   /* Used attributes */
   var $dhcpHWAddress= "";
-
+  var $realGosaHost = FALSE;
+       
   /* attribute list for save action */
   var $objectclasses= array("top", "dhcpHost");
 
-  function dhcpHost($attrs)
+  function dhcpHost($attrs,$host_exists_in_gosa = FALSE)
   {
     dhcpPlugin::dhcpPlugin($attrs);
 
@@ -37,6 +38,8 @@ class dhcpHost extends dhcpPlugin
 
     $this->advanced->setAutoOptions(array("host-name"));
     $this->advanced->setAutoStatements(array("fixed-address"));
+
+       $this->realGosaHost = $host_exists_in_gosa;
   }
 
   function execute()
@@ -44,6 +47,7 @@ class dhcpHost extends dhcpPlugin
     $smarty= get_smarty();
     $smarty->assign("cn", $this->cn);
     $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
+    $smarty->assign("realGosaHost",$this->realGosaHost);
 
     /* Create fixed address */
     if (isset($this->statements['fixed-address'])){
@@ -96,10 +100,13 @@ class dhcpHost extends dhcpPlugin
 
       /* Assemble hwAddress */
       $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
-      $this->cn= validate(get_post('cn'));
+               
+      if(!$this->realGosaHost){
+        $this->cn= validate(get_post('cn'));
+      }
 
       /* Save fixed address */
-      if ($_POST['fixedaddr'] != ""){
+      if (!$this->realGosaHost && $_POST['fixedaddr'] != ""){
         $this->statements['fixed-address']= get_post('fixedaddr');
       } else {
         unset ($this->statements['fixed-address']);
index 6c25b978a5b0be4128fbc82eb694ae62876dd122..8ee236d184b347ceef641e817ca428ea8a133eae 100644 (file)
@@ -205,11 +205,14 @@ class termDNS extends plugin
     if(isset($_POST['dhcpEditOptions'])){
 
       if(count($this->dhcpHostEntry) == 0){
-        $this->dialog = new dhcpHost($this->dhcpParentNode);
+        $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
       }else{
-        $this->dialog = new dhcpHost($this->dhcpHostEntry);
+        $this->dialog = new dhcpHost($this->dhcpHostEntry,TRUE);
+      }
+      $this->dialog->cn = $this->cn; 
+      if(!empty($this->ipHostNumber)){
+        $this->dialog->statements['fixed-address'] = $this->ipHostNumber; 
       }
-    
     }
 
     if(isset($_POST['cancel_dhcp'])){
@@ -559,6 +562,7 @@ class termDNS extends plugin
         if($this->initial_dhcpParentNode != $this->dhcpParentNode){
           $attrs = $this->dhcpHostEntry;
           unset($attrs['dn']);
+          unset($attrs['MODIFIED']);
           $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode);
           $res = $ldap->add($attrs);
           show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed."));
index 31c271738d2f205c9ebf68eb94251ec907031af6..1c8d4d634631bbf8faf38d6b3b35677a67d86a46 100644 (file)
@@ -7,14 +7,15 @@
     <tr>
      <td>{t}Name{/t}{$must}</td>
      <td>
-      <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
+      <input {if $realGosaHost} disabled {/if} id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
              title='{t}Name of host{/t}'>
      </td>
     </tr>
     <tr>
      <td>{t}Fixed address{/t}</td>
      <td>
-      <input type='text' name='fixedaddr' size='25' maxlength='80' value='{$fixedaddr}'
+      <input {if $realGosaHost} disabled {/if} 
+                       type='text' name='fixedaddr' size='25' maxlength='80' value='{$fixedaddr}'
              title='{t}Use hostname or IP-address to assign fixed address{/t}'>
      </td>
     </tr>