From 09d79cc031df0e3afe0b4d4e2cb4a9fcbbf5679a Mon Sep 17 00:00:00 2001 From: cajus Date: Sat, 8 May 2010 11:53:08 +0000 Subject: [PATCH] Added classes and templates git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@18184 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/dhcp/class_dhcpDnsZone.inc | 201 ++++++++++++++++++ .../services/dhcp/class_dhcpTSigKey.inc | 162 ++++++++++++++ .../systems/services/dhcp/dhcp_dnszone.tpl | 39 ++++ .../systems/services/dhcp/dhcp_tsigkey.tpl | 37 ++++ 4 files changed, 439 insertions(+) create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpDnsZone.inc create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpTSigKey.inc create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_dnszone.tpl create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_tsigkey.tpl diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpDnsZone.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpDnsZone.inc new file mode 100644 index 000000000..ddf36870b --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpDnsZone.inc @@ -0,0 +1,201 @@ +new){ + $this->dhcpDnsZoneServer= $attrs['dhcpDnsZoneServer'][0]; + $this->dhcpKeyDN= base64_encode($attrs['dhcpKeyDN'][0]); + } + + // Prepare LDAP link + $ldap= $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + + /* Search for all objects, recursive, that match the given ldap filter. + each dyndns zoen have to depent of an alreday DNS Zone created so we search it + */ + + // Search for domain + $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@))",array("zoneName")); + while($attrs = $ldap->fetch()){ + $this->drop_down_domain[$attrs["zoneName"][0]]= $attrs["zoneName"][0]; + } + + $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@))",array("nSRecord")); + while($attrs = $ldap->fetch()){ + $this->drop_down_nameserver[$attrs["nSRecord"][0]]=$attrs["nSRecord"][0]; + } + + $ldap->search("(objectClass=dhcpTSigKey)",array("dn","cn")); + if ($ldap->count() != 0){ + while($attrs = $ldap->fetch()){ + $this->drop_down_tsigkey[base64_encode($attrs["dn"])]=$attrs["cn"][0]; + } + } + } + + + function execute() + { + $smarty= get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("cns",$this->drop_down_domain); + + $smarty->assign("dhcpDnsZoneServer", $this->dhcpDnsZoneServer); + $smarty->assign("dhcpDnsZoneServers",$this->drop_down_nameserver); + + $smarty->assign("dhcpKeyDN", $this->dhcpKeyDN); + $smarty->assign("dhcpKeyDNs",$this->drop_down_tsigkey); + + /* Assign ACLs */ + $smarty->assign("acl",$this->parent->getacl("")); + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_dnszone.tpl', TRUE,dirname(__FILE__))); + + /* Add footer */ + $display.= "
"; + if(preg_match("/w/",$this->parent->getacl(""))){ + $display.= " "; + } + $display.= ""; + $display.= "
"; + + return ($display); + } + + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save remaining attributes */ + if (isset($_POST['dhcp_dnszone_posted']) && preg_match("/w/", $this->parent->getacl(""))){ + + if (isset($_POST['dhcpKeyDN'])){ + $this->dhcpKeyDN= get_post('dhcpKeyDN'); + } + + if (isset($_POST['dhcpDnsZoneServer'])){ + $this->dhcpDnsZoneServer= get_post('dhcpDnsZoneServer'); + } + if (isset($_POST['cn'])){ + $this->cn= get_post('cn'); + } + + } + + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = array(); + if(isset($this->parent) && isset($this->parent->dhcpObjectCache)){ + $cache = $this->parent->dhcpObjectCache; + } + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= msgPool::required(_("DNS zone")); + } + + if ($this->dhcpDnsZoneServer == ""){ + $message[]= msgPool::required(_("DNS server")); + } + + if ($this->dhcpKeyDN == ""){ + $message[]= msgPool::required(_("Key DN")); + } + + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= msgPool::duplicated(_("Name")); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + + if ($this->dhcpKeyDN != ""){ + $this->attrs['dhcpKeyDN']= array(base64_decode($this->dhcpKeyDN)); + } else { + $this->attrs['dhcpKeyDN']= array(); + } + + if ($this->dhcpDnsZoneServer != ""){ + $this->attrs['dhcpDnsZoneServer']= array($this->dhcpDnsZoneServer); + } else { + $this->attrs['dhcpDnsZoneServer']= array(); + } + + return ($this->attrs); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpTSigKey.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpTSigKey.inc new file mode 100644 index 000000000..900df1113 --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpTSigKey.inc @@ -0,0 +1,162 @@ +new){ + $this->dhcpKeyAlgorithm= $attrs['dhcpKeyAlgorithm'][0]; + $this->dhcpKeySecret= $attrs['dhcpKeySecret'][0]; + } + + } + + function execute() + { + $smarty= get_smarty(); + $smarty->assign("cn", $this->cn); + $dhcpKeyAlgorithm=preg_replace('/\s.*$/', '', $this->dhcpKeyAlgorithm); + $smarty->assign("dhcpKeyAlgorithm",$dhcpKeyAlgorithm); + $smarty->assign("dhcpKeyAlgorithms",array("HMAC-MD5" => _("HMAC-MD5"),"RSAMD5" => _("RSAMD5"),"RSASHA1" => _("RSASHA1"),"DSA" => _("DSA"),"DH" => _("DH"))); + $smarty->assign("dhcpKeySecret",$this->dhcpKeySecret); + + /* Assign ACLs */ + $smarty->assign("acl",$this->parent->getacl("")); + + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_tsigkey.tpl', TRUE,dirname(__FILE__))); + + + /* Add footer */ + $display.= "
"; + if(preg_match("/w/",$this->parent->getacl(""))){ + $display.= " "; + } + $display.= ""; + $display.= "
"; + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save remaining attributes */ + if (isset($_POST['dhcp_tsigkey_posted']) && preg_match("/w/",$this->parent->getacl(""))){ + + if (isset($_POST['dhcpKeyAlgorithm'])){ + $this->dhcpKeyAlgorithm=get_post('dhcpKeyAlgorithm'); + } + + if (isset($_POST['dhcpKeySecret'])){ + $this->dhcpKeySecret=get_post('dhcpKeySecret'); + } + if (isset($_POST['cn'])){ + $this->cn=get_post('cn'); + } + + } + + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = array(); + if(isset($this->parent) && isset($this->parent->dhcpObjectCache)){ + $cache = $this->parent->dhcpObjectCache; + } + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= msgPool::required(_("Key name")); + } + + if ($this->dhcpKeySecret == ""){ + $message[]= msgPool::required(_("Key")); + } + + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= msgPool::duplicated(_("Key name")); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + + if ($this->dhcpKeyAlgorithm != ""){ + $this->attrs['dhcpKeyAlgorithm']= array($this->dhcpKeyAlgorithm); + } else { + $this->attrs['dhcpKeyAlgorithm']= array(); + } + + + if ($this->dhcpKeySecret != ""){ + $this->attrs['dhcpKeySecret']= array($this->dhcpKeySecret); + } else { + $this->attrs['dhcpKeySecret']= array(); + } + + return ($this->attrs); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_dnszone.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_dnszone.tpl new file mode 100644 index 000000000..9390d6bef --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_dnszone.tpl @@ -0,0 +1,39 @@ +{* GOsa dhcp host - smarty template *} +

{t}DNS update zone{/t}

+ + + + + + + + + + + + + +
{t}DNS zone{/t}{$must} + +
{t}DNS server{/t}{$must} + +
{t}Key DN{/t}{$must} + +
+ + + +

+ + + diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_tsigkey.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_tsigkey.tpl new file mode 100644 index 000000000..9ed86a5a8 --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_tsigkey.tpl @@ -0,0 +1,37 @@ +{* GOsa dhcp host - smarty template *} +

{t}DNS update key{/t}

+ + + + + + + + + + + + + + +
{t}Key name{/t}{$must} + +
{t}Encryption method{/t} + +
{t}Key{/t}{$must} + +
+ + + +

+ + + -- 2.30.2