Code

Update DNS service
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Feb 2008 12:18:59 +0000 (12:18 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Feb 2008 12:18:59 +0000 (12:18 +0000)
-Disable network settings if zone is in use.

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

plugins/admin/systems/class_servDNSeditZone.inc
plugins/admin/systems/servdnseditzone.tpl

index 0b9850e0bd423e70d58527e06c7c8faa9f989e81..8dd76dc05c329e8807c610bed21ea19579557592 100644 (file)
@@ -39,6 +39,7 @@ class servdnseditZone extends plugin
   var $isNew                    = true;
   var $cn;
   var $ZoneObject               = array();
+  var $Zone_is_used             = FALSE;
 
   function servdnseditZone ($config, $dn= NULL,$attrs = array())
   {
@@ -129,6 +130,13 @@ class servdnseditZone extends plugin
         $this->ReverseZone .= ".0"; 
       }
     }
+
+    /* Check if this used, in this case disable forward and reverse configuration */
+    $tmp = $this->getUsedZoneNames();
+    $this->Zone_is_used = FALSE;
+    if(isset($tmp[FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"])){
+      $this->Zone_is_used = TRUE;
+    }
   }
 
   /* TRansports the geiven Arraykey one position up*/
@@ -204,6 +212,7 @@ class servdnseditZone extends plugin
 
     /* Fill templating stuff */
     $smarty= get_smarty();
+    $smarty->assign("Zone_is_used",$this->Zone_is_used);
     $display= "";
 
     /* Open Zone Entry Edit Dialog
@@ -368,12 +377,16 @@ class servdnseditZone extends plugin
   {
     //plugin::save_object();
     foreach($this->attributes as $attr){
+      if($this->Zone_is_used && in_array($attr,array("ReverseZone","zoneName"))){
+        continue;
+      }
+
       if(isset($_POST[$attr])){
         $this->$attr = $_POST[$attr];
       }
     }
 
-    if(isset($_POST['NetworkClass'])){
+    if(isset($_POST['NetworkClass']) && !$this->Zone_is_used){
       $this->NetworkClass = $_POST['NetworkClass'];
     }
 
@@ -484,26 +497,21 @@ class servdnseditZone extends plugin
     return ($message);
   }
 
+
   /* This funtion returns all used Zonenames */
   function getUsedZoneNames()
   {
     $ret = array();
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",array("zoneName","tXTRecord"));
+    $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName"));
     while($attr = $ldap->fetch()){
-      if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){
-        if(isset($attr['tXTRecord'][0])){
-          $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]);
-          $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]));
-        }
-      }else{
-        $ret[$attr['zoneName'][0]]="";
-      }
+      $ret[$attr['zoneName'][0]][] = $attr['dn'];
     }
     return($ret);
   }
 
+
   /* Save to LDAP */
   function save()
   {
index 2e7c969be9d9c276ad97d0dbc365c66ed9e4d919..016eba51d7b4352d7223fc5019c3b7707c1dab8c 100644 (file)
@@ -6,24 +6,31 @@
                                <tr>
                                        <td>{t}Zone name{/t}{$must}
                                        </td>
-                                       <td><input type="text" name="zoneName" value="{$zoneName}" {if $NotNew} disabled {/if}>
+                                       <td><input type="text" name="zoneName" value="{$zoneName}" {if $NotNew | $Zone_is_used} disabled {/if}>
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}Network address{/t}{$must}
                                        </td>
-                                       <td><input type="text" name="ReverseZone" value="{$ReverseZone}" {if $NotNew} disabled {/if}>
+                                       <td><input type="text" name="ReverseZone" value="{$ReverseZone}" {if $NotNew | $Zone_is_used} disabled {/if}>
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}Netmask{/t}
                                        </td>
                                        <td>
-                                               <select name="NetworkClass" {if $NotNew} disabled {/if}>
+                                               <select name="NetworkClass" {if $NotNew | $Zone_is_used} disabled {/if}>
                                                        {html_options options=$NetworkClasses selected=$NetworkClass }
                                                </select>
                                        </td>
                                </tr>
+                               {if $Zone_is_used}
+                               <tr>
+                                  <td colspan="2">
+                                          <i>{t}Zone is in use, network settings can't be modified.{/t}</i>
+                                  </td>
+                               </tr>
+                               {/if}
                        </table>
                </td>
                <td style="vertical-align:top;">