From f6042897cb1315406bf7346dd921ccabd9f07a6d Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 27 Jul 2010 09:17:41 +0000 Subject: [PATCH] Updated several service dialogs, fixed typos, string, html, post handling and more. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19154 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/dhcp/class_dhcpSubnet.inc | 330 +++++++++--------- 1 file changed, 165 insertions(+), 165 deletions(-) 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 da1a430ef..29e1f5212 100644 --- a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc @@ -1,204 +1,204 @@ 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.= "
"; + if(preg_match("/w/",$this->parent->getacl(""))){ + $display.= " "; + } + $display.= ""; + $display.= "
"; - /* Add footer */ - $display.= "
"; - if(preg_match("/w/",$this->parent->getacl(""))){ - $display.= " "; - } - $display.= ""; - $display.= "
"; - - - /* 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: ?> -- 2.30.2