summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 15de819)
raw | patch | inline | side by side (parent: 15de819)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 8 Aug 2007 15:47:30 +0000 (15:47 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 8 Aug 2007 15:47:30 +0000 (15:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7006 594d385d-05f5-0310-b6e9-bd551577e9d8
index 04b750e06585252ee6e3e295c4396c965eea95e3..7a412665c015cb5148751fc106d62013c17695a5 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-class dhcpGroup extends plugin
+class dhcpGroup extends dhcpPlugin
{
- /* Used attributes */
- var $cn= "";
- var $options= array();
- var $statements= array();
- var $orig_cn= "";
- var $network;
- var $advanced;
-
/* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
+ var $objectclasses= array('top', 'dhcpGroup', 'dhcpOptions');
function dhcpGroup($attrs)
{
/* Load statements / options */
- if (is_array($attrs)){
- $this->dn= $attrs['dn'];
- $this->cn= $attrs['cn'][0];
- $this->new= FALSE;
-
- /* 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;
-
- /* Save CN for later reference */
- $this->orig_cn= $this->cn;
+ dhcpPlugin::dhcpPlugin($attrs);
}
function execute()
$this->cn= validate($_POST['cn']);
}
- /* 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;
- }
+ /* Handle global saving */
+ dhcpPlugin::save_object();
}
$message[]= _("Field 'Name' contains illegal characters.");
}
+ /* 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[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+
return $message;
}
/* Save to LDAP */
function save()
{
- /* 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;
- }
-
- /* Add cn if we're new */
- if ($this->new){
- $this->dn= "cn=".$this->cn.",".$this->dn;
- } else {
- $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
- }
-
- /* 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";
- }
- }
-
- /* 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";
- }
- }
-
- /* Move dn to the result */
- $this->attrs['dn']= $this->dn;
- $this->attrs['cn']= array($this->cn);
- $this->attrs['objectClass']= array('top', 'dhcpGroup', 'dhcpOptions');
- $this->attrs['MODIFIED']= TRUE;
-
+ dhcpPlugin::save();
return ($this->attrs);
}
index 00f43bb2984646a0f37be72db371dbf505ae429f..ffc20e00cdba1598b2bd9314e0dd46a51dceb7a6 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-class dhcpHost extends plugin
+class dhcpHost extends dhcpPlugin
{
/* Used attributes */
- var $cn= "";
- var $orig_cn= "";
var $dhcpHWAddress= "";
- var $options= array();
- var $statements= array();
- var $dn= "";
-
- /* Subobjects */
- var $network;
- var $advanced;
/* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
+ var $objectclasses= array("top", "dhcpHost");
function dhcpHost($attrs)
{
- /* Load statements / options */
- if (is_array($attrs)){
- $this->dn= $attrs['dn'];
- $this->new= FALSE;
+ dhcpPlugin::dhcpPlugin($attrs);
+ if (!$this->new){
/* Load attributes */
foreach (array("cn", "dhcpHWAddress") 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->setAutoOptions(array("host-name"));
- $this->advanced->statements= $this->statements;
$this->advanced->setAutoStatements(array("fixed-address"));
-
- /* Save CN for later reference */
- $this->orig_cn= $this->cn;
}
function execute()
$this->options['host-name']= $this->cn;
}
- /* 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;
- }
+ dhcpPlugin::save_object();
}
/* Save to LDAP */
function save()
{
- /* 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;
- }
-
- /* Add cn if we're new */
- if ($this->new){
- $this->dn= "cn=".$this->cn.",".$this->dn;
- } else {
- $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
- }
-
- /* 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";
- }
- }
-
- /* 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";
- }
- }
-
- /* Move dn to the result */
- $this->attrs['dn']= $this->dn;
- $this->attrs['cn']= array($this->cn);
+ dhcpPlugin::save();
if ($this->dhcpHWAddress != ""){
$this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
} else {
$this->attrs['dhcpHWAddress']= array();
}
- $this->attrs['objectClass']= array('top', 'dhcpHost');
- $this->attrs['MODIFIED']= TRUE;
return ($this->attrs);
}
diff --git a/plugins/admin/systems/class_dhcpPlugin.inc b/plugins/admin/systems/class_dhcpPlugin.inc
--- /dev/null
@@ -0,0 +1,171 @@
+<?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 dhcpPlugin extends plugin
+{
+ /* Used attributes */
+ var $cn= "";
+ var $orig_cn= "";
+ var $options= array();
+ var $statements= array();
+
+ /* Subobjects */
+ var $network;
+ var $advanced;
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+
+ function dhcpPlugin($attrs)
+ {
+ /* Load statements / options */
+ if (is_array($attrs)){
+ $this->dn= $attrs['dn'];
+ $this->cn= $attrs['cn'][0];
+ $this->new= FALSE;
+
+ /* 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;
+
+ /* Save CN for later reference */
+ $this->orig_cn= $this->cn;
+ }
+
+ function execute()
+ {
+ return ("");
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* 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;
+ }
+ }
+
+
+ /* Check values */
+ function check($cache)
+ {
+ $message= array();
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* 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;
+ }
+
+ /* Add cn if we're new */
+ if ($this->new){
+ $this->dn= "cn=".$this->cn.",".$this->dn;
+ } else {
+ $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
+ }
+
+ /* 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";
+ }
+ }
+
+ /* Assemble new entry - statements */
+ $this->attrs['dhcpStatements']= array();
+ if (isset ($this->statements) && count ($this->statements)){
+ foreach ($this->statements as $key => $val){
+ if ($val != ""){
+ $this->attrs['dhcpStatements'][]= "$key $val";
+ } else {
+ $this->attrs['dhcpStatements'][]= "$key";
+ }
+ }
+ }
+
+ /* Move dn to the result */
+ $this->attrs['dn']= $this->dn;
+ $this->attrs['cn']= array($this->cn);
+ $this->attrs['objectClass']= $this->objectclasses;
+ $this->attrs['MODIFIED']= TRUE;
+
+ return ($this->attrs);
+ }
+
+}
+
+?>
index cccbb90a5bc6c7b06c44fcd22e98ed493746e592..5677322ff5a1bda24a1d84f297473661ac6797eb 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-class dhcpPool extends plugin
+class dhcpPool extends dhcpPlugin
{
/* Used attributes */
- var $cn= "";
var $dhcpRange= "";
var $range_start= "";
var $range_stop= "";
- var $options= array();
- var $statements= array();
-
- /* Subobjects */
- var $network;
- var $advanced;
/* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
+ var $objectclasses= array('top', 'dhcpPool');
function dhcpPool($attrs)
{
- /* Load statements / options */
- if (is_array($attrs)){
- $this->dn= $attrs['dn'];
- $this->new= FALSE;
+ dhcpPlugin::dhcpPlugin($attrs);
- /* Load attributes */
- $this->cn= $attrs['cn'][0];
+ /* Load attributes */
+ if (!$this->new){
$this->dhcpRange= $attrs['dhcpRange'][0];
list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
-
- /* 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->setAutoOptions(array("host-name"));
- $this->advanced->statements= $this->statements;
$this->advanced->setAutoStatements(array("fixed-address"));
-
- /* Save CN for later reference */
- $this->orig_cn= $this->cn;
}
function execute()
$this->range_stop= validate($_POST['range_stop']);
}
- /* 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;
- }
+ dhcpPlugin::save_object();
/* Move range to internal variable */
$this->dhcpRange= $this->range_start." ".$this->range_stop;
/* Save to LDAP */
function save()
{
- /* 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;
- }
-
- /* Add cn if we're new */
- if ($this->new){
- $this->dn= "cn=".$this->cn.",".$this->dn;
- } else {
- $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
- }
-
- /* 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";
- }
- }
-
- /* 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";
- }
- }
-
- /* Move dn to the result */
- $this->attrs['dn']= $this->dn;
- $this->attrs['cn']= array($this->cn);
+ dhcpPlugin::save();
$this->attrs['dhcpRange']= array($this->dhcpRange);
- $this->attrs['objectClass']= array('top', 'dhcpPool');
- $this->attrs['MODIFIED']= TRUE;
return ($this->attrs);
}
diff --git a/plugins/admin/systems/class_dhcpService.inc b/plugins/admin/systems/class_dhcpService.inc
index 6118e7e5717d5447b2f733311c62dc4ec40fdb13..940ea71094c5f48e2f1730ed0515dcf3c017c48c 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-class dhcpService extends plugin
+class dhcpService extends dhcpPlugin
{
/* Used attributes */
- var $cn= "";
- var $orig_cn= "";
var $dhcpPrimaryDN= "";
var $orig_dhcpPrimaryDN= "";
- var $options= array();
- var $statements= array();
var $ddns_styles= array('none', 'interim', 'ad-hoc');
- /* Subobjects */
- var $network;
- var $advanced;
-
/* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
+ var $objectclasses= array('top', 'dhcpService');
function dhcpService($attrs)
{
- /* Load statements / options */
- if (is_array($attrs)){
- $this->dn= $attrs['dn'];
- $this->new= FALSE;
+ dhcpPlugin::dhcpPlugin($attrs);
+ /* Load statements / options */
+ if (!$this->new){
/* 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);
- if ($idx == $opt){
- $value= "";
- } else {
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
- }
- $this->statements[$idx]= $value;
- }
- }
-
+ $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
} else {
/* 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['ddns-update-style']= 'none';
}
- /* 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", "get-lease-hostnames", "server-identifier", "ddns-update-style"));
$this->advanced->setAutoOptions(array("server-name"));
/* Save for later action */
$this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
- $this->orig_cn= $this->cn;
}
$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;
- }
-
+ dhcpPlugin::save_object();
}
$res= $ldap->fetch();
$server_name= $res['cn'][0];
- /* 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 - options */
- $this->attrs['dhcpOption']= array();
- if (isset ($this->options) && count ($this->options)){
- foreach ($this->options as $key => $val){
- if ($key != "server-name"){
- $this->attrs['dhcpOption'][]= "$key $val";
- }
- }
- }
-
- /* Assemble new entry - statements */
- $this->attrs['dhcpStatements']= array();
- if (isset ($this->statements) && count ($this->statements)){
- foreach ($this->statements as $key => $val){
- if ($val != ""){
- $this->attrs['dhcpStatements'][]= "$key $val";
- } else {
- $this->attrs['dhcpStatements'][]= "$key";
- }
- }
- }
+ dhcpPlugin::save();
- $this->attrs['dn']= $this->dn;
- $this->attrs['cn']= array($this->cn);
$this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
- $this->attrs['objectClass']= array('top', 'dhcpService');
- $this->attrs['MODIFIED']= TRUE;
$this->attrs['dhcpOption'][]= "server-name $server_name";
return ($this->attrs);