summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1d19498)
raw | patch | inline | side by side (parent: 1d19498)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Jul 2010 09:17:41 +0000 (09:17 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 27 Jul 2010 09:17:41 +0000 (09:17 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19154 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc | patch | blob | history |
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc
index da1a430efbe3acb1029bae6708eacb631f6c6a28..29e1f52128a7921c18c55c64c966d1ae105cfea4 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 dhcpSubnet extends dhcpPlugin
{
- /* Used attributes */
- var $dhcpNetMask= 24;
- var $dhcpRange= "";
- var $range_start= "";
- var $range_stop= "";
- var $use_range= FALSE;
-
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpSubnet', 'dhcpOptions');
-
- function dhcpSubnet($parent,$attrs)
- {
- dhcpPlugin::dhcpPlugin($parent,$attrs);
-
- if (!$this->new){
- /* Load attributes */
- foreach (array("dhcpNetMask", "dhcpRange") as $attr){
- if (isset($attrs[$attr][0])){
- $this->$attr= $attrs[$attr][0];
+ /* Used attributes */
+ var $dhcpNetMask= 24;
+ var $dhcpRange= "";
+ var $range_start= "";
+ var $range_stop= "";
+ var $use_range= FALSE;
+
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpSubnet', 'dhcpOptions');
+
+ function dhcpSubnet($parent,$attrs)
+ {
+ dhcpPlugin::dhcpPlugin($parent,$attrs);
+
+ if (!$this->new){
+ /* Load attributes */
+ foreach (array("dhcpNetMask", "dhcpRange") as $attr){
+ if (isset($attrs[$attr][0])){
+ $this->$attr= $attrs[$attr][0];
+ }
+ }
+ if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
+ $this->use_range= TRUE;
+ list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
+ }
}
- }
- if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
- $this->use_range= TRUE;
- list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
- }
+
+ $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
}
- $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
- }
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", set_post($this->cn));
+ $smarty->assign("dhcp_netmask", set_post($this->dhcpNetMask));
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcp_netmask", $this->dhcpNetMask);
+ /* Assign ACLs */
+ $smarty->assign("acl",$this->parent->getacl(""));
- /* Assign ACLs */
- $smarty->assign("acl",$this->parent->getacl(""));
+ /* Prepare range */
+ if ($this->use_range){
+ $smarty->assign("use_range", "checked");
+ $smarty->assign("range_disabled", "");
+ } else {
+ $smarty->assign("use_range", "");
+ $smarty->assign("range_disabled", "disabled");
+ }
+ $smarty->assign("range_start", set_post($this->range_start));
+ $smarty->assign("range_stop", set_post($this->range_stop));
- /* Prepare range */
- if ($this->use_range){
- $smarty->assign("use_range", "checked");
- $smarty->assign("range_disabled", "");
- } else {
- $smarty->assign("use_range", "");
- $smarty->assign("range_disabled", "disabled");
- }
- $smarty->assign("range_start", $this->range_start);
- $smarty->assign("range_stop", $this->range_stop);
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE, dirname(__FILE__))).$this->network->execute();
+ $display.= $this->advanced->execute();
- $display.= $this->advanced->execute();
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
+ if(preg_match("/w/",$this->parent->getacl(""))){
+ $display.= "<button type='submit' name='save_dhcp'>".msgPool::saveButton()."</button> ";
+ }
+ $display.= "<button type='submit' name='cancel_dhcp'>".msgPool::cancelButton()."</button>";
+ $display.= "</div>";
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'>";
- if(preg_match("/w/",$this->parent->getacl(""))){
- $display.= "<button type='submit' name='save_dhcp'>".msgPool::saveButton()."</button> ";
- }
- $display.= "<button type='submit' name='cancel_dhcp'>".msgPool::cancelButton()."</button>";
- $display.= "</div>";
-
-
- /* Show main page */
- return $display;
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
-
- /* Skip here if do not have write permissions here
- Still executed at bottom - dhcpPlugin::save_object();
- */
- if(isset($_POST['dhcp_subnet_posted']) && preg_match("/w/",$this->parent->getacl(""))){
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- }
- if (isset($_POST['dhcp_netmask'])){
- $this->dhcpNetMask= validate(get_post('dhcp_netmask'));
- }
- if (isset($_POST['use_range'])){
- $this->use_range= TRUE;
- $this->range_start= validate(get_post('range_start'));
- $this->range_stop= validate(get_post('range_stop'));
- } else {
- $this->use_range= FALSE;
- }
-
- /* Move range to internal variable */
- $this->dhcpRange= $this->range_start." ".$this->range_stop;
+
+ /* Show main page */
+ return $display;
}
- dhcpPlugin::save_object();
- }
- /* Check values */
- function check()
- {
- $message= array();
+ function remove_from_parent()
+ {
+ }
- $cache = $this->parent->dhcpObjectCache;
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= msgPool::required(_("Network address"));
- }
- if ($this->dhcpNetMask == ""){
- $message[]= msgPool::required(_("Netmask"));
+ /* Save data to object */
+ function save_object()
+ {
+
+ /* Skip here if do not have write permissions here
+ Still executed at bottom - dhcpPlugin::save_object();
+ */
+ if(isset($_POST['dhcp_subnet_posted']) && preg_match("/w/",$this->parent->getacl(""))){
+ if (isset($_POST['cn'])){
+ $this->cn= get_post('cn');
+ }
+ if (isset($_POST['dhcp_netmask'])){
+ $this->dhcpNetMask= get_post('dhcp_netmask');
+ }
+ if (isset($_POST['use_range'])){
+ $this->use_range= TRUE;
+ $this->range_start= get_post('range_start');
+ $this->range_stop= get_post('range_stop');
+ } else {
+ $this->use_range= FALSE;
+ }
+
+ /* Move range to internal variable */
+ $this->dhcpRange= $this->range_start." ".$this->range_stop;
+ }
+ 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 = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= msgPool::required(_("Network address"));
+ }
+ if ($this->dhcpNetMask == ""){
+ $message[]= msgPool::required(_("Netmask"));
}
- }
- }
- /* IP's? */
- foreach(array(
- 'dhcpNetMask' => _("Netmask"),
- 'cn' => _("Network address"),
- 'range_start' => _("Range"),
- 'range_stop' => _("Range")) as $attr => $str){
- if ($this->$attr != "" && !tests::is_ip($this->$attr)){
- $message[]= msgPool::invalid($str,"","","192.168.0.23");
- }
- }
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
- /* Check ip range */
- if ($this->use_range){
- if(!tests::is_ip_range($this->range_start,$this->range_stop)){
- $message[]= msgPool::invalid(_("Network range"));
- }
-
- /* Check if range is in the network */
- if (!tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
- !tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
- $message[] = _("'Range' is not inside the configured network.");
- }
- }
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= msgPool::duplicated(_("Name"));
+ break;
+ }
+ }
+ }
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
+ /* IP's? */
+ foreach(array(
+ 'dhcpNetMask' => _("Netmask"),
+ 'cn' => _("Network address"),
+ 'range_start' => _("Range"),
+ 'range_stop' => _("Range")) as $attr => $str){
+ if ($this->$attr != "" && !tests::is_ip($this->$attr)){
+ $message[]= msgPool::invalid($str,"","","192.168.0.23");
+ }
+ }
- return $message;
- }
+ /* Check ip range */
+ if ($this->use_range){
+ if(!tests::is_ip_range($this->range_start,$this->range_stop)){
+ $message[]= msgPool::invalid(_("Network range"));
+ }
+
+ /* Check if range is in the network */
+ if (!tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
+ !tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
+ $message[] = _("'Range' is not inside the configured network.");
+ }
+ }
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+
+ /* Move dn to the result */
+ $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
+ if ($this->use_range && !empty($this->dhcpRange)){
+ $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
+ } else {
+ $this->attrs['dhcpRange']= array();
+ }
- /* Move dn to the result */
- $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
- if ($this->use_range && !empty($this->dhcpRange)){
- $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
- } else {
- $this->attrs['dhcpRange']= array();
+ return ($this->attrs);
}
- return ($this->attrs);
- }
-
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>