Code

Applied LHM commit #1042 (r19542)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Sep 2010 07:30:34 +0000 (07:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 8 Sep 2010 07:30:34 +0000 (07:30 +0000)
-Ensures that FAIprofiles wont be messed up while removing FAIclasses such as partition, scripts, aso.
 If a script named 'test' was removed and a profile contained test123 too, it now contained just '123'.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19555 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index deddde2ba2a964175ba94e8b9ce33ff8edc60f7b..e5d40a9808a9fbccc1222b2fe359d514b75a3807 100644 (file)
@@ -271,17 +271,21 @@ 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'])){
+              $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()){
+              }
+              $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()));
-                }
               }
             }
           }