Code

Apply patch for #5210
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Sep 2010 08:49:19 +0000 (08:49 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Sep 2010 08:49:19 +0000 (08:49 +0000)
Fix a problem with the deletion of fai classes:
The query weither a class is associated to a profile matched
classes, which contained the name of a to-be-deleted class as a
substring of their own name.
The query was changed in a way that the list of associated classes
is compared exactly with the class to be deleted.

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

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

index 2b3d1a0b5eba2e9e63665109e042aff055990ded..ef27ae6ffa6dd94e7636096702eef274df932789 100644 (file)
@@ -249,17 +249,22 @@ class FAI
 
               /* Check if this Profile uses the source class ($cn)
                */
-              if(preg_match("/".preg_quote($cn, '/')."/",$attrs['FAIclass'])){
-                $attrs['FAIclass'] = preg_replace("/[ ]*".preg_quote($cn, '/')."[ ]*/i"," ",$attrs['FAIclass']);
-                if(empty($attrs['FAIclass'])){
-                  $attrs['FAIclass'] = array();
-                }
-                $ldap->cd($dn['dn']);
-                $ldap->modify($attrs);
-
-                if (!$ldap->success()){
-                  msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
-                }
+              $classlist = split(" ", $attrs['FAIclass']);
+              $new_classlist = "";
+              foreach($classlist as $class){
+                if($class != $cn){
+                  $new_classlist = $new_classlist." ".$class;
+               }
+              } 
+              $attrs['FAIclass'] = $new_classlist;
+              if(empty($attrs['FAIclass'])){
+                $attrs['FAIclass'] = array();
+              }
+              $ldap->cd($dn['dn']);
+              $ldap->modify($attrs);
+              
+              if (!$ldap->success()){
+                msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
               }
             }
           }