Code

Fixed acls
[gosa.git] / plugins / admin / groups / class_groupApplication.inc
index d45a62638e6bf6b26de1d91c19e214ea2cc076e0..8166af28ccfba2cefc2b37966d609bde1f31baa3 100644 (file)
@@ -24,20 +24,47 @@ class appgroup extends plugin
   var $curCatDepth              =0;         //
 
   /* attribute list for save action */
-  var $attributes               = array("gosaMemberApplication");
+  var $attributes               = array("gosaMemberApplication","gosaApplicationParameter");
   var $objectclasses            = array("gosaApplicationGroup");
 
-  var $Release                  = "/";
-  var $InitialRelease           = "/";
+  var $FAIrelease               = "/";
+  var $InitialFAIrelease           = "/";
   var $Releases                 = array();
   var $enableReleaseManagement  = false;
 
   var $AllAppsForRelease        = array();
   var $AllAppsForReleaseParameter = array();
 
-  function appgroup ($config, $dn= NULL)
+  var $CopyPasteVars            = array("Categories");
+  var $gosaApplicationParameter ;
+
+
+  function appgroup ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+   
+    /* prepare group app for release management */ 
+    $tmp = search_config($config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      $this->enableReleaseManagement = true;
+      $this->objectclasses [] = "FAIreleaseTag";
+      $this->attributes[] =  "FAIrelease";
+    }
+
+    plugin::plugin ($config, $dn, $parent);
+
+    /* In some case of old applikations with old release tag saving, we 
+        must reassign is_account state.
+       (Or if release management wasn't activated before creating this app) */
+    if($this->enableReleaseManagement){
+  
+      /* Release management is activated && this is a valid group app account,
+          but no release class was found, so activate is_account flag  */
+      if($dn != "new" && ( in_array("gosaApplicationGroup",$this->attrs['objectClass'])) && 
+         (!in_array("FAIreleaseTag",$this->attrs['objectClass']))){
+        $this->is_account =true;
+      }
+    }
+    
 
     /* Load member applications */
     if (isset ($this->attrs["gosaMemberApplication"][0])){
@@ -117,13 +144,9 @@ class appgroup extends plugin
     $this->gosaMemberApplication = $tmp;
     $this->curbase = $this->config->current['BASE'];
     
-    /* Check if we should enable the release selection 
-     */
-    $tmp = search_config($config->data,"faiManagement","CLASS");
-    if(!empty($tmp)){
-      $this->enableReleaseManagement = true;
-      $this->Release        = $this->getReleaseName();
-      $this->InitialRelease = $this->Release;
+    /* Get required release informations */
+    if($this->enableReleaseManagement){
+      $this->InitialFAIrelease = $this->FAIrelease;
       $this->Releases       = $this->getReleases();
     }
   }
@@ -165,51 +188,54 @@ class appgroup extends plugin
     /* Only diff if it is required 
      */
     $ret =array();
-  
+
     /* If current release has changed */
-    if($this->Release != $this->InitialRelease){
-  
+    if($this->FAIrelease != $this->InitialFAIrelease){
+
       /* Walk through all apps which are currently displayed */
-      foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
+      if(isset($this->gosaMemberApplication[$this->curCatDir])){
 
-        /* If application is also available in new release, check if parameter differs */
-        if(in_array($entry['App'],$this->AllAppsForRelease)){ 
+        foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
 
-          $old = array();   // Old application parameter
-          $new = array();   // New parameters 
+          /* If application is also available in new release, check if parameter differs */
+          if(in_array($entry['App'],$this->AllAppsForRelease)){ 
 
-          /* There are possibly no parameters specified */
-          if(isset($this->AllAppsForReleaseParameter[$this->InitialRelease][$entry['App']])){
-            $old = $this->AllAppsForReleaseParameter[$this->InitialRelease][$entry['App']];
-          }
+            $old = array();   // Old application parameter
+            $new = array();   // New parameters 
 
-          if(isset($this->AllAppsForReleaseParameter[$this->Release][$entry['App']])){
-            $new = $this->AllAppsForReleaseParameter[$this->Release][$entry['App']];
-          }
+            /* There are possibly no parameters specified */
+            if(isset($this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']])){
+              $old = $this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']];
+            }
 
-          /*  Both (old & new) have no gosaApplicationParameter
-           */
-          if((!isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){
-            $ret[$entry['App']] = false; 
+            if(isset($this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']])){
+              $new = $this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']];
+            }
 
-            /* Both got gosaApplicationParameter
+            /*  Both (old & new) have no gosaApplicationParameter
              */
-          }elseif((isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){
-            if(array_differs($old['gosaApplicationParameter'],$new['gosaApplicationParameter'])){
-              $ret[$entry['App']]  = true;
-            }else{
-              $ret[$entry['App']]  = false;
+            if((!isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){
+              $ret[$entry['App']] = false; 
+
+              /* Both got gosaApplicationParameter
+               */
+            }elseif((isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){
+              if(array_differs($old['gosaApplicationParameter'],$new['gosaApplicationParameter'])){
+                $ret[$entry['App']]  = true;
+              }else{
+                $ret[$entry['App']]  = false;
+              }
             }
-          }
-          /* Initialy had gosaApplicationParameter bot in new release not 
-           */
-        }elseif((isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){
-          $ret[$entry['App']]  = true;
+            /* Initialy had gosaApplicationParameter bot in new release not 
+             */
+          }elseif((isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){
+            $ret[$entry['App']]  = true;
 
-          /* Old release had no gosaApplicationParameter but new got some
-           */
-        }elseif((!isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){
-          $ret[$entry['App']]  = true;
+            /* Old release had no gosaApplicationParameter but new got some
+             */
+          }elseif((!isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){
+            $ret[$entry['App']]  = true;
+          }
         }
       }
     }
@@ -345,12 +371,9 @@ class appgroup extends plugin
     /* Call parent execute */
     plugin::execute();
 
-
     if((isset($_GET['act']))&&($_GET['act']=="depopen")){
-      $dep = base64_decode($_GET['depid']);  
-      if(isset($this->config->idepartments[$dep])){
-        $this->curbase =$dep;
-      }
+      $dep = base64_decode($_GET['depid']); 
+      $this->curbase =$dep;
     }
 
     if((isset($_GET['act']))&&($_GET['act']=="open")){
@@ -358,8 +381,12 @@ class appgroup extends plugin
     }
 
     /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
     }
 
     /* Do we represent a valid group? */
@@ -373,10 +400,10 @@ class appgroup extends plugin
     $display= "";
     if ($this->parent != NULL){
       if ($this->is_account){
-        $display= $this->show_header(_("Remove applications"),
+        $display= $this->show_disable_header(_("Remove applications"),
             _("This group has application features enabled. You can disable them by clicking below."));
       } else {
-        $display.= $this->show_header(_("Create applications"),
+        $display.= $this->show_enable_header(_("Create applications"),
             _("This group has application features disabled. You can enable them by clicking below."));
         return ($display);
       }
@@ -384,20 +411,22 @@ class appgroup extends plugin
 
 
     /* Add Categorie */ 
-
-
     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)){ 
-        if(empty($this->curCatDir)){
-          $this->Categories[$_POST['CatName']]=$_POST['CatName'];
+      /* Only allow adding a category, if it is allowed */  
+      if($this->acl_is_writeable("gosaMemberApplication")){
+
+        if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){
+          print_red(_("Invalid character in category name."));
+        }elseif(!in_array($_POST['CatName'],$this->Categories)){ 
+          if(empty($this->curCatDir)){
+            $this->Categories[$_POST['CatName']]=$_POST['CatName'];
+          }else{
+            $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
+          }
         }else{
-          $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
+          print_red(_("The specified category already exists."));
         }
-      }else{
-        print_red(_("The specified category already exists."));
       }
     }
 
@@ -406,129 +435,137 @@ class appgroup extends plugin
 
     $this->diffAppsInReleases();
     $only_once = false;
-    foreach($_POST as $name => $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))&&(!$only_once)){
-        $only_once = true;
-   
+    /* Check POST variables for commands to add/remove some applications */
+    if($this->acl_is_writeable("gosaMemberApplication")){
+      foreach($_POST as $name => $value){
 
-        if(preg_match("/DelApp___SEPARATOR__/",$name)) {
-          $n=  preg_replace("/DelApp___SEPARATOR__/","",$name);
-          $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n);
-        }else{
-          $n = preg_replace("/DelApp_/","",$name);
+        if((preg_match("/AddSep_/",$name))&&(!$only_once)){
+          $only_once = true;
+          $n = preg_replace("/AddSep_/","",$name);
           $val= preg_replace("/_.*$/","",$n);
+          $this->AddSeperator($val);
         }
 
-        foreach($this->gosaMemberApplication as $key =>  $cat){
-          foreach($cat as $key2 => $app){
-            if($app['App'] == $val){
-              unset($this->gosaMemberApplication[$key][$key2]);
-              if(isset($this->used_apps[$val])){
-                unset($this->used_apps[$val]);
+        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'] == $val){
+                unset($this->gosaMemberApplication[$key][$key2]);
+                if(isset($this->used_apps[$val])){
+                  foreach($this->getParameters($val) as $para){
+                    if(isset($this->appoption[$para])){
+                      unset($this->appoption[$para]);
+                    }
+                  }
+                  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]);    
+
+        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]);
             }
-            unset($this->Categories[$key]);
           }
         }
-      }
-      
-      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();
-
-        $tmp = search_config($this->config->data,"faiManagement","CLASS");
-        if(!empty($tmp)){
-          $tmp = array_flip($this->Releases);
-          $base = $tmp[$this->Release];
-
-          $ldap->cd($this->config->current['BASE']);
-          $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
-          $found = "";
-          while($attrs = $ldap->fetch()) {
-            if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){
-              $found = $attrs['dn'];
-            }
-          }
-          $ldap->cat($found);
-        }else{
-          $ldap->cd($this->config->current['BASE']);
-          $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
 
-        }
+        if((preg_match("/EdiApp_/",$name))&&(!$only_once)){
 
+          $only_once = true;
+          $appname = $value;
+          $appname = preg_replace("/EdiApp_/","",$name);  
+          $appname = preg_replace("/_.*$/","",$appname);
 
-        if ($ldap->count() != 1){
-          print_red (_("The selected application name is not uniq. Please check your LDAP."));
-        } else {
-          $attrs= $ldap->fetch();
-          if(isset($attrs['gosaApplicationParameter'])){
-            $this->dialog= TRUE;
-
-            /* Fill name and value arrays */
-            for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
-              $option= preg_replace('/^[^:]+:/', '',
-                  $attrs['gosaApplicationParameter'][$i]);
-              $name= preg_replace('/:.*$/', '', 
-                  $attrs['gosaApplicationParameter'][$i]);
-              $this->option_name[$i]= $name;
-
-              /* Fill with values from application, default should be
-                 loaded by the external scripts */
-              if (isset($this->appoption[$name])){
-                $this->option_value[$i]= $this->appoption[$name];
+          /* We've got the appname, get parameters from ldap 
+           */
+          $ldap= $this->config->get_ldap_link();
+
+          $tmp = search_config($this->config->data,"faiManagement","CLASS");
+          if(!empty($tmp)){
+            $tmp = array_flip($this->Releases);
+            $base = $tmp[$this->FAIrelease];
+
+            $ldap->cd($this->config->current['BASE']);
+            $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
+            $found = "";
+            while($attrs = $ldap->fetch()) {
+              if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){
+                $found = $attrs['dn'];
               }
             }
+            $ldap->cat($found, array("gosaApplicationParameter"));
+          }else{
+            $ldap->cd($this->config->current['BASE']);
+            $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
+          }
+
 
-            /* Create edit field */
-            $table= "<table summary=\"\">";
-            for ($i= 0; $i < count($this->option_name); $i++){
-              if (isset($this->option_value[$i])){
-                $value= $this->option_value[$i];
-              } else {
-                $value= "";
+          if ($ldap->count() != 1){
+            print_red (_("The selected application name is not uniq. Please check your LDAP."));
+          } else {
+            $attrs= $ldap->fetch();
+            if(isset($attrs['gosaApplicationParameter'])){
+              $this->dialog= TRUE;
+
+              /* Fill name and value arrays */
+              for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
+                $option= preg_replace('/^[^:]+:/', '',
+                    $attrs['gosaApplicationParameter'][$i]);
+                $name= preg_replace('/:.*$/', '', 
+                    $attrs['gosaApplicationParameter'][$i]);
+                $this->option_name[$i]= $name;
+
+                /* Fill with values from application, default should be
+                   loaded by the external scripts */
+                if (isset($this->appoption[$name])){
+                  $this->option_value[$i]= $this->appoption[$name];
+                }
+              }
+
+              /* Create edit field */
+              $table= "<table summary=\"\">";
+              for ($i= 0; $i < count($this->option_name); $i++){
+                if (isset($this->option_value[$i])){
+                  $value= $this->option_value[$i];
+                } else {
+                  $value= "";
+                }
+                $table.="<tr><td>".$this->option_name[$i]."</td><td>".
+                  "<input name=\"value$i\" size=60 maxlength=250 ".
+                  "value=\"".$value."\"><br></td></tr>";
               }
-              $table.="<tr><td>".$this->option_name[$i]."</td><td>".
-                "<input name=\"value$i\" size=60 maxlength=250 ".
-                "value=\"".$value."\"><br></td></tr>";
+              $table.= "</table>";
+              $this->table= $table;
+            } else {
+              print_red (_("The selected application has no options."));
             }
-            $table.= "</table>";
-            $this->table= $table;
-          } else {
-            print_red (_("The selected application has no options."));
           }
         }
       }
     }
-
+  
     $this->reload();
 
     /* Add group with post */
@@ -580,23 +617,12 @@ class appgroup extends plugin
 
     $div->SetHeight(300);
 
-    /* NEW LIST MANAGMENT
-     * We also need to search for the departments
-     * So we are able to navigate like in konquerer
-     */
-
-    //FIXME: Why do we not use get_list here? It's the same code all over the time...
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->curbase) ;
-    $ldap->ls("(objectClass=gosaDepartment)"); 
-    $departments= array();
-    $tmp = array();
-    while ($value = $ldap->fetch()){
-      $tmp[strtolower($value['dn']).$value['dn']]=$value;
-    }
-    ksort($tmp);
-    foreach($tmp as $value){
-      $fdn= @LDAP::fix($value['dn']);
+    /* get departments */  
+    $ui = get_userinfo();
+    $departments = array();
+    $res = get_list("(objectClass=gosaDepartment)", "department", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT);
+    foreach($res as $value){
+      $fdn= @LDAP::fix(str_replace($this->curbase,"",$value['dn']));
       if($value["description"][0]!=".."){
         $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]";
       }else{
@@ -604,11 +630,13 @@ class appgroup extends plugin
       }
     }
 
-    /* END NEW LIST MANAGMENT
-     */
+    if($this->acl_is_writeable("gosaMemberApplication")){
+      $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
+    }else{
+      $linkadd = "%s";
+    }
 
     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=depopen&amp;depid=%s'>%s</a>";
-    $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
 
     $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
     if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
@@ -657,13 +685,20 @@ class appgroup extends plugin
     $div2 = new DivSelectBox("appgroup");
     $div2->SetHeight(300);
 
-    $linkopen       = "<img class='center' src='images/folder.png' alt=\"\">&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
-    $catremove      = "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
-    $app            = "<img class='center' src='images/select_application.png' alt=\"\">&nbsp;%s";
-    
-    $catupdown        = "<a href='?plug=".$_GET['plug']."&amp;act=cat_up&amp;id=%s'>
-                       <img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'></a>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=cat_down&amp;id=%s'> 
-                       <img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
+    if(!$this->acl_is_writeable("gosaMemberApplication")){
+      $linkopen       = "<img class='center' src='images/folder.png' alt=\"\">&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
+      $catremove      = "&nbsp;<img src='images/empty.png' alt='&nbsp;'>";
+      $catupdown      = "";
+    }else{
+      $linkopen       = "<img class='center' src='images/folder.png' alt=\"\">&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
+      $catremove      = "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
+      $catupdown      = "<a href='?plug=".$_GET['plug']."&amp;act=cat_up&amp;id=%s'>".
+        "<img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'>".
+        "</a>&nbsp;".
+        "<a href='?plug=".$_GET['plug']."&amp;act=cat_down&amp;id=%s'>".
+        "<img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0>".
+        "</a>";
+    }
 
     if(empty($this->curCatDir)){
       $cnt =0;
@@ -690,12 +725,25 @@ class appgroup extends plugin
 
     $separator ="<hr size=1>"; 
 
-    $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
-  
-    $upudown ="<a href='?plug=".$_GET['plug']."&amp;act=one_up&amp;id=%s'>   <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
-      "&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=one_down&amp;id=%s'> <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
-      "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
-    $edit=      "&nbsp;<input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
+    if($this->acl_is_writeable("gosaMemberApplication")){
+      $sep      = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
+      $upudown  = "<a href='?plug=".$_GET['plug']."&amp;act=one_up&amp;id=%s'>".
+                  " <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0>".
+                  "</a>&nbsp;".
+                  "<a href='?plug=".$_GET['plug']."&amp;act=one_down&amp;id=%s'>".
+                  " <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0>".
+                  "</a>&nbsp;".
+                  "<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
+    }else{
+      $sep      = "";
+      $upudown  = "";
+    }
+      
+    if($this->acl_is_writeable("gosaApplicationParameter")){
+      $edit=      "&nbsp;<input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
+    }else{
+      $edit=      "";
+    }
 
     $Differences = $this->diffAppsInReleases();
 
@@ -721,7 +769,7 @@ class appgroup extends plugin
                           title='"._("This application is no longer available.")."'>&nbsp;";
             }else{
               $image = "<img class='center' src='images/select_invalid_application.png' 
-                          title='".sprintf(_("This application is not available in any release named %s."),$this->Release)."'>&nbsp;";
+                          title='".sprintf(_("This application is not available in any release named %s."),$this->FAIrelease)."'>&nbsp;";
             }
       
           }elseif(isset($Differences[$entry['App']]) && ($Differences[$entry['App']] == true)) {
@@ -746,7 +794,7 @@ class appgroup extends plugin
     $smarty->assign("enableReleaseManagement",$this->enableReleaseManagement);
  
     if($this->enableReleaseManagement){
-      $smarty->assign("Release",  $this->Release);
+      $smarty->assign("FAIrelease",  $this->FAIrelease);
       $smarty->assign("Releases", $this->Releases);
 
       if(count($this->used_apps)){
@@ -755,7 +803,13 @@ class appgroup extends plugin
         $smarty->assign("ReleaseSelectAble", true);
       }
     }
-        $smarty->assign("ReleaseSelectAble", true);
+    $smarty->assign("ReleaseSelectAble", true);
+
+    /* Set acls to  template */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $acl => $translation){
+      $smarty->assign($acl."ACL",$this->getacl($acl));
+    }
 
     /* Show main page */
     if ($this->dialog){
@@ -764,18 +818,19 @@ class appgroup extends plugin
     } else {
       $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
     }
+    
     return ($display);
   }
 
 
   function getReleases()
   {
-    $dn   = "ou=apps,".$this->config->current['BASE'];
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($dn);
-    $ldap->search("objectClass=organizationalUnit",array("ou"));
+    $dn     = $this->config->current['BASE'];
+    $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))";
+    $res    = get_list($filter,"groups", $dn, array("ou"), GL_SUBSEARCH);
+
     $ret =array();
-    while($attrs = $ldap->fetch()){
+    foreach($res as $attrs){
       if(preg_match("/ou=apps,/",$attrs['dn'])){
         $bb = preg_replace("/ou=apps,.*/","",$attrs['dn']);
         $parts = array_reverse(split("ou=",$bb));
@@ -799,9 +854,7 @@ class appgroup extends plugin
 
   function save_object()
   {
-    if(isset($_POST ['Release'])){
-      $this->Release = $_POST['Release'];
-    }
+    plugin::save_object();
   }
  
 
@@ -809,14 +862,13 @@ class appgroup extends plugin
   {
     plugin::remove_from_parent();
 
-    $this->attrs["gosaMemberApplication"]= array();
-
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
-$ldap->modify ($this->attrs); 
+    
+    $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/applications with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove");
@@ -831,6 +883,7 @@ $ldap->modify ($this->attrs);
     /* Copy members */
     $this->Categories[""]=""; 
     $this->attrs["gosaMemberApplication"]= array();
+    $this->attrs["gosaApplicationParameter"]= array();
     foreach($this->Categories as $name => $cats){
       $i =0;
       if(isset($this->gosaMemberApplication[$name])){
@@ -858,14 +911,14 @@ $ldap->modify ($this->attrs);
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
-$ldap->modify ($this->attrs); 
+    $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/applications with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
       if ($this->is_modified){
-        $this->handle_post_events("mofify");
+        $this->handle_post_events("modify");
       }
     } else {
       $this->handle_post_events("add");
@@ -894,15 +947,18 @@ $ldap->modify ($this->attrs);
       $this->enableReleaseManagement = true;
 
       $tmp = array_flip($this->Releases);
-      if(isset($tmp[$this->Release])){
-        $base =  $tmp[$this->Release];
+      if(isset($tmp[$this->FAIrelease])){
+        $base =  $tmp[$this->FAIrelease];
       }else{
+        $old_r =  $this->FAIrelease;
         $k = key($tmp);
         $r = $tmp[$k];
-        $this->Release = $k;
+        $this->FAIrelease = $k;
         $base = $r; 
-    
-        print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$this->Release,$k));
+
+        if(!(!$this->initially_was_account && $old_r =="/")){
+          print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$this->FAIrelease,$k));    
+        }
       }
 
       $base = preg_replace("/ou=apps,.*$/","ou=apps,".$this->curbase,$base);
@@ -941,9 +997,9 @@ $ldap->modify ($this->attrs);
         $testdn = preg_replace("/^[^,]+/","",$testdn);
         $testdn = preg_replace("/^,/","",$testdn);
 
-        if($testdn == preg_replace("/ou=apps,.*$/","ou=apps",$tmp[$this->Release])){
+        if($testdn == preg_replace("/ou=apps,.*$/","ou=apps",$tmp[$this->FAIrelease])){
           $this->AllAppsForRelease[$attrs['dn']] = $attrs['cn'][0];
-          $this->AllAppsForReleaseParameter[$this->Release][$attrs['cn'][0]] = $attrs;
+          $this->AllAppsForReleaseParameter[$this->FAIrelease][$attrs['cn'][0]] = $attrs;
         }
       }
     }else{
@@ -990,6 +1046,27 @@ $ldap->modify ($this->attrs);
     $this->is_modified= TRUE;
   }
 
+  function getParameters($app)
+  {
+    $tmp = $this->getReleases();
+    $ret = array();
+    if(in_array($this->FAIrelease,$tmp)){
+      $tmp2 = array_flip($tmp);
+      $base = $tmp2[$this->FAIrelease];
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gosaApplication)(cn=".$app.")(gosaApplicationParameter=*))",array("gosaApplicationParameter"));
+      if($ldap->count()){
+        $attrs = $ldap->fetch();
+        for($i = 0 ; $i < $attrs['gosaApplicationParameter']['count'] ; $i ++ ){
+          $name = preg_replace("/:.*$/","",$attrs['gosaApplicationParameter'][$i]);
+          $ret[$name] = $name;
+        } 
+      }
+    }
+    return($ret);
+  }
+
   function GetSubdirs($dir)
   {
     $ret = array();
@@ -1014,37 +1091,27 @@ $ldap->modify ($this->attrs);
         $ret[$path]=$cat;
       } 
     }
-  return($ret);
+    return($ret);
   }
 
 
-  /* Get selected release name.
-   *  it is written in the description tag 
-   *  within ... (.*)$
-   */
-  function getReleaseName()
+  /* Return plugin informations for acl handling  */ 
+  function plInfo()
   {
-  
-    if(isset($this->parent)){
-      $base = $this->parent->by_object['group'];
-    }else{
-      $base = $this;
-    }
-
-    if(isset($base->attrs['description'][0])){
-      $desc = $base->attrs['description'][0];
-    }else{
-      $desc = "";
-    }
-    if(preg_match("/\(.*\)$/",$desc)){
-      $str = preg_replace("/^.*\((.*)\)$/","\\1",$desc);
-    }else{
-      $str = "/";
-    }
-    return($str);  
+    return (array(
+          "plShortName"   => _("Applications"),
+          "plDescription" => _("Group applications"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("admin"),
+          "plCategory"    => array("groups"),
+          "plProvidedAcls"=> array(
+            "gosaMemberApplication"     => _("Application"),
+            "FAIrelease"                => _("Release"),
+            "gosaApplicationParameter"  => _("Application parameter"))
+          ));
   }
 }
-
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>