From ef1ce01b75f4d03d50ddb24a39ef3b6c1b381a64 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 26 Mar 2009 19:51:37 +0000 Subject: [PATCH] added upload --- lam/lib/modules/ddns.inc | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index fdeddc28..c17f3e33 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -106,6 +106,32 @@ class ddns extends baseModule { 'zone', 'reverseZone', ); + // upload fields + if (isset($_SESSION['loggedIn']) && $this->check_if_ddns_is_enable()) { + $return['upload_columns'] = array( + array( + 'name' => 'ddns_DNSserver', + 'description' => _('IP address of the DNS server'), + 'help' => 'dns', + 'example' => '123.123.123.123', + 'required' => true + ), + array( + 'name' => 'ddns_zone', + 'description' => _('Zone names'), + 'help' => 'zone', + 'example' => 'company.local', + 'required' => true + ), + array( + 'name' => 'ddns_reverseZone', + 'description' => _('Reverse zone names'), + 'help' => 'zone_reverse', + 'example' => '0.168.192.in-addr.arpa', + 'required' => true + ), + ); + } return $return; } @@ -116,6 +142,7 @@ class ddns extends baseModule { $this->messages['key_path'][0] = array('ERROR', 'Please enter the path to the key.', ''); $this->messages['key_path'][1] = array('ERROR', 'The key path contains invalid characters.', ''); $this->messages['ip'][0] = array('ERROR', 'The IP address of the DNS server is invalid.'); + $this->messages['ip'][1] = array('ERROR', _('Account %s:') . ' ddns_DNSserver', 'The IP address of the DNS server is invalid.'); $this->messages['zone'][0] = array('ERROR', 'Please enter a zone name.'); $this->messages['zone_reverse'][0] = array('ERROR', 'Please enter the reverse zone.'); } @@ -580,6 +607,34 @@ class ddns extends baseModule { // load nothing, attributes are saved in "dhcp_settings" module } + /** + * In this function the LDAP account is built up. + * + * @param array $rawAccounts list of hash arrays (name => value) from user input + * @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP + * @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5) + * @return array list of error messages if any + */ + function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { + $messages = array(); + if (!$this->check_if_ddns_is_enable()) { + return $messages; + } + for ($i = 0; $i < sizeof($rawAccounts); $i++) { + // principal name + if (!check_ip($rawAccounts[$i][$ids['ddns_DNSserver']])) { + $error = $this->messages['ip'][1]; + array_push($error, $i); + $messages[] = $error; + } + else { + $partialAccounts[$i]['dhcpStatements'][] = "zone {$rawAccounts[$i][$ids['ddns_zone']]}. { primary {$rawAccounts[$i][$ids['ddns_DNSserver']]}; key DHCP_UPDATER; }"; + $partialAccounts[$i]['dhcpStatements'][] = "zone {$rawAccounts[$i][$ids['ddns_reverseZone']]}. { primary {$rawAccounts[$i][$ids['ddns_DNSserver']]}; key DHCP_UPDATER; }"; + } + } + return $messages; + } + } ?>