index 7bc056a17d3cf03df0014f7cb394260e7a8e6c86..997a8ad00fc0efbb481707c4cc0c3e86d76b1c71 100644 (file)
var $orig_dn = "";
- var $DNSinitially_was_account;
-
+ var $initially_was_account;
+
+ /* ServerService tab vars */
+ var $conflicts = array("servdns");
+ var $DisplayName = "";
+ var $StatusFlag = "";
- function servdns ($config, $dn= NULL)
+ function servdns ($config, $dn= NULL, $parent= NULL)
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
+
+ $this->DisplayName = _("Domain name system service");
$this->orig_dn = $dn;
}else{
$this->is_account = true;
}
- $this->DNSinitially_was_account = $this->is_account;
+ $this->initially_was_account = $this->is_account;
}
}
if ($this->is_account){
- $display= $this->show_header(_("Remove DNS service"),
+ $display= $this->show_disable_header(_("Remove DNS service"),
_("This server has DNS features enabled. You can disable them by clicking below."));
} else {
- $display= $this->show_header(_("Add DNS service"),
+ $display= $this->show_enable_header(_("Add DNS service"),
_("This server has DNS features disabled. You can enable them by clicking below."));
return ($display);
}
$str .=" ... ";
}
print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str)));
-
+ return(false);
}else{
unset($this->Zones[$id]);
+ return(true);
}
}
*/
function remove_from_parent()
{
- if(!$this->DNSinitially_was_account){
- return;
- }
- print_red("Can't remove dns yet. returning without remove.");
- return;
- $ldap = $this->config->get_ldap_link();
- $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",$this->orig_dn,array("relativeDomainName","zoneName"));
- while($attr = $ldap->fetch()){
- $ldap->cd($attr['dn']);
- $ldap->rmDir($attr['dn']);
+ if($this->initially_was_account){
+ $bool = true;
+ foreach($this->Zones as $key => $zone){
+ $bool= $bool & $this->RemoveZone($key);
+ }
+
+ if($bool){
+ $this->save();
+ }
+ return($bool);
}
- show_ldap_error($ldap->get_error());
}
/* Get differences
*/
$tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$this->orig_dn);
-
+
/* Updated zone entries if reverser or forward name has changed
* Must be done before moving entries, else the given dn is invalid
*/
foreach($tmp['zoneUpdates'] as $dn => $attrs){
$ldap->cd($dn);
$ldap->modify($attrs);
- show_ldap_error("Zone:".$ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn));
}
}
foreach($tmp['del'] as $dn => $del){
$ldap->cd($dn);
$ldap->rmdir_recursive($dn);
- show_ldap_error("Zone:".$ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn));
}
/* move follwoing entries
*/
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);
$ldap->cd($dn);
$ldap->add($attrs);
}
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
+ }
+ }
+
+
+ /* Directly save new status flag */
+ function setStatus($value)
+ {
+ if($value == "none") return;
+ if(!$this->initially_was_account) return;
+ if(empty($this->StatusFlag)) return;
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->dn);
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+
+ $tmp = $ldap->fetch();
+ for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
+ $attrs['objectClass'][] = $tmp['objectClass'][$i];
+ }
+ $flag = $this->StatusFlag;
+ $attrs[$flag] = $value;
+ $this->$flag = $value;
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn));
+ $this->action_hook();
}
}
+
+
+ function getListEntry()
+ {
+ $this->updateStatusState();
+ $flag = $this->StatusFlag;
+ if(empty($flag)){
+ $fields['Status'] = "";
+ }else{
+ $fields['Status'] = $this->$flag;
+ }
+ $fields['Message'] = _("DNS service");
+ $fields['AllowStart'] = true;
+ $fields['AllowStop'] = true;
+ $fields['AllowRestart'] = true;
+ $fields['AllowRemove']= true;
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ /* Get updates for status flag */
+ function updateStatusState()
+ {
+ if(empty($this->StatusFlag)) return;
+
+ $attrs = array();
+ $flag = $this->StatusFlag;
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->cn);
+ $ldap->cat($this->dn,array($flag));
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ }
+ if(isset($attrs[$flag][0])){
+ $this->$flag = $attrs[$flag][0];
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ function plInfo()
+ {
+ return (array(
+ "plShortName" => _("DNS"),
+ "plDescription" => _("DNS service"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 0,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "zoneName" =>_("Zone name"),
+ "ReverseZone" =>_("Reverse zone"),
+ "sOAprimary" =>_("Primary dns server"),
+ "sOAmail" =>_("Mail address"),
+ "sOAserial" =>_("Serial"),
+ "sOArefresh" =>_("Refresh"),
+ "sOAretry" =>_("Retry"),
+ "sOAexpire" =>_("Expire"),
+ "sOAttl" =>_("TTL"),
+ "zoneRecords" =>_("Zone records"))
+ ));
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>