Code

Updated plugin class
[gosa.git] / gosa-core / include / class_plugin.inc
index 6bef2744e5f3902ae0f940e7667516d17822b4f0..e854884a4e81f9c3c10b265f647f660e6617f75c 100644 (file)
@@ -148,11 +148,13 @@ class plugin
     // Ensure that we've a valid acl_category set.
     if(empty($this->acl_category)){
       $tmp = $this->plInfo();
-      $c = key($tmp['plCategory']);
-      if(is_numeric($c)){
-        $c = $tmp['plCategory'][0];
+      if (isset($tmp['plCategory'])) {
+        $c = key($tmp['plCategory']);
+        if(is_numeric($c)){
+          $c = $tmp['plCategory'][0];
+        }
+        $this->acl_category = $c."/";
       }
-      $this->acl_category = $c."/";
     }
 
     /* Handle new accounts, don't read information from LDAP */
@@ -1035,6 +1037,23 @@ class plugin
         $role->save();
       }
     }
+
+    // Update 'manager' attributes from gosaDepartment and inetOrgPerson 
+    $filter = "(&(objectClass=inetOrgPerson)(manager=".LDAP::prepare4filter(LDAP::fix($src_dn))."))";
+    $ocs = $ldap->get_objectclasses();
+    if(isset($ocs['gosaDepartment']['MAY']) && in_array('manager', $ocs['inetOrgPerson']['MAY'])){
+      $filter = "(|".$filter."(&(objectClass=gosaDepartment)(manager=".LDAP::prepare4filter(LDAP::fix($src_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' => $dst_dn);
+      $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()));
+      }
+    }
  
     /* Check if there are gosa departments moved. 
        If there were deps moved, the force reload of config->deps.