X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZoneEntries.inc;h=3a13bde7dbfac17fc1f0b18238cb336979970ad1;hb=7f51b7c557fe5fb3c73b5bde15856fbfdb08efbb;hp=35b2143c12cb74743152c18e957844b611ad98aa;hpb=f8dc0335d722acf93a5175786c9217621894e475;p=gosa.git
diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
index 35b2143c1..3a13bde7d 100644
--- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc
+++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
@@ -8,109 +8,102 @@ class servDNSeditZoneEntries extends plugin
var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
/* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array("zoneName");
- var $objectclasses= array("whatever");
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
- var $Devices = array();
- var $InitDevices = array();
- var $zoneName = "";
- var $reverseName = "";
- var $RecordTypes= array();
+ var $Devices = array();
- function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
+ var $zoneName = ""; // ZoneName of currently edited Zone
+ var $reverseName = ""; // ReverseZone of the currently edited Zone
+
+ var $RecordTypes = array(); // Possible record type.
+
+ var $disableDialog = false; // Dialog will be disabled, if this zone is new
+
+ function servDNSeditZoneEntries ($config,$dn, $zoneObject)
{
plugin::plugin ($config, $dn);
- $this->zoneName = $zoneName;
- $this->reverseName = $reverseName;
- $this->RecordTypes = $RTypes;
- $this->RecordTypes['cNAMERecord'] = "relativeDomainName";
+ /* Initialise class
+ */
+ $this->RecordTypes = getDnsRecordTypes();
+ $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn;
+ $this->zoneName = $zoneObject['InitialzoneName'];
+ $this->reverseName = $zoneObject['InitialReverseZone'];
-
+ /* Get ldap connection
+ */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
- /* Get all objects it this zone ...
+ /* Get zone content
*/
- $res = $ldap->search("(&(objectClass=dNSZone)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa))(!(relativeDomainName=@)))");
- while($attrs = $ldap->fetch($res)){
- foreach($this->RecordTypes as $atr => $val){
- if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
- unset($attrs[$val]['count']);
- $dn = preg_replace("/^.*,cn/","cn",$attrs['dn']);
- $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val];
- }
- }
- }
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName"));
- /* Add additional informations
- to all catched objects
- */
- foreach($this->Devices as $dn => $Recs){
- $this->Devices[$dn]['OBJECT'] = $ldap->fetch($ldap->cat($dn,array("objectClass","cn")));
+ while($attrs = $ldap->fetch()){
+ $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true);
+ $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0];
}
- $this->Devices;
- $this->InitDevices = $this->Devices;
+ $ldap->cat($this->dn,array("objectClass"));
+
+ $this->disableDialog = true;
+ if(count($this->Devices)|| $ldap->count()){
+ $this->disableDialog = false;
+ }
}
function execute()
{
- plugin::execute();
+ plugin::execute();
+
/* Check posts for operations ...
*/
$once = true;
foreach($_POST as $name => $value){
-
+
/* Add a new Record in given object
*/
- if((preg_match("/^AddRecord_/",$name)) && ($once)){
- $once = false;
- $tmp = preg_replace("/^AddRecord_/","",$name);
- $tmp = preg_replace("/_.*$/","",$tmp);
- $tmp2 = split("\|",$tmp);
- $dn = base64_decode($tmp2[0]);
- $record = $tmp2[1];
- $numrec = $tmp2[2];
-
- $this->Devices[$dn]['RECORDS'][$record][] = "";
+ $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name);
+ $tmp2 = split("\|",$tmp);
+
+ /* Add new host entry
+ */
+ if((preg_match("/^UserRecord_?/",$name)) && ($once)){
+ $once = false;
+ $entry = getDNSHostEntries($this->config,"",true);
+ $entry['exists'] = true;
+ $entry['zoneName'] = $this->zoneName;
+ $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>"");
+ $this->Devices[_("New entry")] = $entry;
}
-
+
+ if(count($tmp2) != 2) continue;
+
+ $Name = base64_decode($tmp2[0]);
+ $RecordID = $tmp2[1];
+
+ /* Add new REcord
+ */
+ if((preg_match("/^AddRecord_/",$name)) && ($once)){
+ $once = false;
+ $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID];
+ }
+
/* Remove record from given dn
*/
if((preg_match("/^RemoveRecord_/",$name)) && ($once)){
$once = false;
- $tmp = preg_replace("/^RemoveRecord_/","",$name);
- $tmp = preg_replace("/_.*$/","",$tmp);
- $tmp2 = split("\|",$tmp);
-
- $dn = base64_decode($tmp2[0]);
- $record = $tmp2[1];
- $numrec = $tmp2[2];
-
- unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
+ if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+ unset($this->Devices[$Name]['RECORDS'][$RecordID]);
+ }
}
-
- /* Don't know how i should implement this ...
- */
- if((preg_match("/^UserRecord_/",$name)) && ($once)){
- $once = false;
- $tmp = preg_replace("/^UserRecord_/","",$name);
- $tmp = preg_replace("/_.*$/","",$tmp);
- $tmp2 = split("\|",$tmp);
-
- $dn = base64_decode($tmp2[0]);
- $record = $tmp2[1];
- $numrec = $tmp2[2];
- $this->FreeDevices[$dn]['RECORDS']['User'][$numrec] = "";
- }
}
-
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
@@ -120,156 +113,195 @@ class servDNSeditZoneEntries extends plugin
$table .= $this->generateRecordConfigurationRow($key);
}
+ $smarty->assign("disableDialog",$this->disableDialog);
$smarty->assign("table",$table);;
$display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
return($display);
}
- /* Create html table out of given entry
- */
- function generateRecordConfigurationRow($obj_dn){
-
- /* get some basic inforamtions
- */
- $obj = $this->Devices[$obj_dn];
- $objectName = $obj['OBJECT']['cn'][0];
- // set title
- $str = "
".sprintf(_("Settings for '%s'"),$obj_dn)." :
";
-
- /* Walk through all defined records
+ function save_object()
+ {
+ /* Possible attributes posted
*/
- foreach($obj['RECORDS'] as $id => $types){
+ foreach($_POST as $name => $value){
- /* Create table
+ /* Extract informations out of post name
*/
- $str.= "