summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69d4bf5)
raw | patch | inline | side by side (parent: 69d4bf5)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Jul 2010 09:17:16 +0000 (09:17 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Jul 2010 09:17:16 +0000 (09:17 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19145 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc | patch | blob | history |
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc
index 5c93fb1b627e24d0d27c17b89d704d4bddf4ccec..dc5f65c658616b47dd046363f304cc879e015ae0 100644 (file)
<?php
/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
+ 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 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.
+ 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
-*/
+ 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 dhcpHost extends dhcpPlugin
{
- /* Used attributes */
- var $dhcpHWAddress= "";
- var $realGosaHost = FALSE;
-
- /* attribute list for save action */
- var $objectclasses= array("top", "dhcpHost");
-
- function dhcpHost($parent,$attrs,$host_exists_in_gosa = FALSE)
- {
- dhcpPlugin::dhcpPlugin($parent,$attrs);
-
- /* Load attributes */
- if (!$this->new){
- $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
- }
-
- $this->advanced->setAutoOptions(array("host-name"));
- $this->advanced->setAutoStatements(array("fixed-address"));
+ /* Used attributes */
+ var $dhcpHWAddress= "";
+ var $realGosaHost = FALSE;
- $this->realGosaHost = $host_exists_in_gosa;
- }
+ /* attribute list for save action */
+ var $objectclasses= array("top", "dhcpHost");
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
- $smarty->assign("realGosaHost",$this->realGosaHost);
+ function dhcpHost($parent,$attrs,$host_exists_in_gosa = FALSE)
+ {
+ dhcpPlugin::dhcpPlugin($parent,$attrs);
- /* Assign ACLs */
- $smarty->assign("acl",$this->parent->getacl(""));
-
- /* Create fixed address */
- $smarty->assign("fixedaddr", $this->statements->get('fixed-address'));
+ /* Load attributes */
+ if (!$this->new){
+ $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
+ }
- /* Prepare hw type selector */
- $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
- $smarty->assign("hwtype", $hwtype);
- $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"),
- "fddi" => _("FDDI"),
- "token-ring" => _("Token Ring")));
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
+ $this->advanced->setAutoOptions(array("host-name"));
+ $this->advanced->setAutoStatements(array("fixed-address"));
- /* Get advanced options */
- $display.= $this->advanced->execute();
+ $this->realGosaHost = $host_exists_in_gosa;
+ }
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
-# if(preg_match("/w/",$this->parent->getacl(""))){
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", set_post($this->cn));
+ $smarty->assign("dhcpHWAddress", set_post(preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress)));
+ $smarty->assign("realGosaHost", set_post($this->realGosaHost));
+
+ /* Assign ACLs */
+ $smarty->assign("acl",$this->parent->getacl(""));
+
+ /* Create fixed address */
+ $smarty->assign("fixedaddr", set_post($this->statements->get('fixed-address')));
+
+ /* Prepare hw type selector */
+ $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
+ $smarty->assign("hwtype", set_post($hwtype));
+ $smarty->assign("hwtypes",
+ set_post(
+ array(
+ "ethernet" => _("Ethernet"),
+ "fddi" => _("FDDI"),
+ "token-ring" => _("Token Ring"))));
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
+
+ /* Get advanced options */
+ $display.= $this->advanced->execute();
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
$display.= "<button type='submit' name='save_dhcp'>".msgPool::saveButton()."</button> ";
-# }
- $display.= "<button type='submit' name='cancel_dhcp'>".msgPool::cancelButton()."</button>";
- $display.= "</div>";
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Save remaining attributes */
- if (isset($_POST['dhcp_host_posted']) && preg_match("/w/",$this->parent->getacl(""))){
-
- /* Assemble hwAddress */
- if (isset($_POST['dhcpHWAddress'])){
- $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
- }
-
- if(!$this->realGosaHost){
- $this->cn= validate(get_post('cn'));
- }
-
- /* Save fixed address */
- if(!$this->realGosaHost){
- if ($_POST['fixedaddr'] != ""){
- $this->statements->set('fixed-address', get_post('fixedaddr'));
- } else {
- $this->statements->removeAll('fixed-address');
- }
- }
- $this->options->set('host-name',$this->cn);
+ $display.= "<button type='submit' name='cancel_dhcp'>".msgPool::cancelButton()."</button>";
+ $display.= "</div>";
+
+ return ($display);
}
- dhcpPlugin::save_object();
- }
+ function remove_from_parent()
+ {
+ }
- /* Check values */
- function check()
- {
- $message= array();
- $cache = array();
- if(isset($this->parent) && isset($this->parent->dhcpObjectCache)){
- $cache = $this->parent->dhcpObjectCache;
- }
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= msgPool::required(_("Name"));
+ /* Save data to object */
+ function save_object()
+ {
+ /* Save remaining attributes */
+ if (isset($_POST['dhcp_host_posted']) && preg_match("/w/",$this->parent->getacl(""))){
+
+ /* Assemble hwAddress */
+ if (isset($_POST['dhcpHWAddress'])){
+ $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
+ }
+
+ if(!$this->realGosaHost){
+ $this->cn= get_post('cn');
+ }
+
+ /* Save fixed address */
+ if(!$this->realGosaHost){
+ if ($_POST['fixedaddr'] != ""){
+ $this->statements->set('fixed-address', get_post('fixedaddr'));
+ } else {
+ $this->statements->removeAll('fixed-address');
+ }
+ }
+ $this->options->set('host-name',$this->cn);
+ }
+
+ dhcpPlugin::save_object();
}
- /* 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[]= msgPool::duplicated(_("Name"));
- break;
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = array();
+ if(isset($this->parent) && isset($this->parent->dhcpObjectCache)){
+ $cache = $this->parent->dhcpObjectCache;
}
- }
- }
- /* Check syntax of MAC address */
- $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
- if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
- $message[]= msgPool::invalid(_("Hardware address"));
- }
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= msgPool::required(_("Name"));
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= msgPool::duplicated(_("Name"));
+ break;
+ }
+ }
+ }
- return $message;
- }
+ /* Check syntax of MAC address */
+ $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
+ if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
+ $message[]= msgPool::invalid(_("Hardware address"));
+ }
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- if ($this->dhcpHWAddress != ""){
- $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
- } else {
- $this->attrs['dhcpHWAddress']= array();
+ return $message;
}
- return ($this->attrs);
- }
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ if ($this->dhcpHWAddress != ""){
+ $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
+ } else {
+ $this->attrs['dhcpHWAddress']= array();
+ }
+
+ return ($this->attrs);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: