Code

Add type attribute to CopyPasteVars (#5601)
[gosa.git] / trunk / gosa-plugins / goto / admin / devices / class_deviceGeneric.inc
index d4d5043cae7c2040b2abd65134ad9782fd7fc7ec..9ee0295019e24998f9e49b1adce88a71071a0f62 100644 (file)
@@ -18,7 +18,7 @@ class deviceGeneric extends plugin
   public $attributes      = array("cn","description","devID","serial","vendor", "type");
   public $objectclasses   = array("top","gotoDevice");
 
-  public $CopyPasteVars   = array("orig_cn","description","vendor","devID","serial","base");
+  public $CopyPasteVars   = array("orig_cn","description","vendor","devID","serial","base", "type");
 
   public function deviceGeneric(&$config,$dn = NULL)
   {
@@ -87,10 +87,10 @@ class deviceGeneric extends plugin
     $message = plugin::check();
 
     if($this->cn == "" ||(preg_match("/[^a-z0-9]/i",$this->cn))){
-      $message[]= msgPool::invalid(_("Name"),$this->cn,"/^[a-z0-9]*$/i");
+      $message[]= msgPool::invalid(_("Device name"),$this->cn,"/^[a-z0-9]*$/i");
     }
     if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){
-      $message[]= msgPool::invalid(_("Description"),$this->cn,"/^[a-z0-9!\"?.,;:-_\(\) ]*$/i");
+      $message[]= msgPool::invalid(_("Description"),$this->description,"/^[a-z0-9!\"?.,;:-_\(\) ]*$/i");
     }
 
     /* Skip serial check if vendor and product id are given */
@@ -126,6 +126,21 @@ class deviceGeneric extends plugin
       $message[] = msgPool::permMove();
     }
 
+    if ($this->cn != $this->orig_cn || $this->base != $this->orig_base) { 
+
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=".LDAP::prepare4filter($this->orig_dn)."))",
+                    array("cn","uid"));
+      $obj = array();
+      while($attrs = $ldap->fetch()){
+        $obj[$ldap->getDN()]= $attrs['cn'][0];
+      }
+      if ($obj != array()) {
+        $message[] = msgPool::stillInUse(_("Device"), $obj);
+      }
+    }
+     
     return($message);
   }