Code

Allow duplicated class names of different types
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Nov 2009 10:29:22 +0000 (10:29 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Nov 2009 10:29:22 +0000 (10:29 +0000)
- When adding a new class with a name that already
exists, but has a different type (e.g. is stored
in another RDN), do not show a warning.
(Trac: #3200)
- Don't search for objects with FAIstate removed

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

trunk/gosa-plugins/fai/admin/fai/class_askClassName.inc

index de302bd2ad75a5fe0dfd775d99560c2a6ee72483..3d3beb2ebcf9aa07b77f130998eb6db96a117042 100644 (file)
@@ -151,9 +151,19 @@ class askClassName extends plugin
     }
     else {
       /* Check if the given ClassName is already used in another administrative unit */
+      switch($this->objectClass) {
+        case "FAIpartitionTable":  $rdn = get_ou('faiPartitionRDN'); break;
+        case "FAIpackageList"   :  $rdn = get_ou('faiPackageRDN'); break;
+        case "FAIscript"        :  $rdn = get_ou('faiScriptRDN'); break;
+        case "FAIvariable"      :  $rdn = get_ou('faiVariableRDN'); break;
+        case "FAIhook"          :  $rdn = get_ou('faiHookRDN'); break;
+        case "FAIprofile"       :  $rdn = get_ou('faiProfileRDN'); break;
+        case "FAItemplate"      :  $rdn = get_ou('faiTemplateRDN'); break;
+      }
       $ldap= $this->config->get_ldap_link();
-      $filter = "(cn=".$this->ClassName.")";
-      $ldap->cd($this->parent->fai_release);
+      $filter = "(&(cn=".$this->ClassName.")(!(FAIstate=|removed)))";
+      $base = $rdn . $this->parent->fai_release;
+      $ldap->cd($base);
       $ldap->search($filter, array("dn","gosaUnitTag"));
 
       if ($ldap->count() > 0) {