Code

Reset array of dns to delete, before adding new dns
[gosa.git] / gosa-plugins / goto / admin / devices / class_deviceGeneric.inc
index eed97d25ddaf077a71951a97712eb1ac39d2ae02..099788aad5a4abc1fb1cc5e6a981da7e1ad0893d 100644 (file)
@@ -26,9 +26,8 @@ class deviceGeneric extends plugin
     $this->is_account = TRUE;
 
     $this->types= array("camera" => _("Digital camera"),
-                        "harddisk" => _("Harddisk"),
-                        "stick" => _("USB stick"),
-                        "cd" => _("CD/DVD drive"),);
+                        "disc" => _("USB stick"),
+                        "cdrom" => _("CD/DVD drive"),);
     asort($this->types);
 
     /* Set class values */
@@ -84,29 +83,29 @@ class deviceGeneric extends plugin
     $message = plugin::check();
 
     if(empty($this->cn)||(preg_match("/[^a-z0-9]/i",$this->cn))){
-      $message[]=_("Please specify a valid name. Only 0-9 a-Z is allowed.");
+      $message[]= msgPool::invalid(_("Name"),$this->cn,"/^[a-z0-9]*$/i");
     }
     if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){
-      $message[]=_("Invalid character in description. Please specify a valid description.");
+      $message[]= msgPool::invalid(_("Description"),$this->cn,"/^[a-z0-9!\"?.,;:-_\(\) ]*$/i");
     }
 
     /* Skip serial check if vendor and product id are given */
     if(preg_match("/^\s+$/i",$this->dev_id)){
-      $message[]=_("Please specify a valid iSerial.");
+      $message[]= msgPool::invalid(_("iSerial"),"","01234");
     }
     if(empty($this->serial) || !$this->is_2byteHex($this->serial)){
-      $message[]=_("Please specify a valid vendor ID. (2 byte hex like '0xFFFF')");
+      $message[]= msgPool::invalid(_("Serial"),"","","0x1234");
     }
     if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){
-      $message[]=_("Please specify a valid product ID. (2 byte hex like '0xFFFF')");
+      $message[]= msgPool::invalid(_("Vendor ID"),"","","0x1234");
     }
-   
+  
     /* Check if entry already exists */ 
-    if($this->cn != $this->orig_cn){
+    if($this->cn != $this->orig_cn || $this->dn == "new"){
       $ldap = $this->config->get_ldap_link();
       $ldap->search("(&(objectClass=gotoDevice)(cn=".$this->cn."*))",array("cn"));
       if($ldap->count()){
-        $message[]=_("An Entry with this name already exists.");
+        $message[]= msgPool::duplicated(_("Name"));
       }
     }
 
@@ -143,19 +142,13 @@ class deviceGeneric extends plugin
 
     $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=".$this->dn."))",array("cn","gotoHotplugDeviceDN"));
     $skip = FALSE;
-    $str ="";
-    $cnt = 3;
-    while($cnt && $attrs = $ldap->fetch()){
+    $obj = array();
+    while($attrs = $ldap->fetch()){
+      $obj[$ldap->getDN()]= $attrs['cn'][0];
       $skip =TRUE;
-      $str .= $attrs['cn'][0].", ";
-      $cnt --;
     }
     if($skip){
-      $str  = preg_replace("/, $/","",$str);
-      if($cnt == 0){
-        $str .= "...";
-      }
-      print_red(sprintf(_("Can't remove the device '%s' it is still in use be this user(s) : %s"),$this->cn,$str));
+      msg_dialog::display(_("Error"), msgPool::stillInUse(_("Device"), $obj), INFO_DIALOG);
     }else{
       $ldap->rmdir_recursive($this->dn);
     }