summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d80fe85)
raw | patch | inline | side by side (parent: d80fe85)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 7 Aug 2007 14:21:18 +0000 (14:21 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 7 Aug 2007 14:21:18 +0000 (14:21 +0000) |
* Add first non working version of the service plugin
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6989 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6989 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_dhcpGroup.inc | patch | blob | history | |
plugins/admin/systems/class_dhcpHost.inc | patch | blob | history | |
plugins/admin/systems/class_dhcpService.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/class_dhcpSubnet.inc | patch | blob | history | |
plugins/admin/systems/class_servDHCP.inc | patch | blob | history | |
plugins/admin/systems/dhcp_service.tpl | [new file with mode: 0644] | patch | blob |
index bce7875c8e57297015d6dbc1632202650aba30e5..04b750e06585252ee6e3e295c4396c965eea95e3 100644 (file)
$this->advanced= new dhcpAdvanced();
$this->advanced->options= $this->options;
$this->advanced->statements= $this->statements;
- $this->advanced->setAutoStatements(array("fixed-address"));
/* Save CN for later reference */
$this->orig_cn= $this->cn;
index a88859c4d8cf74a8f45eb40fb5908145bcfec539..00f43bb2984646a0f37be72db371dbf505ae429f 100644 (file)
$this->network->statements= $this->statements;
$this->advanced= new dhcpAdvanced();
$this->advanced->options= $this->options;
+ $this->advanced->setAutoOptions(array("host-name"));
$this->advanced->statements= $this->statements;
$this->advanced->setAutoStatements(array("fixed-address"));
} else {
unset ($this->statements['fixed-address']);
}
+ $this->options['host-name']= $this->cn;
}
/* Strip network objects */
diff --git a/plugins/admin/systems/class_dhcpService.inc b/plugins/admin/systems/class_dhcpService.inc
--- /dev/null
@@ -0,0 +1,280 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+class dhcpService extends plugin
+{
+ /* Used attributes */
+ var $cn= "";
+ var $orig_cn= "";
+ var $dhcpPrimaryDN= "";
+ 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 */
+ var $network;
+ var $advanced;
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+
+
+ function dhcpService($attrs)
+ {
+ /* Load statements / options */
+ if (is_array($attrs)){
+ $this->dn= $attrs['dn'];
+ $this->new= FALSE;
+
+ /* Load attributes */
+ foreach (array("cn", "dhcpPrimaryDN") as $attr){
+ if (isset($attrs[$attr][0])){
+ $this->$attr= $attrs[$attr][0];
+ }
+ }
+
+ /* Load options */
+ if (isset($attrs['dhcpOption'])){
+ foreach ($attrs['dhcpOption'] as $opt){
+ $idx= preg_replace('/\s.+$/', '', $opt);
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ $this->options[$idx]= $value;
+ }
+ }
+
+ /* Load statements */
+ if (isset($attrs['dhcpStatements'])){
+ foreach ($attrs['dhcpStatements'] as $opt){
+ $idx= preg_replace('/\s.+$/', '', $opt);
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ $this->statements[$idx]= $value;
+ }
+ }
+
+ } else {
+ /* We keep the parent dn here if it's new */
+ $this->dn= $attrs;
+ $this->new= TRUE;
+ }
+
+ /* Load network module */
+ $this->network= new dhcpNetwork();
+ $this->network->options= $this->options;
+ $this->network->statements= $this->statements;
+ $this->advanced= new dhcpAdvanced();
+ $this->advanced->options= $this->options;
+ $this->advanced->statements= $this->statements;
+ $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-name", "get-lease-hostnames", "server-identifier", "ddns-update-style"));
+
+ /* Save for later action */
+ $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
+ $this->orig_cn= $this->cn;
+ }
+
+ function execute()
+ {
+ /* Show main page */
+ $smarty= get_smarty();
+
+ $smarty->assign('ddns_styles', $this->ddns_styles);
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ foreach (array("options", "statements") as $type){
+ $tmp= array_merge($this->$type, $this->network->$type);
+ $this->advanced->$type= $tmp;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+
+ return ($display);
+
+ }
+
+ 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();
+
+ /* 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;
+ }
+
+
+ /* 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";
+ }
+
+ /* 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();
+ }
+ }
+
+ /* 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();
+ }
+ }
+
+ /* 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());
+ }
+ }
+ }
+
+}
+
+?>
diff --git a/plugins/admin/systems/class_dhcpSubnet.inc b/plugins/admin/systems/class_dhcpSubnet.inc
index 28ed6b79c54093f2fe6340d2e28923f0835087c4..3734e2d4edeba30bc77d51df27a1d6b25d574a9b 100644 (file)
$this->advanced= new dhcpAdvanced();
$this->advanced->options= $this->options;
$this->advanced->statements= $this->statements;
- $this->advanced->setAutoStatements(array("fixed-address"));
/* Save CN for later reference */
$this->orig_cn= $this->cn;
index 30ebc6f7c193383265df868d8fbcf2031207405a..c3ee2fbb575025d8c48103a840139b5becc8fe5e 100644 (file)
$editImgIns = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
"<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
"<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
+ $editImgInsNoDel = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
+ "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
$editImg = "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
"<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
foreach($this->dhcpSections as $section => $values ){
if (count(dhcpNewSectionDialog::$sectionMap[$this->objectType($section)])){
- $DhcpList->AddEntry(array(
+ if ($this->objectType($section) == "dhcpService"){
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
+ ));
+ } else {
+ $DhcpList->AddEntry(array(
array("string" => $values),
array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
));
+ }
} else {
$DhcpList->AddEntry(array(
array("string" => $values),
diff --git a/plugins/admin/systems/dhcp_service.tpl b/plugins/admin/systems/dhcp_service.tpl
--- /dev/null
@@ -0,0 +1,44 @@
+<p><b>{t}Generic{/t}</b></p>
+
+<table width="100%">
+ <tr>
+ <td width="50%">
+ <input type=checkbox name="authoritative" value="1" {$authoritative}> {t}Autoritative 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}
+ </select>
+ </td>
+
+ <td style='vertical-align:top'>
+
+ <table>
+ <tr>
+ <td>{t}Default lease time (s){/t}</td>
+ <td>
+ <input type='text' name='default_lease_time' size='25' maxlength='80' value='{$default_lease_time}' title='{t}Enter default lease time in seconds.{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Maximum lease time (s){/t}</td>
+ <td>
+ <input type='text' name='max_lease_time' size='25' maxlength='80' value='{$max_lease_time}' title='{t}Enter maximum lease time in seconds.{/t}'>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+
+ </tr>
+</table>
+
+<p class="seperator"></p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">V
+ <!-- // First input field on page
+ document.mainform.cn.focus();
+ -->
+</script>