Code

When moving or renaming devices, check whether they are in use by a
authorwolffc <wolffc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 16 Sep 2010 14:35:53 +0000 (14:35 +0000)
committerwolffc <wolffc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 16 Sep 2010 14:35:53 +0000 (14:35 +0000)
user, group or object group. If so, display an error message stating
the user. As the reference is not being updated in the user object,
the device would get deleted from the user next time when they are
saved.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@19720 594d385d-05f5-0310-b6e9-bd551577e9d8

trunk/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc

index d4d5043cae7c2040b2abd65134ad9782fd7fc7ec..cd83d097eef8294095971a63e1fbc34e89feb6ae 100644 (file)
@@ -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);
   }