Code

More speed optimizations
[gosa.git] / plugins / admin / groups / class_groupApplication.inc
index b7e18d58a5de80ee2d0f2aa584c4af45b87510d3..4a4fde162c069a21fe595b08f4b95b940961ac92 100644 (file)
@@ -39,7 +39,7 @@ class appgroup extends plugin
   var $gosaApplicationParameter ;
 
 
-  function appgroup ($config, $dn= NULL)
+  function appgroup ($config, $dn= NULL, $parent= NULL)
   {
    
     /* prepare group app for release management */ 
@@ -50,7 +50,7 @@ class appgroup extends plugin
       $this->attributes[] =  "FAIrelease";
     }
 
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
 
     /* In some case of old applikations with old release tag saving, we 
         must reassign is_account state.
@@ -371,7 +371,6 @@ 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])){
@@ -455,9 +454,15 @@ class appgroup extends plugin
 
         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]);
               }
             }
@@ -504,11 +509,10 @@ class appgroup extends plugin
               $found = $attrs['dn'];
             }
           }
-          $ldap->cat($found);
+          $ldap->cat($found, array("gosaApplicationParameter"));
         }else{
           $ldap->cd($this->config->current['BASE']);
           $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
-
         }
 
 
@@ -606,22 +610,11 @@ 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){
+    /* get departments */  
+    $ui = get_userinfo();
+    $departments = array();
+    $res = get_list("(objectClass=gosaDepartment)",$ui->subtreeACL,$this->curbase,array("description","cn","ou"),GL_SIZELIMIT);
+    foreach($res as $value){
       $fdn= @LDAP::fix($value['dn']);
       if($value["description"][0]!=".."){
         $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]";
@@ -630,9 +623,6 @@ class appgroup extends plugin
       }
     }
 
-    /* END NEW LIST MANAGMENT
-     */
-
     $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>";
 
@@ -796,10 +786,10 @@ class appgroup extends plugin
 
   function getReleases()
   {
-    $dn   = "ou=apps,".$this->config->current['BASE'];
+    $dn   = $this->config->current['BASE'];
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($dn);
-    $ldap->search("objectClass=organizationalUnit",array("ou"));
+    $ldap->search("(&(objectClass=organizationalUnit)(objectClass=FAIbranch))",array("ou"));
     $ret =array();
     while($attrs = $ldap->fetch()){
       if(preg_match("/ou=apps,/",$attrs['dn'])){
@@ -839,7 +829,7 @@ class appgroup extends plugin
     
     $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Removing application information failed"));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove");
@@ -854,6 +844,7 @@ class appgroup extends plugin
     /* 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])){
@@ -883,7 +874,7 @@ class appgroup extends plugin
     $this->cleanup();
     $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving application information failed"));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
@@ -1013,6 +1004,27 @@ class appgroup extends plugin
     $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();