index 2a27325ddfbe8db08f79cd97a098851fa0d94549..f12ad0f8bcc77f0de704d79532a6409e11fbbd93 100644 (file)
class servdns extends plugin
{
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();
/* attribute list for save action */
var $ignore_account = FALSE;
var $attributes = array();
/* Get all zone Informations
*/
$this->Zones = getDNSZoneEntries($config,$dn);
/* 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){
/* If there is at least one entry in this -> types, we have DNS enabled
*/
if(count($this->Zones) == 0){
/* Edited or Added zone
*/
/* Edited or Added zone
*/
- if(isset($_POST['SaveZoneChanges'])){
+ if((isset($_POST['SaveZoneChanges'])) && is_object($this->dialog)){
$this->dialog->save_object();
/* Check for errors
$this->dialog->save_object();
/* Check for errors
/* Create Listbox with existing Zones
*/
$ZoneList = new divSelectBox("dNSZones");
/* Create Listbox with existing Zones
*/
$ZoneList = new divSelectBox("dNSZones");
- $ZoneList -> SetHeight(254);
+ $ZoneList -> SetHeight(300);
/* Add entries to divlist
*/
/* Add entries to divlist
*/
<input type='image' src='images/edittrash.png' name='delZone_%s'>";
foreach($this->Zones as $zone => $values ){
$ZoneList->AddEntry(array(
<input type='image' src='images/edittrash.png' name='delZone_%s'>";
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" => _("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))
));
}
));
}
function RemoveZone($id)
{
$zones = $this->getUsedZoneNames();
function RemoveZone($id)
{
$zones = $this->getUsedZoneNames();
-
+ $rev ="";
+
if(isset($this->Zones[$id]['InitialReverseZone'])){
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 = "";
if(isset($this->Zones[$id]['InitialzoneName'])){
- $zonename= $this->Zones[$id]['InitialzoneName'];
+ $zonename= getNameFromMix($this->Zones[$id]['InitialzoneName']);
}
$used = array();
}
$used = array();
}else{
unset($this->Zones[$id]);
}else{
unset($this->Zones[$id]);
+ return(true);
}
}
+ return(false);
}
}
}
}
- /* Remove dns service
+
+ /* Remove dns service
*/
function remove_from_parent()
{
*/
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(), _("Removing DNS service failed"));
}
}
+
/* Save to LDAP */
function save()
{
/* Save to LDAP */
function save()
{
/* Get differences
*/
/* 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
/* Updated zone entries if reverser or forward name has changed
* Must be done before moving entries, else the given dn is invalid