Code

Some style changes
[gosa.git] / plugins / admin / groups / class_groupApplication.inc
index fd4da27d2ebbb7fcd3b851d50e51852269733f16..c899f0bff70e22847d848ea9c76660fc57f26132 100644 (file)
@@ -275,12 +275,12 @@ class appgroup extends plugin
     if((isset($_GET['act']))&&($_GET['act']=="depopen")){
       $dep = base64_decode($_GET['depid']);  
       if(isset($this->config->idepartments[$dep])){
-        $this->curbase = $dep;
+        $this->curbase =$dep;
       }
     }
 
     if((isset($_GET['act']))&&($_GET['act']=="open")){
-      $this->curCatDir = $_GET['id'];
+      $this->curCatDir = base64_decode($_GET['id']);
     }
 
     /* Do we need to flip is_account state? */
@@ -313,7 +313,7 @@ class appgroup extends plugin
   
     
     if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
-      
+
       if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){
         print_red(_("Invalid character in category name."));
       }elseif(!in_array($_POST['CatName'],$this->Categories)){ 
@@ -329,36 +329,61 @@ class appgroup extends plugin
 
 
     $this->reload();
+    $only_once = false;
     foreach($_POST as $name => $value){
-      if(preg_match("/AddSep_/",$name)){
-        $this->AddSeperator($value);
+      
+      if((preg_match("/AddSep_/",$name))&&(!$only_once)){
+        $only_once = true;
+        $n = preg_replace("/AddSep_/","",$name);
+        $val= preg_replace("/_.*$/","",$n);
+        $this->AddSeperator($val);
       }
-    
 
-      if(preg_match("/DelApp_/",$name)){
-        $app = $value; 
+      if((preg_match("/DelApp_/",$name))&&(!$only_once)){
+        $only_once = true;
+   
+
+        if(preg_match("/DelApp___SEPARATOR__/",$name)) {
+          $n=  preg_replace("/DelApp___SEPARATOR__/","",$name);
+          $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n);
+        }else{
+          $n = preg_replace("/DelApp_/","",$name);
+          $val= preg_replace("/_.*$/","",$n);
+        }
+
         foreach($this->gosaMemberApplication as $key =>  $cat){
           foreach($cat as $key2 => $app){
-            if($app['App'] == $value){
+            if($app['App'] == $val){
               unset($this->gosaMemberApplication[$key][$key2]);
-              if(isset($this->used_apps[$value])){
-                unset($this->used_apps[$value]);
+              if(isset($this->used_apps[$val])){
+                unset($this->used_apps[$val]);
               }
             }
           }
         }
       }
+  
       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]);    
+              }
+            }
             unset($this->Categories[$key]);
           }
         }
       }
-      if(preg_match("/EdiApp_/",$name)){
+      
+      if((preg_match("/EdiApp_/",$name))&&(!$only_once)){
+
+        $only_once = true;
         $appname = $value;
+        $appname = preg_replace("/EdiApp_/","",$name);  
+        $appname = preg_replace("/_.*$/","",$appname);
         /* We've got the appname, get parameters from ldap */
         $ldap= $this->config->get_ldap_link();
         $ldap->cd($this->config->current['BASE']);
@@ -406,7 +431,6 @@ class appgroup extends plugin
       }
     }
     $this->reload();
-
     /* Add group with post */
     if((isset($_GET['act']))&&($_GET['act']=="add")){
       $this->used_apps[$_GET['id']]= $_GET['id'];
@@ -548,7 +572,7 @@ class appgroup extends plugin
       for($i = 0 ; $i < ($cnt -1 ) ; $i++){
         $bbk .= $tmp[$i];
       }
-      $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>"&nbsp;","attach"=>"style='border-right:0px;'")));
+      $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),"..")),array("string"=>"&nbsp;","attach"=>"style='border-right:0px;'")));
     }
 
     $this->GetSubdirs($this->curCatDir);
@@ -562,7 +586,7 @@ class appgroup extends plugin
 
     /* Append entries */
 
-    $separator ="<hr height=1  size=1></hr>"; 
+    $separator ="<hr size=1>"; 
 
     $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";