Code

Updated category removement in group->apps
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Sep 2007 06:57:13 +0000 (06:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Sep 2007 06:57:13 +0000 (06:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7418 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupApplication.inc

index fcc9d391c504be205c2699e4a6a0fc774720434f..bd15fa0c44dc2535c58c698bd82b8fae9d204b7d 100644 (file)
@@ -511,18 +511,32 @@ class appgroup extends plugin
           }
         }
 
-        /* Remove category entry */
-        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) && !$only_once){
+          $only_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]);
             }
           }
         }