Code

Updated network class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 10 Apr 2008 09:15:45 +0000 (09:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 10 Apr 2008 09:15:45 +0000 (09:15 +0000)
-Allow saving of multiple IP addresses

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

gosa-plugins/systems/admin/systems/class_termDNS.inc
gosa-plugins/systems/admin/systems/network.tpl

index f40e6d5d2f9892c5536b9442d4d641e33d3cbaf0..8a9d47998eb06fc38bf15739273483a5ccee8539 100644 (file)
@@ -84,7 +84,8 @@ class termDNS extends plugin
       $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]);
     }
 
-
+    /* Create list of additional ipHostNumber.
+     */
     $this->additionalHostNumbers = array();
     if(isset($this->attrs['ipHostNumber']) && $this->attrs['ipHostNumber']['count'] > 1){
       for($i = 1 ; $i < $this->attrs['ipHostNumber']['count']; $i ++){
@@ -251,21 +252,45 @@ class termDNS extends plugin
 
     $display= "";
 
+    /**********
+     * Additional ipHostNumber handling 
+     **********/
+      
+    /* Add a new one */
+    if(isset($_POST['additionalHostNumbers_add'])){
+      if(!is_array($this->additionalHostNumbers)){
+        $this->additionalHostNumbers=array();
+      }
+      $this->additionalHostNumbers[] = "";
+    }
+
+    /* Delete given entry */
+    foreach($this->additionalHostNumbers as $id => $value){
+      if(isset($_POST['additionalHostNumbers_del_'.$id])){
+        unset($this->additionalHostNumbers[$id]);
+        $this->additionalHostNumbers = array_values($this->additionalHostNumbers);
+      }
+    } 
     $smarty->assign("additionalHostNumbers",$this->additionalHostNumbers);
     $smarty->assign("staticAddress", ""); 
  
+    /**********
+     * Autonet completion
+     **********/
     /* Check for autonet button */
     if (isset($_POST['autonet'])){
-       $d= new gosaSupportDaemon(TRUE, 0.5);
-        $res= $d->_send("<xml><header>gosa_network_completition</header><source>GOSA</source><target>GOSA</target><hostname>".$this->cn."</hostname></xml>", TRUE);
-       if (isset($res['XML']['IP'])){
-               $this->ipHostNumber= $res['XML']['IP'];
-       }
-       if (isset($res['XML']['MAC'])){
-               $this->macAddress= $res['XML']['MAC'];
-       }
+      $d= new gosaSupportDaemon(TRUE, 0.5);
+      $res= $d->_send("<xml><header>gosa_network_completition</header><source>GOSA</source><target>GOSA</target><hostname>".$this->cn."</hostname></xml>", TRUE);
+      if (isset($res['XML']['IP'])){
+        $this->ipHostNumber= $res['XML']['IP'];
+      }
+      if (isset($res['XML']['MAC'])){
+        $this->macAddress= $res['XML']['MAC'];
+      }
     }
-    
+
   
     /**********
      * DHCP Handling
@@ -452,7 +477,22 @@ class termDNS extends plugin
       /* Save all posted vars */
       plugin::save_object();
 
-      /* Handle DHCP Posts*/
+      /******
+        Additional IP Host Numbers 
+       ******/
+  
+      /* Get posts for all additionally added ipHostNumbers */
+      foreach($this->additionalHostNumbers as $id => $value){
+        if(isset($_POST['additionalHostNumbers_'.$id])){
+          $this->additionalHostNumbers[$id] = get_post('additionalHostNumbers_'.$id);
+        }
+      } 
+
+
+      /******
+        DHCP posts
+       ******/
+
       if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){
         foreach($this->dhcpAttributes as $attr){
           if(isset($_POST[$attr])){
@@ -473,6 +513,11 @@ class termDNS extends plugin
         }
       }
 
+
+      /******
+        DNS posts
+       ******/
+
       /* Check if DNS should be enabled / disabled */
       if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){
         $this->DNS_is_account = false;
@@ -519,6 +564,17 @@ class termDNS extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
+    /******
+      check additional IP Host Numbers 
+     ******/
+
+    foreach($this->additionalHostNumbers as $id => $value){
+      if(!tests::is_ip($value)){
+        $message[]= msgPool::invalid(sprintf(_("IP address #%s"),($id +2)), "", "", "192.168.1.10");
+      }
+    }
+
+
     /* Check if mac and ip are already used */
     if(!empty($this->ipHostNumber) && $this->DNS_is_account && 
         $this->ipHostNumber != $this->orig_ipHostNumber && 
@@ -628,6 +684,13 @@ class termDNS extends plugin
     /* Save DNS setting & ip/Mac*/
     plugin::save();
 
+    /* Add all additional ipHostNumbers now 
+     */
+    $this->attrs['ipHostNumber'] = array($this->ipHostNumber);
+    foreach($this->additionalHostNumbers as $value){
+      $this->attrs['ipHostNumber'][] = $value;
+    }
+
     /* Write back to ldap */
     $ldap->cd($this->dn);
     $this->cleanup();
index 6132c8a8f1fa746faca96700bdcf64b6eca29c50..f1f309dc076921399e4e201fa472462d032cbe6d 100644 (file)
@@ -6,15 +6,17 @@
                <td     style="width:50%; vertical-align: top;">
                        <table  summary="">
                                <tr>
-                                       <td><LABEL      for="ipHostNumber">{t}IP-address{/t}{if $IPisMust}{$staticAddress}{/if}</LABEL></td>
+                                       <td style='vertical-align:top;'><LABEL  for="ipHostNumber">{t}IP-address{/t}{if $IPisMust}{$staticAddress}{/if}</LABEL></td>
                                        <td>
 {render acl=$ipHostNumberACL}
             <input     id="ipHostNumber"       name="ipHostNumber"     size=25 maxlength=80    value="{$ipHostNumber}">
 {/render}
-
           {foreach from=$additionalHostNumbers item=item key=key}
-            <br>{$item}
+            <br>
+            <input size=25 maxlength=80 type='text' name='additionalHostNumbers_{$key}' value='{$item}'>
+            <input type='submit' name='additionalHostNumbers_del_{$key}' value='{msgPool type=delButton}'>
           {/foreach}
+          <input type='submit' name='additionalHostNumbers_add' value='{msgPool type=addButton}'>
 
 {render acl=$ipHostNumberACL}
 {if $DNS_is_account == true}