Code

Updated hotplug new dialog.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Aug 2006 06:10:39 +0000 (06:10 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Aug 2006 06:10:39 +0000 (06:10 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4476 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/environment/class_hotplugDialog.inc
plugins/personal/environment/hotplugDialogNew.tpl

index dbb082141e3ea561f3e3306cfb14f04b2019527a..3a1ca5e84aecc761daa85850207e776c9baa39f3 100644 (file)
@@ -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']))){
index 9704ebeb63beabe6bece096edb529bb669271fb5..bd5d255311e14783abcd8182bbca4ca0f8b40ae1 100644 (file)
@@ -14,7 +14,7 @@
                        </td>
                </tr>
                <tr>
-                       <td><LABEL for="HOT_description">{t}Description{/t}</LABEL>{$must}
+                       <td><LABEL for="HOT_description">{t}Description{/t}</LABEL>
                        </td>
                        <td>
                                <input type="text" size=40 value="{$HOT_description}" name="HOT_description" id="HOT_description">
    </td>
    <td style="vertical-align:top">
        <table summary="">
-               <tr>
-                       <td><LABEL for="HOT_vendor">{t}Vendor ID{/t}</LABEL>{$must}
-                       </td>
-                       <td>
-                               <input type="text" value="{$HOT_vendor}" name="HOT_vendor" id="HOT_vendor">
-                       </td>
-               </tr>
-               <tr>
-                       <td><LABEL for="HOT_id">{t}Device ID{/t}</LABEL>{$must}
-                       </td>
-                       <td>
-                               <input type="text" value="{$HOT_id}" name="HOT_id" id="HOT_id">
-                       </td>
-                       <td cols="2">&nbsp;</td>
-               </tr>
-               <tr>
-                       <td><LABEL for="HOT_produkt">{t}Product ID{/t}</LABEL>{$must}
-                       </td>
-                       <td>
-                               <input type="text" value="{$HOT_produkt}" name="HOT_produkt" id="HOT_produkt">
-                       </td>
-               </tr>
+                <tr>
+                        <td><LABEL for="HOT_id">{t}Serial number{/t}&nbsp;{t}(iSerial){/t}</LABEL>
+                        </td>
+                        <td>
+                                <input type="text" value="{$HOT_id}" name="HOT_id" id="HOT_id">
+                        </td>
+                        <td colspan="2">&nbsp;</td>
+                </tr>
+                <tr>
+                        <td><LABEL for="HOT_vendor">{t}Vendor-ID{/t}&nbsp;{t}(idVendor){/t}</LABEL>
+                        </td>
+                        <td>
+                                <input type="text" value="{$HOT_vendor}" name="HOT_vendor" id="HOT_vendor">
+                        </td>
+                </tr>
+                <tr>
+                        <td><LABEL for="HOT_produkt">{t}Product-ID{/t}&nbsp;{t}(idProduct){/t}</LABEL>
+                        </td>
+                        <td>
+                                <input type="text" value="{$HOT_produkt}" name="HOT_produkt" id="HOT_produkt">
+                        </td>
+                </tr>
        </table>
 </table>
        <p class="seperator">&nbsp;</p>