summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aaf3d4b)
raw | patch | inline | side by side (parent: aaf3d4b)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 8 Aug 2007 15:47:47 +0000 (15:47 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 8 Aug 2007 15:47:47 +0000 (15:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7007 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_dhcpPlugin.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/class_dhcpPlugin.inc | [deleted file] | patch | blob | history |
diff --git a/include/class_dhcpPlugin.inc b/include/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);
+ }
+
+}
+
+?>
diff --git a/plugins/admin/systems/class_dhcpPlugin.inc b/plugins/admin/systems/class_dhcpPlugin.inc
+++ /dev/null
@@ -1,171 +0,0 @@
-<?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);
- }
-
-}
-
-?>