From feacc1ba41c5f7a0dc2a78488819cfda6710c7bd Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 27 Jul 2010 09:17:19 +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@19146 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/dhcp/class_dhcpNetwork.inc | 358 +++++++++--------- 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc index be8f1f57f..9c1fcf8c7 100644 --- a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc @@ -1,214 +1,214 @@ is_account= TRUE; - } - - function execute() - { - plugin::execute(); - - $acl_writeable = preg_match("/w/",$this->parent->getacl("")); - - /* Check for iteraction */ - if ($acl_writeable && isset($_POST['add_dns']) && $_POST['addserver'] != ""){ - if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){ - msg_dialog::display(_("Error"), msgPool::invalid(_("Name"), - htmlentities(get_post('addserver')),"/[0-9a-z.-]/"), ERROR_DIALOG); - } else { - $servers= array(); - if($this->options->exists('domain-name-servers')){ - foreach(explode(",", $this->options->get('domain-name-servers')) as $val){ - $servers[$val]= $val; - } - } - $servers[get_post('addserver')]= get_post('addserver'); + /* Used attributes */ + var $options= null; + var $statements= null; + + /* attribute list for save action */ + var $attributes= array(); + var $objectclasses= array(); + + function dhcpNetwork() + { + /* This is always an account */ + $this->is_account= TRUE; + } - $tmp= ""; - foreach($servers as $val){ - $tmp.= $val.","; + function execute() + { + plugin::execute(); + + $acl_writeable = preg_match("/w/",$this->parent->getacl("")); + + /* Check for iteraction */ + if ($acl_writeable && isset($_POST['add_dns']) && $_POST['addserver'] != ""){ + if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){ + msg_dialog::display(_("Error"), msgPool::invalid(_("Name"), + htmlentities(get_post('addserver')),"/[0-9a-z.-]/"), ERROR_DIALOG); + } else { + $servers= array(); + if($this->options->exists('domain-name-servers')){ + foreach(explode(",", $this->options->get('domain-name-servers')) as $val){ + $servers[$val]= $val; + } + } + $servers[get_post('addserver')]= get_post('addserver'); + + $tmp= ""; + foreach($servers as $val){ + $tmp.= $val.","; + } + $this->options->removeAll('domain-name-servers'); + $this->options->set('domain-name-servers',preg_replace('/,$/', '', $tmp)); + } } - $this->options->removeAll('domain-name-servers'); - $this->options->set('domain-name-servers',preg_replace('/,$/', '', $tmp)); - } - } - if ($acl_writeable && isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){ - $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '', - $this->options->get('domain-name-servers')); - $tmp= trim(preg_replace("/(\s*)?,(\s*)?$/", '', $tmp),","); + if ($acl_writeable && isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){ + $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '', + $this->options->get('domain-name-servers')); + $tmp= trim(preg_replace("/(\s*)?,(\s*)?$/", '', $tmp),","); - if ($tmp != ""){ - $this->options->set('domain-name-servers', $tmp); - } else { - $this->options->remove('domain-name-servers'); - } - } + if ($tmp != ""){ + $this->options->set('domain-name-servers', $tmp); + } else { + $this->options->remove('domain-name-servers'); + } + } - /* Show main page */ - $smarty= get_smarty(); + /* Show main page */ + $smarty= get_smarty(); - /* Assign ACLs */ - $smarty->assign("acl",$this->parent->getacl("")); + /* Assign ACLs */ + $smarty->assign("acl",$this->parent->getacl("")); - /* - * Assemble options - */ + /* + * Assemble options + */ - /* Router */ - $smarty->assign("routers", $this->options->get('routers')); + /* Router */ + $smarty->assign("routers", set_post($this->options->get('routers'))); - /* DNS */ - $smarty->assign("domain",$this->options->get('domain-name')); + /* DNS */ + $smarty->assign("domain", set_post($this->options->get('domain-name'))); - if($this->options->exists('domain-name-servers')){ - $servers= array(); - foreach(explode(",", $this->options->get('domain-name-servers')) as $val){ - $servers[$val]= $val; - } - $smarty->assign("dnsservers", $servers); - } else { - $smarty->assign("dnsservers", array()); - } + if($this->options->exists('domain-name-servers')){ + $servers= array(); + foreach(explode(",", $this->options->get('domain-name-servers')) as $val){ + $servers[$val]= $val; + } + $smarty->assign("dnsservers", set_post($servers)); + } else { + $smarty->assign("dnsservers", array()); + } - /* Netmask / Broadcast */ - if ($this->options->exists('subnet-mask')){ - $this->options->set('subnet-mask',normalize_netmask($this->options->get('subnet-mask'))); - } - $smarty->assign("subnet_mask", $this->options->get('subnet-mask')); - $smarty->assign("broadcast_address", $this->options->get('broadcast-address')); - - /* Boot stuff */ - $smarty->assign("filename", $this->statements->get('filename')); - $smarty->assign("nextserver", $this->statements->get('next-server')); - - /* Set flags */ - $smarty->assign("autohost", ""); - if ($this->statements->exists('get-lease-hostnames')){ - if (preg_match('/^(true|on|yes)$/', $this->statements->get('get-lease-hostnames'))){ - $smarty->assign("autohost", "checked"); - } - } - $smarty->assign("autohostdecl", ""); - if ($this->statements->exists('use-host-decl-names')){ - if (preg_match('/^(true|on|yes)$/', $this->statements->get('use-host-decl-names'))){ - $smarty->assign("autohostdecl", "checked"); - } - } + /* Netmask / Broadcast */ + if ($this->options->exists('subnet-mask')){ + $this->options->set('subnet-mask',normalize_netmask($this->options->get('subnet-mask'))); + } + $smarty->assign("subnet_mask", set_post($this->options->get('subnet-mask'))); + $smarty->assign("broadcast_address",set_post($this->options->get('broadcast-address'))); + + /* Boot stuff */ + $smarty->assign("filename", set_post($this->statements->get('filename'))); + $smarty->assign("nextserver", set_post($this->statements->get('next-server'))); + + /* Set flags */ + $smarty->assign("autohost", ""); + if ($this->statements->exists('get-lease-hostnames')){ + if (preg_match('/^(true|on|yes)$/', $this->statements->get('get-lease-hostnames'))){ + $smarty->assign("autohost", "checked"); + } + } + $smarty->assign("autohostdecl", ""); + if ($this->statements->exists('use-host-decl-names')){ + if (preg_match('/^(true|on|yes)$/', $this->statements->get('use-host-decl-names'))){ + $smarty->assign("autohostdecl", "checked"); + } + } - return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__))); - } + return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__))); + } - function remove_from_parent() - { - } + function remove_from_parent() + { + } - /* Save data to object */ - function save_object() - { - /* Only save, if we are "active" */ - if (isset($_POST['routers']) && preg_match("/w/",$this->parent->getacl(""))){ + /* Save data to object */ + function save_object() + { + /* Only save, if we are "active" */ + if (isset($_POST['routers']) && preg_match("/w/",$this->parent->getacl(""))){ + + /* + * Assemble options + */ + + /* Options */ + foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask", + "broadcast-address" => "broadcast_address") as $key => $val){ + if ($_POST["$val"] == ''){ + $this->options->remove($key); + } else { + $this->options->set($key,get_post($val)); + } + } + + /* Statements */ + foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){ + if ($_POST["$val"] == ''){ + $this->statements->removeAll($key); + } else { + + /* Only quote filename values */ + if(in_array($key,array("filename"))){ + $this->statements->set($key,'"'.trim(get_post($val),"\"").'"'); + }else{ + $this->statements->set($key,get_post($val)); + } + } + } + + /* Flags */ + if (isset ($_POST['autohost'])){ + $this->statements->set('get-lease-hostnames',"true"); + } else { + $this->statements->removeAll('get-lease-hostnames'); + } + if (isset ($_POST['autohostdecl'])){ + $this->statements->set('use-host-decl-names', "on"); + } else { + $this->statements->removeAll('use-host-decl-names'); + } + } + } - /* - * Assemble options - */ - /* Options */ - foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask", - "broadcast-address" => "broadcast_address") as $key => $val){ - if ($_POST["$val"] == ''){ - $this->options->remove($key); - } else { - $this->options->set($key,get_post($val)); - } - } + /* Check values */ + function check() + { + $message= array(); - /* Statements */ - foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){ - if ($_POST["$val"] == ''){ - $this->statements->removeAll($key); - } else { - - /* Only quote filename values */ - if(in_array($key,array("filename"))){ - $this->statements->set($key,'"'.trim(get_post($val),"\"").'"'); - }else{ - $this->statements->set($key,get_post($val)); - } + /* Check netmask and broadcast */ + foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){ + if (!$this->options->exists("$key")){ + continue; + } + if (!tests::is_ip($this->options->get($key))){ + $message[]= sprintf(_("Error in definition of '%s'!"), $typ); + } } - } - - /* Flags */ - if (isset ($_POST['autohost'])){ - $this->statements->set('get-lease-hostnames',"true"); - } else { - $this->statements->removeAll('get-lease-hostnames'); - } - if (isset ($_POST['autohostdecl'])){ - $this->statements->set('use-host-decl-names', "on"); - } else { - $this->statements->removeAll('use-host-decl-names'); - } + return $message; } - } - - - /* Check values */ - function check() - { - $message= array(); - - /* Check netmask and broadcast */ - foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){ - if (!$this->options->exists("$key")){ - continue; - } - if (!tests::is_ip($this->options->get($key))){ - $message[]= sprintf(_("Error in definition of '%s'!"), $typ); - } - } - return $message; - } - /* Save to LDAP */ - function save() - { - } - + /* Save to LDAP */ + function save() + { + } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> -- 2.30.2