X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNS.inc;h=f12ad0f8bcc77f0de704d79532a6409e11fbbd93;hb=868f556da0e7c0003fb3ae735559e6500e5bc3ed;hp=f2864d790c5eefa317cd4d84e10dc84313185b0d;hpb=9661305ec872b58877cee3ac6b772134dcf7282c;p=gosa.git diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index f2864d790..f12ad0f8b 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -2,11 +2,6 @@ class servdns extends plugin { - /* CLI vars */ - var $cli_summary= "Manage server basic objects"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - /* attribute list for save action */ var $ignore_account = FALSE; var $attributes = array(); @@ -21,9 +16,9 @@ class servdns extends plugin var $DNSinitially_was_account; - function servdns ($config, $dn= NULL) + function servdns ($config, $dn= NULL, $parent= NULL) { - plugin::plugin ($config, $dn); + plugin::plugin ($config, $dn, $parent); $this->orig_dn = $dn; @@ -34,7 +29,7 @@ class servdns extends plugin /* Get all zone Informations */ $this->Zones = getDNSZoneEntries($config,$dn); - + /* If there is at least one entry in this -> types, we have DNS enabled */ if(count($this->Zones) == 0){ @@ -60,7 +55,15 @@ class servdns extends plugin /* Do we need to flip is_account state? */ if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; + + /* Only change account state if allowed */ + if($this->is_account && $this->acl == "#all#"){ + $this->is_account= !$this->is_account; + $this->is_modified = true; + }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){ + $this->is_account= !$this->is_account; + $this->is_modified = true; + } } if ($this->is_account){ @@ -75,7 +78,7 @@ class servdns extends plugin /* Edited or Added zone */ - if(isset($_POST['SaveZoneChanges'])){ + if((isset($_POST['SaveZoneChanges'])) && is_object($this->dialog)){ $this->dialog->save_object(); /* Check for errors @@ -104,7 +107,7 @@ class servdns extends plugin /* Add empty new zone */ - if(isset($_POST['AddZone'])){ + if(isset($_POST['AddZone']) && chkacl($this->acl,"servdns") == ""){ $this->dialog = new servdnseditZone($this->config,$this->dn); } @@ -115,7 +118,7 @@ class servdns extends plugin /* check all post for edit request */ - if(preg_match("/^editZone_/",$name)&&!$once){ + if(preg_match("/^editZone_/",$name)&&!$once && chkacl($this->acl,"servdns") == ""){ $once =true; $tmp = preg_replace("/^editZone_/","",$name); $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); @@ -124,7 +127,7 @@ class servdns extends plugin /* check posts for delete zone */ - if(preg_match("/^delZone_/",$name)&&!$once){ + if(preg_match("/^delZone_/",$name)&&!$once && chkacl($this->acl,"servdns") == ""){ $once =true; $tmp = preg_replace("/^delZone_/","",$name); @@ -147,7 +150,7 @@ class servdns extends plugin /* Create Listbox with existing Zones */ $ZoneList = new divSelectBox("dNSZones"); - $ZoneList -> SetHeight(254); + $ZoneList -> SetHeight(300); /* Add entries to divlist */ @@ -155,14 +158,16 @@ class servdns extends plugin "; foreach($this->Zones as $zone => $values ){ $ZoneList->AddEntry(array( - array("string" => $zone), - array("string" => _("Reverse zone")." : ".$values['ReverseZone']), + array("string" => getNameFromMix($zone)), + array("string" => _("Reverse zone")." : ".getNameFromMix($values['ReverseZone'])), array("string" => _("TTL")." : ".$values['sOAttl']), array("string" => _("Class")." : ".$values['dNSClass']), - array("string" =>str_replace("%s",base64_encode($zone),$editImg)) + array("string" => str_replace("%s",base64_encode($zone),$editImg)) )); } - + + $smarty->assign("servdnsACL",chkacl($this->acl,"servdns")); + /* Display tempalte */ $smarty->assign("ZoneList",$ZoneList->DrawList()); @@ -176,16 +181,17 @@ class servdns extends plugin function RemoveZone($id) { $zones = $this->getUsedZoneNames(); - + $rev =""; + if(isset($this->Zones[$id]['InitialReverseZone'])){ - $rev = FlipIp($this->Zones[$id]['InitialReverseZone']); - }else{ - $rev = FlipIp($this->Zones[$id]['ReverseZone']); + $rev = FlipIp(getNameFromMix($this->Zones[$id]['InitialReverseZone'])); + }elseif(isset($this->Zones[$id]['ReverseZone'])){ + $rev = FlipIp(getNameFromMix($this->Zones[$id]['ReverseZone'])); } $zonename = ""; if(isset($this->Zones[$id]['InitialzoneName'])){ - $zonename= $this->Zones[$id]['InitialzoneName']; + $zonename= getNameFromMix($this->Zones[$id]['InitialzoneName']); } $used = array(); @@ -224,7 +230,9 @@ class servdns extends plugin }else{ unset($this->Zones[$id]); + return(true); } + return(false); } @@ -243,25 +251,26 @@ class servdns extends plugin } - /* Remove dns service + + /* Remove dns service */ function remove_from_parent() { - if(!$this->DNSinitially_was_account){ - return; - } - print_red("Can't remove dns yet. returning without remove."); - return; - $ldap = $this->config->get_ldap_link(); - $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",$this->orig_dn,array("relativeDomainName","zoneName")); - while($attr = $ldap->fetch()){ - $ldap->cd($attr['dn']); - $ldap->rmDir($attr['dn']); + if($this->DNSinitially_was_account){ + $bool = true; + foreach($this->Zones as $key => $zone){ + $bool= $bool & $this->RemoveZone($key); + } + + if($bool){ + $this->save(); + } + return($bool); } - show_ldap_error($ldap->get_error()); } + /* Save to LDAP */ function save() { @@ -270,7 +279,13 @@ class servdns extends plugin /* Get differences */ - $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$this->orig_dn); + + $old_dn = $this->orig_dn; + if($old_dn == "new"){ + $old_dn = $this->dn; + } + + $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); /* Updated zone entries if reverser or forward name has changed * Must be done before moving entries, else the given dn is invalid @@ -279,7 +294,7 @@ class servdns extends plugin foreach($tmp['zoneUpdates'] as $dn => $attrs){ $ldap->cd($dn); $ldap->modify($attrs); - show_ldap_error("Zone:".$ldap->get_error()); + show_ldap_error("Zone:".$ldap->get_error(), _("Updating DNS service failed")); } } @@ -288,7 +303,7 @@ class servdns extends plugin foreach($tmp['del'] as $dn => $del){ $ldap->cd($dn); $ldap->rmdir_recursive($dn); - show_ldap_error("Zone:".$ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Removing DNS entries failed")); } /* move follwoing entries @@ -309,6 +324,7 @@ class servdns extends plugin $ldap->cd($dn); $ldap->add($attrs); } + show_ldap_error($ldap->get_error(), _("Saving DNS entries failed")); } } }