Code

Updated multiple remove for departments
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Nov 2008 10:29:58 +0000 (10:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Nov 2008 10:29:58 +0000 (10:29 +0000)
-Do not remove deps twice

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

gosa-core/plugins/admin/departments/class_departmentManagement.inc

index a6118c39866d7910e23000106502e931450b339c..7637f1c38e036cca01def98e5718a382c5cc0c51 100644 (file)
@@ -225,12 +225,23 @@ class departmentManagement extends plugin
     /* Confirmation for deletion has been passed. Users should be deleted. */
     if (isset($_POST['delete_multiple_department_confirm'])){
 
+      /* Do not remove departments that will already be deleted by its parents 
+       */
+      foreach($this->dns as $key => $dn){
+        foreach($this->dns as $key2 => $dn2){
+          if($dn == $dn2) continue;
+          if(preg_match("/".preg_quote($dn,'/')."$/",$dn2)){
+            unset($this->dns[$key2]);
+          }
+        }
+      }
+
       /* Remove user by user and check acls before removeing them */
       foreach($this->dns as $key => $dn){
         $acl = $this->ui->get_permissions($dn,"department/department");
         if (preg_match('/d/', $acl)){
 
-          /* Delete request is permitted, perform LDAP action */
+         /* Delete request is permitted, perform LDAP action */
           $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $dn,"department");
           $this->deptabs->set_acl_base();
           $this->deptabs->delete ();