Code

Fixed wrong existance check
[gosa.git] / gosa-plugins / systems / admin / systems / class_termDNS.inc
index d904a976f6de9531558b4b53283037a894eccbfe..e336feb26d3a41f1d1dea274113d832a83b58b72 100644 (file)
@@ -79,7 +79,9 @@ class termDNS extends plugin
     $this->IPisMust       = $IPisMust;
     $this->namingAttr     = $namingAttr;
 
-    plugin::plugin ($config, $parent->dn);
+    plugin::plugin ($config, $parent->dn, $this->parent);
+  
+    $this->attrs = &$this->parent->attrs;
 
     if(isset($this->attrs[$namingAttr][0])){
       $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs[$namingAttr][0]);
@@ -332,7 +334,7 @@ class termDNS extends plugin
       $this->dialog = FALSE; 
     }
 
-    if(isset($_POST['save_dhcp']) && $this->acl_is_writeable("dhcpSetup")){
+    if(isset($_POST['save_dhcp']) && $this->acl_is_writeable("dhcpSetup") && is_object($this->dialog)){
       $this->dialog->save_object();
       $msgs = $this->dialog->check(array());
       if(count($msgs)){
@@ -541,11 +543,15 @@ class termDNS extends plugin
         DNS posts
        ******/
 
-      /* Check if DNS should be enabled / disabled */
-      if($this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && !isset($_POST['DNS_is_account'])){
-        $this->DNS_is_account = false;
-      }elseif(!$this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && isset($_POST['DNS_is_account'])){
-        $this->DNS_is_account = true;
+      /* Check if DNS should be enabled / disabled 
+       *  -skip this, if the dns account is enforced.
+       */
+      if(!$this->hide_dns_check_box){
+        if($this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && !isset($_POST['DNS_is_account'])){
+          $this->DNS_is_account = false;
+        }elseif(!$this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && isset($_POST['DNS_is_account'])){
+          $this->DNS_is_account = true;
+        }
       }
 
       /* Get dns attributes */
@@ -715,7 +721,7 @@ class termDNS extends plugin
     }
 
     /* Do not add the objectClass ipHost if no ip address is given */
-    if(!$this->attrs['ipHostNumber']){
+    if(!isset($this->attrs['ipHostNumber'])){
       $this->attrs['objectClass'] = array_remove_entries(array("ipHost"),$this->attrs['objectClass']);
     }
 
@@ -1117,9 +1123,11 @@ class termDNS extends plugin
       "(objectClass=gotoPrinter)".
       "(objectClass=ipHost)";
     $list = array();
-    $ldap->search("(&(|{$ocs})(ipHostNumber={$net}*))",array("ipHostNumber"));
+    $ldap->search("(&(|{$ocs})(ipHostNumber=*))",array("ipHostNumber"));
     while($attrs = $ldap->fetch()){
-      $list[] = $attrs['ipHostNumber'][0];
+      if (preg_match("/^$net\./", $attrs['ipHostNumber'][0])) {
+        $list[] = $attrs['ipHostNumber'][0];
+      }
     }
 
     // Set starting ip.