Code

Updated category deletion in group->apps
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Sep 2007 06:31:22 +0000 (06:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Sep 2007 06:31:22 +0000 (06:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7416 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupApplication.inc

index a75676068764540500928df38e508e1372166ada..029f959321ab222c2ca48320b032314b609a3b85 100644 (file)
@@ -436,6 +436,7 @@ class appgroup extends plugin
 
     $this->diffAppsInReleases();
     $only_once = false;
+    $once =FALSE;
     foreach($_POST as $name => $value){
       
       if((preg_match("/AddSep_/",$name))&&(!$only_once)){
@@ -474,18 +475,34 @@ class appgroup extends plugin
           }
         }
       }
-  
-      if(preg_match("/DelCat_/",$name)){
-        $n = preg_replace("/DelCat_/","",$name);
-        $app = base64_decode( preg_replace("/_.*$/","",$n));
-        foreach($this->Categories as $key =>  $cat){
-          if($cat == $app){
-            foreach($this->Categories as $p => $n){
-              if(preg_match("/^".$key."\/.*/",$p)){
-                unset($this->Categories[$p]);    
+
+      if(preg_match("/DelCat_/",$name) && !$once){
+        $once =TRUE;
+        $cat = preg_replace("/DelCat_/","",$name);
+        $cat = trim(base64_decode( preg_replace("/_.*$/","",$cat)));
+
+        $free_apps = array();
+
+        if(isset($this->gosaMemberApplication[$cat]) && is_array($this->gosaMemberApplication[$cat])){
+          foreach($this->gosaMemberApplication[$cat] as $app){
+            $free_apps[] = $app['App'];
+          }
+          @unset($this->gosaMemberApplication[$cat]);
+          @unset($this->Categories[$cat]);
+          foreach($this->Categories as $key => $name){
+            if(preg_match("/^".$cat."\/.*/",$key)){
+              foreach($this->gosaMemberApplication[$key] as $app){
+                $free_apps[] = $app['App'];
               }
+              @unset($this->gosaMemberApplication[$key]);
+              @unset($this->Categories[$key]);
             }
-            unset($this->Categories[$key]);
+          }
+        }
+        foreach($free_apps as $app){
+          if(isset($this->used_apps[$app])){
+            unset($this->used_apps[$app]);
           }
         }
       }