From 2b7cd41a951cfed6c2900de6c9bbc8b21be7169c Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 11 Aug 2006 06:10:39 +0000 Subject: [PATCH] Updated hotplug new dialog. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4476 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../environment/class_hotplugDialog.inc | 42 +++++++++++------ .../personal/environment/hotplugDialogNew.tpl | 46 +++++++++---------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/plugins/personal/environment/class_hotplugDialog.inc b/plugins/personal/environment/class_hotplugDialog.inc index dbb082141..3a1ca5e84 100644 --- a/plugins/personal/environment/class_hotplugDialog.inc +++ b/plugins/personal/environment/class_hotplugDialog.inc @@ -92,18 +92,29 @@ class hotplugDialog extends plugin function save_object() { if(isset($_POST['dialogissubmitted'])){ + plugin::save_object(); foreach($this->attributes as $s_attr){ if(isset($_POST[$s_attr])){ - $this->$s_attr = stripslashes($_POST[$s_attr]); + if(in_array($s_attr,array("HOT_produkt","HOT_vendor"))){ + $this->$s_attr = strtolower(stripslashes($_POST[$s_attr])); + }else{ + $this->$s_attr = stripslashes($_POST[$s_attr]); + } }else{ $this->$s_attr = false; } } - plugin::save_object(); } } + /* check if given str in like this 0xffff*/ + function is_2byteHex($str) + { + return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9][a-f0-9][a-f0-9][a-f0-9]/i",$str); + } + + /* Check supplied data */ function check() { @@ -111,27 +122,28 @@ class hotplugDialog extends plugin $message= plugin::check(); if(!$this->use_existing){ - if((empty($this->HOT_name))||(preg_match("/[^a-z0-9]/i",$this->HOT_name))){ + + if(empty($this->HOT_name)||(preg_match("/[^a-z0-9]/i",$this->HOT_name))){ $message[]=_("Please specify a valid name. Only 0-9 a-Z is allowed."); } - if((empty($this->HOT_description))||(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->HOT_description))){ + if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->HOT_description)){ $message[]=_("Invalid character in description. Please specify a valid description."); } - if((empty($this->HOT_id))||(preg_match("/[\|]/i",$this->HOT_id))){ + + if(preg_match("/[\|]/i",$this->HOT_id)){ $message[]=_("Please specify a valid id."); } - if((empty($this->HOT_vendor))||(preg_match("/[\|]/i",$this->HOT_vendor))){ - $message[]=_("Please specify a valid id."); + if(!$this->is_2byteHex($this->HOT_vendor)){ + $message[]=_("Please specify a valid vendor id. (2 byte hex like '0xFFFF')"); } - if((empty($this->HOT_produkt))||(preg_match("/[\|]/i",$this->HOT_produkt))){ - $message[]=_("Please specify a valid id."); + if(!$this->is_2byteHex($this->HOT_produkt)){ + $message[]=_("Please specify a valid product id. (2 byte hex like '0xFFFF')"); + } + $ldap = $this->config->get_ldap_link(); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDevice=".$this->HOT_name."*))",array("gotoHotplugDevice")); + if($ldap->count()){ + $message[]=_("An Entry with this name already exists."); } - - $ldap = $this->config->get_ldap_link(); - $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDevice=".$this->HOT_name."*))",array("gotoHotplugDevice")); - if($ldap->count()){ - $message[]=_("An Entry with this name already exists."); - } }else{ if((!isset($_POST['hotplugName']))||(empty($_POST['hotplugName']))){ diff --git a/plugins/personal/environment/hotplugDialogNew.tpl b/plugins/personal/environment/hotplugDialogNew.tpl index 9704ebeb6..bd5d25531 100644 --- a/plugins/personal/environment/hotplugDialogNew.tpl +++ b/plugins/personal/environment/hotplugDialogNew.tpl @@ -14,7 +14,7 @@ - {$must} + @@ -24,28 +24,28 @@ - - - - - - - - - - - - - + + + + + + + + + + + + +
{$must} - - -
{$must} - - -  
{$must} - - -
+ + +  
+ + +
+ + +

 

-- 2.30.2