summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1a3d93)
raw | patch | inline | side by side (parent: a1a3d93)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 7 Aug 2007 15:24:56 +0000 (15:24 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 7 Aug 2007 15:24:56 +0000 (15:24 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6990 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_dhcpService.inc | patch | blob | history | |
plugins/admin/systems/dhcp_service.tpl | patch | blob | history |
diff --git a/plugins/admin/systems/class_dhcpService.inc b/plugins/admin/systems/class_dhcpService.inc
index 742c8ddaecdf0a074ce368dcfd0fba9b33e2d413..af2dffe3467c59735a90a4f20ab39612d48b68b5 100644 (file)
var $orig_dhcpPrimaryDN= "";
var $options= array();
var $statements= array();
- var $default_lease_time= 600;
- var $max_lease_time= 1700;
- var $authoritative= TRUE;
- var $get_lease_hostnames= TRUE;
- var $ddns_update_style= "none";
var $ddns_styles= array('none', 'interim', 'ad-hoc');
/* Subobjects */
/* We keep the parent dn here if it's new */
$this->dn= $attrs;
$this->new= TRUE;
+ $this->statements['default_lease_time']= 600;
+ $this->statements['max_lease_time']= 1700;
+ $this->statements['authoritative']= TRUE;
+ $this->statements['get_lease_hostnames']= TRUE;
+ $this->statements['ddns_update_style']= 'none';
}
/* Load network module */
$this->orig_cn= $this->cn;
}
+
function execute()
{
/* Show main page */
$smarty= get_smarty();
$smarty->assign('ddns_styles', $this->ddns_styles);
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
+ if (isset($this->statements[preg_replace('/_/', '-', $value)])){
+ $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
+ } else {
+ $smarty->assign("$value", "");
+ }
+ }
+
+ if (isset($this->statements['authoritative'])){
+ $smarty->assign("authoritative", "checked");
+ } else {
+ $smarty->assign("authoritative", "");
+ }
+
+ if (isset($this->statements['get-lease-hostnames']) && preg_match('/on/i', $this->statements['get-lease-hostnames'])){
+ $smarty->assign("get_lease_hostnames", "checked");
+ } else {
+ $smarty->assign("get_lease_hostnames", "");
+ }
/* Show main page */
$display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
function remove_from_parent()
{
- /* Just remove the dn from the ldap, then we're done. Host
- entries do not have any entries below themselfes. */
- $ldap= $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->recursive_remove();
- show_ldap_error($ldap->get_error());
-
- $ldap->cat($this->dhcpPrimaryDN);
- $attrs= $ldap->fetch();
- $objectclasses= array();
- for($i= 0; $i<$attrs['objectClass']['count']; $i++){
- if ($attrs['objectClass'][$i] != "dhcpServer"){
- $objectclasses[]= $attrs['objectClass'][$i];
- }
- }
- $attrs= array();
- $attrs['dhcpServiceDN']= array();
- $attrs['objectClass']= $objectclasses;
- $ldap->cd($this->dhcpPrimaryDN);
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error());
-
-
- /* Optionally execute a command after we're done */
- $this->postremove();
}
/* Save data to object */
function save_object()
{
- plugin::save_object();
+ /* No need to save in the first time */
+ if (!isset($_POST['ddns_update_style'])){
+ return;
+ }
+
+ /* Save remaining attributes */
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
+ $tval= preg_replace('/_/', '-', $val);
+ if ($_POST[$val] != ""){
+ $this->statements[$tval]= validate($_POST[$val]);
+ } else {
+ unset ($this->statements[$tval]);
+ }
+ }
+ if (isset($_POST['authoritative'])){
+ $this->statements['authoritative']= "";
+ } else {
+ unset($this->statements['authoritative']);
+ }
+ if (isset($_POST['get_lease_hostnames'])){
+ $this->statements['get-lease-hostnames']= "on";
+ } else {
+ $this->statements['get-lease-hostnames']= "off";
+ }
+
+ /* Strip network objects */
+ foreach (array("routers", "domain-name", "subnet-mask", "broadcast-address") as $toberemoved){
+ unset($this->options[$toberemoved]);
+ }
+ foreach (array("filename", "next-server") as $toberemoved){
+ unset($this->statements[$toberemoved]);
+ }
+
+ /* Save sub-objects */
+ $this->network->save_object();
+ $this->advanced->save_object();
+
+ /* Merge arrays for advanced view */
+ foreach (array("options", "statements") as $type){
+ $tmp= array_merge($this->$type, $this->network->$type);
+ $this->advanced->$type= $tmp;
+ }
- /* Save base */
- if (isset($_POST['base'])){
- $this->base= $_POST['base'];
- }
}
/* Check values */
function check()
{
- $message= array();
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
- if ($this->dhcpPrimaryDN == ""){
- $message[]= _("No server specified to host dhcp service!");
- }
-
- return $message;
+ $message= array();
+ return $message;
}
/* Save to LDAP */
function save()
{
-echo "server-name";
-echo "server-identifier";
- plugin::save();
-
- /* Get ldap mode */
- if ($this->dn == "new"){
- $mode= "add";
- $this->dn= "cn=".$this->cn.",ou=dhcp,ou=configs,ou=systems,".$this->base;
- } else {
- $mode= "modify";
- }
+ $this->attrs= array();
+ echo "server-name";
+ echo "server-identifier";
- /* Assemble new entry - options */
- if (isset ($this->options) && count ($this->options)){
- $this->attrs['dhcpOption']= array();
- foreach ($this->options as $key => $val){
- $this->attrs['dhcpOption'][]= "$key $val";
- }
- } else {
- if ($mode == "modify"){
- $this->attrs['dhcpOption']= array();
- }
- }
+ /* Merge arrays for network and advanced view */
+ foreach (array("options", "statements") as $type){
+ $tmp= array_merge($this->$type, $this->network->$type, $this->advanced->$type);
+ $this->$type= $tmp;
+ }
- /* Assemble new entry - statements */
- if (isset ($this->statements) && count ($this->statements)){
- $this->attrs['dhcpStatements']= array();
- foreach ($this->statements as $key => $val){
- $this->attrs['dhcpStatements'][]= "$key $val";
- }
- } else {
- if ($mode == "modify"){
- $this->attrs['dhcpStatements']= array();
- }
- }
+ /* Assemble new entry - options */
+ $this->attrs['dhcpOption']= array();
+ if (isset ($this->options) && count ($this->options)){
+ foreach ($this->options as $key => $val){
+ $this->attrs['dhcpOption'][]= "$key $val";
+ }
+ }
- /* Do LDAP action */
- $ldap= $this->config->get_ldap_link();
- if ($mode == "add"){
- $ldap->cd($this->config->current['BASE']);
- $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
- }
- $ldap->cd($this->dn);
- $ldap->$mode($this->attrs);
- show_ldap_error($ldap->get_error());
-
- /* Modify server entry to keep our 'dn' */
- $ldap->cat($this->dhcpPrimaryDN);
- $attrs= $ldap->fetch();
- $objectclasses= array();
- for($i= 0; $i<$attrs['objectClass']['count']; $i++){
- if ($attrs['objectClass'][$i] != "dhcpServer"){
- $objectclasses[]= $attrs['objectClass'][$i];
- }
- }
- $objectclasses[]= "dhcpServer";
- $attrs= array();
- $attrs['dhcpServiceDN']= $this->dn;
- $attrs['objectClass']= $objectclasses;
- $ldap->cd($this->dhcpPrimaryDN);
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error());
-
- /* Modify old server entry */
- if ( ($this->orig_dhcpPrimaryDN != "")
- && ($this->orig_dhcpPrimaryDN != $this->dhcpPrimaryDN)){
-
- $ldap->cat($this->orig_dhcpPrimaryDN);
- $attrs= $ldap->fetch();
- if (isset($attrs['dhcpServiceDN'])){
- $objectclasses= array();
- for($i= 0; $i<$attrs['objectClass']['count']; $i++){
- if ($attrs['objectClass'][$i] != "dhcpServer"){
- $objectclasses[]= $attrs['objectClass'][$i];
- }
- }
- $attrs= array();
- $attrs['dhcpServiceDN']= array();
- $attrs['objectClass']= $objectclasses;
- $ldap->cd($this->orig_dhcpPrimaryDN);
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error());
- }
- }
+ /* Assemble new entry - statements */
+ $this->attrs['dhcpStatements']= array();
+ if (isset ($this->statements) && count ($this->statements)){
+ foreach ($this->statements as $key => $val){
+ $this->attrs['dhcpStatements'][]= "$key $val";
+ }
+ }
+
+ $this->attrs['objectClass']= array('top', 'dhcpService');
+ $this->attrs['MODIFIED']= TRUE;
+
+ return ($this->attrs);
}
}
index 33d4fd9044c6bbb4d038d4447fd71caac796473f..e4581ef283e2e29170ecebe1ee9af6d509d0034c 100644 (file)
<table width="100%">
<tr>
<td width="50%">
- <input type=checkbox name="authoritative" value="1" {$authoritative}> {t}Autoritative service{/t}<br>
+ <input type=checkbox name="authoritative" value="1" {$authoritative}> {t}Authoritative service{/t}<br>
<input type=checkbox name="get_lease_hostnames" value="1" {$get_lease_hostnames}> {t}Assign hostnames via DNS{/t}<br>
<br>
{t}Dynamic DNS update{/t}
<select name='ddns_update_style' title='{t}Dynamic DNS update style{/t}' size="1">
- {html_options options=$ddns_styles}
+ {html_options options=$ddns_styles selected=$ddns_update_style}
</select>
</td>
<p class="seperator"></p>
<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">V
+<script language="JavaScript" type="text/javascript">
<!-- // First input field on page
- document.mainform.cn.focus();
+ document.mainform.authoritative.focus();
-->
</script>