Code

Updated DNS service.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Feb 2008 11:17:12 +0000 (11:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Feb 2008 11:17:12 +0000 (11:17 +0000)
- DNS zones can't be modified anymore, if the are used.

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

gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc
gosa-plugins/dns/admin/systems/services/dns/servdnseditzone.tpl

index 9242662a8edd3d9424f65274a001c8d89a519600..bb7053e70eb6438b6f12a14d1e0c0256bd9bb751 100644 (file)
@@ -44,6 +44,7 @@ class servdnseditZone extends plugin
   var $isNew                    = true;
 
   var $ZoneObject               = array();
+  var $Zone_is_used             = FALSE;
 
   function servdnseditZone (&$config, $dn= NULL,$attrs = array())
   {
@@ -115,6 +116,13 @@ class servdnseditZone extends plugin
       }else{
         $this->sOAserial = date("Ymd")."01";
       }
+
+      /* Check if this used, in this case disable forward and reverse configuration */
+      $tmp = $this->getUsedZoneNames();
+      $this->Zone_is_used = FALSE;
+      if(isset($tmp[DNS::FlipIp($this->InitialReverseZone).".in-addr.arpa"])){
+        $this->Zone_is_used = TRUE;
+      }
     }
 
     /* Detect Network class */
@@ -204,10 +212,9 @@ class servdnseditZone extends plugin
     /* Call parent execute */
     plugin::execute();
 
-
-
     /* Fill templating stuff */
     $smarty= get_smarty();
+    $smarty->assign("Zone_is_used",$this->Zone_is_used);
     $ui = get_userinfo();
 
     $smarty->assign("ACLs",$this->parent->getacl(""));
@@ -367,6 +374,11 @@ 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];
       }
@@ -381,7 +393,7 @@ class servdnseditZone extends plugin
       }
     }
 
-     if(isset($_POST['NetworkClass'])){
+     if(isset($_POST['NetworkClass']) && !$this->Zone_is_used){
        $this->NetworkClass = $_POST['NetworkClass'];
      }
 
@@ -478,26 +490,22 @@ class servdnseditZone extends plugin
     return ($message);
   }
 
-  /* This funtion returns all used Zonenames */
+
+  /* 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] =DNS::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()
   {
@@ -597,7 +605,8 @@ class servdnseditZone extends plugin
     $str.="</select>";
     return($str);
   }
-}
 
+
+}
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 1136dba537a09e3435f173680e32ce65cf9054ac..60b39101fbaeba766e5230aa248d871bf5f96783 100644 (file)
@@ -4,20 +4,20 @@
                <td style="width:50%;vertical-align:top;border-right:1px        solid   #b0b0b0;">
                        <table summary="">
                                <tr>
-                                       <td>{t}Zone name{/t}{$must}
+                                       <td style='vertical-align:top'>{t}Zone name{/t}{$must}
                                        </td>
                                        <td>
 {render acl=$ACLs}                                     
-                                               <input type="text" name="zoneName" value="{$zoneName}" {if $NotNew} disabled {/if}>
+                                               <input type="text" name="zoneName" value="{$zoneName}" {if $NotNew | $Zone_is_used} disabled {/if}>
 {/render}
                                        </td>
                                </tr>
                                <tr>
-                                       <td>{t}Network address{/t}{$must}
+                                       <td style='vertical-align:top'>{t}Network address{/t}{$must}
                                        </td>
                                        <td>
 {render acl=$ACLs}                                     
-                                               <input type="text" name="ReverseZone" value="{$ReverseZone}" {if $NotNew} disabled {/if}>
+                                               <input type="text" name="ReverseZone" value="{$ReverseZone}" {if $NotNew | $Zone_is_used} disabled {/if}>
 {/render}
                                        </td>
                                </tr>
                                        </td>
                                        <td>
 {render acl=$ACLs}                                     
-                                               <select name="NetworkClass" {if $NotNew} disabled {/if}>
+                                               <select name="dummy3" {if $NotNew | $Zone_is_used} disabled {/if}>
                                                        {html_options options=$NetworkClasses selected=$NetworkClass }
                                                </select>
 {/render}
                                        </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;">