"Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ var $ignore_account= TRUE; var $attributes = array("zoneName","ReverseZone","dNSTTL","dNSClass", "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); var $objectclasses = array("whatever"); var $RecordTypes = array(); var $ReverseZone = ""; var $ReverseDN = ""; var $zoneName = ""; var $dNSTTL = "7200"; var $dNSClass = "IN"; var $status = "new"; var $sOAprimary = ""; var $sOAmail = ""; var $sOAserial = ""; var $sOArefresh = "3600"; var $sOAretry = "1800"; var $sOAexpire = ""; var $sOAttl = "6400"; var $Records = array(); var $InitiallyZoneName = ""; var $isNew = true; function servdnseditZone ($config, $dn= NULL,$recordtypes,$attrs = array()) { plugin::plugin ($config, $dn); /* All types with required attrs */ $this->RecordTypes = $recordtypes; if(!count($attrs)){ $this->InitiallyZoneName = ""; $this->isNew = true; }else{ $this->InitiallyZoneName = $attrs['zoneName']; $this->isNew = false; foreach($this->attributes as $value){ $this->$value = $attrs[$value]; } $this->Records = $attrs['Records']; } } function execute() { /* Call parent execute */ plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); $display= ""; /* Handle Post events */ $once = true; foreach($_POST as $name => $value){ /* Delete record if requested */ if((preg_match("/RemoveRecord_/",$name))&&($once)){ $once = false; $id= preg_replace("/RemoveRecord_/","",$name); if($this->Records[$id]['status']!= "new"){ $this->Records[$id]['status']= "deleted"; }else{ unset($this->Records[$id]); } } } /* Add new Zonerecord */ if(isset($_POST['AddNewRecord'])){ $this->Records[] = array("type"=>"aRecord","inittype"=>"","value"=>"","status"=>"new"); } /* Fill in values */ foreach($this->attributes as $name){ $smarty->assign($name,$this->$name); } /* Assign records list */ $smarty->assign("records",$this->generateRecordsList()); /* Display tempalte */ $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE)); return($display); } function remove_from_parent() { } /* Save data to object */ function save_object() { //plugin::save_object(); foreach($this->attributes as $attr){ if(isset($_POST[$attr])){ $this->$attr = $_POST[$attr]; } } foreach($this->Records as $id => $value){ if(isset($_POST['RecordTypeSelectedFor_'.$id])){ $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id]; } if(isset($_POST['RecordValue_'.$id])){ $this->Records[$id]['value'] = $_POST['RecordValue_'.$id]; } } } /* Check supplied data */ function check() { $message= array(); /* Check if zoneName is already in use */ $usedZones = $this->getUsedZoneNames(); if(($this->isNew == true)||($this->zoneName != $this->InitiallyZoneName)){ if(isset($usedZones[$this->zoneName])){ $message[] =_("This zoneName is already in use"); } if(in_array($this->ReverseZone,$usedZones)){ $message[] =_("This reverse zone is already in use"); } } return ($message); } 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")); while($attr = $ldap->fetch()){ if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); $ret[$zn] = preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]); }else{ $ret[$attr['zoneName'][0]]=""; } } return($ret); } /* Save to LDAP */ function save() { $ret =array(); foreach($this->attributes as $name){ $ret[$name] = $this->$name; } $ret['Records'] = $this->Records; return($ret); } function generateRecordsList($changeStateForRecords="") { $changeStateForRecords = ""; $str = ""; foreach($this->Records as $key => $entry){ if($entry['status'] == "deleted") continue; $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; $str.=" ". " ". " ". " ". ""; } $str.= " ". " ". " ". "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". " ". "
"; return($str); } function generateRecordListBox($selected,$name) { $str = ""; return($str); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>