X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZoneEntries.inc;h=50812871960c60f872fcc874222198b83a7f53d2;hb=c30fdf675865a86365275ed6fb9f8a0cc06e41af;hp=faf29d198257ca3f5c207d4da2ea9425193a4483;hpb=276650eae5da9b54f28f59419c5e19278a47a9ef;p=gosa.git
diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
index faf29d198..508128719 100644
--- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc
+++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
@@ -2,204 +2,102 @@
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 $ignore_account = TRUE;
+ var $attributes = array("cn");
+ var $objectclasses = array("whatever");
- var $Devices = array();
- var $InitDevices = array();
+ var $Devices = array();
- var $FreeHosts = array();
- var $InitFreeHosts= array();
+ var $zoneName = ""; // ZoneName of currently edited Zone
+ var $reverseName = ""; // ReverseZone of the currently edited Zone
- var $zoneName = ""; // ZoneName of currently edited Zone
- var $reverseName = ""; // ReverseZone of the currently edited Zone
-
- var $RecordTypes= array(); // Possible record type. They will be set in contrucktor
- // and some types will be added later (cName/Ptr)
+ var $RecordTypes = array(); // Possible record type.
- function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
+ var $disableDialog = false; // Dialog will be disabled, if this zone is new
+ var $cn;
+
+ 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=@)))");
- 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";
- }
- }
- }
-
- /* Add additional informations
- to all catched 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 Hand entries
- * Free hand 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 subtree within this zone.
- * For example :
- * The object name is FreeHand1,
- * zoneName=test.de,cn=server ...
- * // ObjectContainer
- * relativeDomainName=FreeHand1,zoneName=....
- * // Dns entry
- * relativeDomainName=FreeHand1, relativeDomainName=FreeHand1,zoneName=....
- * // cName entry ....
- * relativeDomainName=terminal12, relativeDomainName=FreeHand1,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()){
-
- unset($attrs[$val]['count']);
-
- $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=....
- // 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];
- }
- }
- }
+ $ldap->cat($this->dn,array("objectClass"));
+
+ $this->disableDialog = true;
+ if(count($this->Devices)|| $ldap->count()){
+ $this->disableDialog = false;
}
-
- $this->Devices;
- $this->InitDevices = $this->Devices;
}
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(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]);
}
-
- }
-
- /* Don't know how i should implement this ...
- */
- 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 */
@@ -211,263 +109,164 @@ 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
- */
- 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
+ function save_object()
+ {
+ /* Possible attributes posted
*/
- $str.= "";
- return($str);
- }
+ $Name = base64_decode($tmp2[0]);
+ $RecordID = $tmp2[1];
- /* Create selectbox with all available option types
- */
- function createRecordTypeSelection($id,$refID,$isFreeRecord =false){
- if(!$isFreeRecord){
- $str = "\n