Code

Updated class user
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 08:15:47 +0000 (08:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 08:15:47 +0000 (08:15 +0000)
-When a user is removed, remove it from roles too.

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

gosa-core/plugins/personal/generic/class_user.inc

index 95b0960a776688278cf228970058fa87b9e66f37..30c50e47516dade4e0a802b400119bae7851dbf1 100644 (file)
@@ -744,6 +744,19 @@ class user extends plugin
       $og->save ();
     }
 
+    /* Delete references to roles */
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search ("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+    while ($ldap->fetch()){
+      $role= new roleGeneric($this->config, $ldap->getDN());
+      $key = array_search($this->dn,$role->roleOccupant);
+      if($key !== FALSE){
+        unset($role->roleOccupant[$key]);
+        $role->reload();
+        $role->save ();
+      }
+    }
+
     /* If needed, let the password method do some cleanup */
     $tmp = new passwordMethod($this->config);
     $available = $tmp->get_available_methods();
@@ -863,6 +876,7 @@ class user extends plugin
     /* Only force save of changes .... 
        If this attributes aren't changed, avoid saving.
      */
+  
     if($this->gender=="0") $this->gender ="";
     if($this->preferredLanguage=="0") $this->preferredLanguage ="";