X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZoneEntries.inc;h=50812871960c60f872fcc874222198b83a7f53d2;hb=5f1f63cbff1a76de561e6e556342179ace8ca24e;hp=e775a21f05f3ee0c41aab93d675e676d38d479b7;hpb=866206093f4488b9f56098dcd43034d81a244cff;p=gosa.git
diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
index e775a21f0..508128719 100644
--- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc
+++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
@@ -2,160 +2,59 @@
class servDNSeditZoneEntries 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= TRUE;
- var $attributes= array("zoneName");
- var $objectclasses= array("whatever");
-
- var $Devices = array();
- var $InitDevices = array();
+ var $ignore_account = TRUE;
+ var $attributes = array("cn");
+ var $objectclasses = array("whatever");
- var $zoneName = ""; // ZoneName of currently edited Zone
- var $reverseName = ""; // ReverseZone of the currently edited Zone
+ var $Devices = array();
- var $RecordTypes= array(); // Possible record type. They will be set in contrucktor
- // and some types will be added later (cName/Ptr)
+ 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
+ var $disableDialog = false; // Dialog will be disabled, if this zone is new
+ var $cn;
- function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
+ function servDNSeditZoneEntries ($config,$dn, $zoneObject)
{
plugin::plugin ($config, $dn);
/* Initialise class
*/
- $this->zoneName = $zoneName;
- $this->reverseName = $reverseName;
- $this->RecordTypes = $RTypes;
-
- /* Add records types which are not allowed in zones
- */
- $this->RecordTypes['cNAMERecord'] = "relativeDomainName";
- $this->RecordTypes['pTRRecord'] = "relativeDomainName";
- $this->RecordTypes['tXTRecord'] = "tXTRecord";
+ $this->RecordTypes = getDnsRecordTypes();
+ $this->dn = "zoneName=".getNameFromMix($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 using this zone
- * Workstations / Terminals
- */
- $res = $ldap->search("(&(objectClass=dNSZone)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa))(!(relativeDomainName=@)))");
- $this->disableDialog = false;
- while($attrs = $ldap->fetch($res)){
- if(preg_match("/zoneName=/",$attrs['dn'])) continue;
- 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];
- $this->Devices[$dn]['Type'] = "Exists";
- }
- }
- }
-
- /* Check if this zone exists
- */
- $res = $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa)))",
- array("zoneName"));
- if($ldap->count()){
- }else{
- $this->disableDialog = true;
- }
-
- /* Add additional informations
- to all caught objects ( ObjectInformations)
- */
- foreach($this->Devices as $dn => $Recs){
- $attrs = $ldap->fetch($ldap->cat($dn,array("objectClass","cn")));
- $this->Devices[$dn]['OBJECT'] = $attrs;
- $this->Devices[$dn]['OrigCn'] = $attrs['cn'][0];
- }
-
- /* Add free entries
- * Free entries are entries which are not directly assigned
- * to an existing network object like a WS or a Terminal.
- * They will be found in a subtrees within a zone.
- * For example :
- * The object name is free1,
- * zoneName=test.de,cn=server ...
- * // ObjectContainer
- * relativeDomainName=Free1,zoneName=....
- * // Dns entry
- * relativeDomainName=Free1, relativeDomainName=Free1,zoneName=....
- * // cName entry ....
- * relativeDomainName=terminal12, relativeDomainName=Free1,zone...
+ /* Get zone content
*/
- $ldap->cd ("zoneName=".$this->zoneName.",".$this->dn);
- $ldap->ls ("(&(objectClass=dNSZone)(!(relativeDomainName=@)))","zoneName=".$this->zoneName.",".$this->dn,array("*"));
-
- $GetSubInformations = array();
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName"));
+
while($attrs = $ldap->fetch()){
-
- $dn = $attrs['dn'];
-
- /* Split dn into relativeDomainNames
- */
- $tmp = split("relativeDomainName=",trim(preg_replace("/,zoneName=.*$/","\\1",$dn)));
- $tmp2 = array();
- foreach($tmp as $t){
- if(empty($t)) continue;
- $tmp2[] = preg_replace("/,$/","",$t);
- }
-
- /* Set object Name
- */
- $cn = $tmp2[0];
- $dn = "relativeDomainName=".$cn.",zoneName=".$this->zoneName.",".$this->dn;
-
- /* Create entry
- */
- $this->Devices[$dn]['OBJECT'] = $attrs;
- $this->Devices[$dn]['OBJECT']['cn'][0] = $cn;//attrs['relativeDomainName'];
- $this->Devices[$dn]['OBJECT']['OrigCn'] = $cn;//attrs['relativeDomainName'][0];
- $this->Devices[$dn]['Type'] = "Free";
-
- $GetSubInformations [] = $dn;
+ $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true);
+ $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0];
}
- /* Get sub informations
- CName or pTR records are stored in a sub entry.
-
- // The base entry with aRecords/tXTrecords/....
- relativeDomainName=Keks, relativeDomainName=Keks, zoneName=....
+ $ldap->cat($this->dn,array("objectClass"));
- // And the sub entries like this one
- relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =...
- ( They can't be stored in a single entry, so i decided to store them this way ).
- */
- foreach($GetSubInformations as $dn){
- $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("*"));
- while($attrs= $ldap->fetch()){
- foreach($this->RecordTypes as $atr => $val){
- if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
- unset($attrs[$val]['count']);
- $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val];
- }
- }
- }
+ $this->disableDialog = true;
+ if(count($this->Devices)|| $ldap->count()){
+ $this->disableDialog = false;
}
-
- $this->Devices;
- $this->InitDevices = $this->Devices;
}
function execute()
{
plugin::execute();
+
/* Check posts for operations ...
*/
$once = true;
@@ -163,51 +62,42 @@ class servDNSeditZoneEntries extends plugin
/* 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);
+
+ $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name);
+ $tmp2 = split("\|",$tmp);
- $dn = base64_decode($tmp2[0]);
- $record = $tmp2[1];
- $numrec = $tmp2[2];
+ /* 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;
+ }
- $this->Devices[$dn]['RECORDS'][$record][] = "";
+ 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(count($this->Devices[$dn]['RECORDS'][$record]) == 0){
- unset($this->Devices[$dn]['RECORDS'][$record]);
- if(count($this->Devices[$dn]['RECORDS']) ==0){
- unset($this->Devices[$dn]);
- }
+ if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+ unset($this->Devices[$Name]['RECORDS'][$RecordID]);
}
-
}
- /* Add new host entry
- */
- if((preg_match("/^UserRecord_/",$name)) && ($once)){
- $once = false;
- $tmp['RECORDS']['aRecord'][0] = 'empty';
- $tmp['Type'] = 'Free';
- $tmp['OBJECT']['cn'][0] = 'Free';
- $this->Devices[] = $tmp;
- }
}
/* Fill templating stuff */
@@ -219,7 +109,6 @@ 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));
@@ -227,268 +116,157 @@ class servDNSeditZoneEntries extends plugin
}
- /* 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
- */
- if($obj['Type'] == "Free"){
- $str = "
".sprintf(_("Settings for host entry #%s"),($obj_dn +1))." :
";
- }else{
- $str = "".sprintf(_("Settings for '%s'"),$obj_dn)." :
";
- }
-
- $hostNameOnce = true;
- /* Walk through all defined records
- */
- $str.= "";
- return($str);
- }
-
- /* Create selectbox with all available option types
- */
- function createRecordTypeSelection($id,$refID,$isFreeRecord =false){
- if(!$isFreeRecord){
- $str = "\n