X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDNSeditZoneEntries.inc;h=50812871960c60f872fcc874222198b83a7f53d2;hb=5f1f63cbff1a76de561e6e556342179ace8ca24e;hp=7a2e57a45d817e6106ec421c3c040efad07d80a3;hpb=c69a8774d92e7bddd0deab1bdd4586b9b0976f58;p=gosa.git diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc index 7a2e57a45..508128719 100644 --- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc +++ b/plugins/admin/systems/class_servDNSeditZoneEntries.inc @@ -2,14 +2,9 @@ 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(); + var $attributes = array("cn"); var $objectclasses = array("whatever"); var $Devices = array(); @@ -20,6 +15,7 @@ class servDNSeditZoneEntries extends plugin var $RecordTypes = array(); // Possible record type. var $disableDialog = false; // Dialog will be disabled, if this zone is new + var $cn; function servDNSeditZoneEntries ($config,$dn, $zoneObject) { @@ -28,7 +24,7 @@ class servDNSeditZoneEntries extends plugin /* Initialise class */ $this->RecordTypes = getDnsRecordTypes(); - $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; + $this->dn = "zoneName=".getNameFromMix($zoneObject['InitialzoneName']).",".$dn; $this->zoneName = $zoneObject['InitialzoneName']; $this->reverseName = $zoneObject['InitialReverseZone']; @@ -46,8 +42,11 @@ class servDNSeditZoneEntries extends plugin $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; } - if(!count($this->Devices)){ - $this->disableDialog = true; + $ldap->cat($this->dn,array("objectClass")); + + $this->disableDialog = true; + if(count($this->Devices)|| $ldap->count()){ + $this->disableDialog = false; } } @@ -69,13 +68,13 @@ class servDNSeditZoneEntries extends plugin /* Add new host entry */ - if((preg_match("/^UserRecord_/",$name)) && ($once)){ + 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[_("New entry")] = $entry; } if(count($tmp2) != 2) continue; @@ -185,14 +184,21 @@ class servDNSeditZoneEntries extends plugin */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); $names = array(); + foreach($this->Devices as $DevName => $device){ + /* skip checking empty attributes */ + if(count($this->Devices[$DevName]['RECORDS']) == 0){ + return; + } + /* Checking entry name */ if((!is_uid($DevName)) | (empty($DevName))){ @@ -202,13 +208,13 @@ class servDNSeditZoneEntries extends plugin /* Renaming check for existing devices */ if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ - $ldap->cd($this->config->current['BASE']); + $ldap->cd($this->dn); $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); if($ldap->count()){ $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); } }elseif(!isset($device['OrigCn'])){ - $ldap->cd($this->config->current['BASE']); + $ldap->cd($this->dn); $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); if($ldap->count()){ $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); @@ -225,6 +231,8 @@ class servDNSeditZoneEntries extends plugin /* Names should be written in lowercase */ + + if(strtolower($DevName) != $DevName){ $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); } @@ -271,6 +279,7 @@ class servDNSeditZoneEntries extends plugin $todo = array(); + /* Create todolist */ foreach($this->Devices as $name => $dev){ @@ -322,7 +331,7 @@ class servDNSeditZoneEntries extends plugin */ foreach($tmp['add'] as $dn => $attrs){ $ldap->cd($dn); - $ldap->cat($dn); + $ldap->cat($dn, array('dn')); if(count($ldap->fetch())){ $ldap->cd($dn); $ldap->modify ($attrs); @@ -349,7 +358,7 @@ class servDNSeditZoneEntries extends plugin /* Set title */ - $str = "