Code

Updated user plugin to release manager assignment
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 25 Feb 2010 09:38:19 +0000 (09:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 25 Feb 2010 09:38:19 +0000 (09:38 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15709 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 94a9ae722ae40bbd336f46bfb1b5ca29359ac061..10c4eba291c388e4c8e4d35f1fb15fad51627faf 100644 (file)
@@ -757,6 +757,23 @@ class user extends plugin
       $og->save ();
     }
 
+    // Update 'manager' attributes from gosaDepartment and inetOrgPerson
+    $filter = "(&(objectClass=inetOrgPerson)(manager=".LDAP::prepare4filter($this->dn)."))";
+    $ocs = $ldap->get_objectclasses();
+    if(isset($ocs['gosaDepartment']['MAY']) && in_array('manager', $ocs['gosaDepartment']['MAY'])){
+      $filter = "(|".$filter."(&(objectClass=gosaDepartment)(manager=".LDAP::prepare4filter($this->dn).")))";
+    }
+    $leaf_deps=  get_list($filter,array("all"),$this->config->current['BASE'],
+        array("manager","dn","objectClass"),GL_SUBSEARCH | GL_NO_ACL_CHECK);
+    foreach($leaf_deps as $entry){
+      $update = array('manager' => array());
+      $ldap->cd($entry['dn']);
+      $ldap->modify($update);
+      if(!$ldap->success()){
+        trigger_error(sprintf("Failed to update manager for '%s', error was '%s'", $entry['dn'], $ldap->get_error()));
+      }
+    }
+
     /* Delete references to roles */
     $ldap->cd ($this->config->current['BASE']);
     $ldap->search ("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter($this->dn)."))", array("cn"));