Code

Updated object movement.
[gosa.git] / plugins / admin / fai / class_faiManagement.inc
index 5dde279a3a83fb1684c77b30dc910621f142b582..629b0190d77383bd51a939402e5a36d1b5a42e09 100644 (file)
@@ -26,6 +26,7 @@ require "tabsScript.inc";
 require "tabsProfile.inc";
 require "tabsPackage.inc";
 
+
 class faiManagement extends plugin
 {
        /* Definitions */
@@ -128,20 +129,28 @@ class faiManagement extends plugin
     }
 
 
+    $type_acl_mapping = array(
+        "FAIpartitionTable"  => "faiPartitionTable", 
+        "FAIpackageList"     => "faiPackage",
+        "FAIscript"          => "faiScript",
+        "FAIvariable"        => "faiVariable",
+        "FAIhook"            => "faiHook",
+        "FAIprofile"         => "faiProfile",
+        "FAItemplate"        => "faiTemplate");
+
     /****************
       Delete confirme dialog 
      ****************/
 
                if ($s_action=="delete"){
 
-                       /* Get 'dn' from posted termlinst */
-                       $this->dn= $this->objects[$s_entry]['dn'];
+      /* Get 'dn' from posted termlinst */
+      $this->dn= $this->objects[$s_entry]['dn'];
 
                        /* Load permissions for selected 'dn' and check if
                           we're allowed to remove this 'dn' */
-                       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-                       $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
-                       if (chkacl($this->acl, "delete") == ""){
+      $acl  = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
+      if(preg_match("/d/",$acl)){
 
                                /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
                                if (($user= get_lock($this->dn)) != ""){
@@ -181,32 +190,42 @@ class faiManagement extends plugin
 
                        /* Some nice guy may send this as POST, so we've to check
                           for the permissions again. */
-                       if (chkacl($this->acl, "delete") == ""){
-
-                               /* Find out more about the object type */
-                               $ldap     = $this->config->get_ldap_link();
-                               $ldap->cat($this->dn, array('objectClass'));
-                               $attrs  = $ldap->fetch();
-                               $type     = $this->get_type($attrs);                    
-                               $this->dialog = new $type[0]($this->config,     $this->config->data['TABS'][$type[2]], $this->dn);
-                               $this->dialog->set_acl(array($this->acl));
-
-                               $this->dialog->by_object[$type[1]]->remove_from_parent ();
-                               unset ($this->dialog);
-                               gosa_log ("FAI class '".$this->dn."' has been removed");
-                               $this->dialog= NULL;
-                       } else {
 
-                               /* Normally this shouldn't be reached, send some extra
-                                  logs to notify the administrator */
-                               print_red (_("You are not allowed to delete this component!"));
-                               gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
-                                               "deletion.");
-                       }
+      /* Find out more about the object type */
+      $ldap      = $this->config->get_ldap_link();
+      $ldap->cat($this->dn, array('objectClass'));
+      $attrs   = $ldap->fetch();
+      $type      = $this->get_type($attrs);                    
+
+      $acl  = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
+      if(preg_match("/d/",$acl)){
+
+        $this->dialog = new $type[0]($this->config,    $this->config->data['TABS'][$type[2]], $this->dn,"fai");
+        $this->dialog->set_acl_base($this->dn);
+        $this->dialog->by_object[$type[1]]->remove_from_parent ();
+        unset ($this->dialog);
+        gosa_log ("FAI class '".$this->dn."' has been tagged as removed");
+        $this->dialog= NULL;
+        $to_del = clean_up_releases($this->dn);
+        save_release_changes_now();
+
+        foreach($to_del as $dn){
+          $ldap->rmdir_recursive($dn);
+          gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn));
+        }
 
-                       /* Remove lock file after successfull deletion */
-                       del_lock ($this->dn);
-               }
+      } else {
+
+        /* Normally this shouldn't be reached, send some extra
+           logs to notify the administrator */
+        print_red (_("You are not allowed to delete this component!"));
+        gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
+            "deletion.");
+      }
+
+      /* Remove lock file after successfull deletion */
+      del_lock ($this->dn);
+    }
 
 
     /****************
@@ -224,11 +243,13 @@ class faiManagement extends plugin
                        }
                        add_lock ($this->dn, $this->ui->dn);
 
-                       $this->dialog     = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn);
+                       $this->dialog     = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
+      $this->dialog->set_acl_base($this->dn);
                        $this->is_dialog  = true;
 
       if($entry['FAIstate'] == "freeze"){
-        $this->dialog->set_acl(array("*none*"))  ;
+        #$this->dialog->set_acl(array("*none*"))  ;    
+        echo "Dawn it is freezed.";
       }
                        $_SESSION['objectinfo'] = $this->dn;
                }
@@ -249,9 +270,9 @@ class faiManagement extends plugin
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
-      $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL);
-      $this->acl= get_module_permission($acl, "FAIclass", $base);
-      if (chkacl($this->acl, "delete") == ""){
+      $this->set_acl_base($base);
+      if($this->acl_is_removeable()){
+
         $smarty->assign("info", sprintf(_("You're about to delete a fai branch / freeze  '%s'."), $this->DivListFai->selectedBranch));
         return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
       } else {
@@ -272,7 +293,7 @@ class faiManagement extends plugin
 
       $br = $this->getBranches();
 
-      if(isset($br[$bb])){
+      if(isset($br[$bb]) && $this->acl_is_removeable()){
         $name = $br[$bb];
         $ldap->cd($bb);
         $ldap->recursive_remove();
@@ -339,74 +360,118 @@ class faiManagement extends plugin
      ****************/
 
     if(isset($_GET['PerformBranch'])){
-      /* Create it know */
-      $this->dispNewBranch = false;
-      $this->dispNewFreeze = false;
-      $base = $_SESSION['LASTPOST']['base'];
-      $_POST = $_SESSION['LASTPOST'];      
-      $name = $_POST['BranchName'];
 
-      $type = $_SESSION['LASTPOST']['type'];
-      $ldap = $this->config->get_ldap_link();
+      if(!$this->acl_is_createable()){
+        print_red(_("You are not allowed to create a new branch."));
+      }else{
 
-      $baseToUse = $base;
-      if($this->DivListFai->selectedBranch != "main" ){
-        $baseToUse = $this->DivListFai->selectedBranch;
-      }
-  
-      /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
-      
-      $CurrentReleases  = $this->getBranches();
-      $NewReleaseName   = $name;
-      if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) {
-        if($this->DivListFai->selectedBranch != "main"){
-          $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name;
-          $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
-        }else{
-          $NewReleaseName   = $name;
+        /* Create it know */
+        $this->dispNewBranch = false;
+        $this->dispNewFreeze = false;
+        $base = $_SESSION['LASTPOST']['base'];
+        $_POST = $_SESSION['LASTPOST'];      
+        $name = $_POST['BranchName'];
+
+        $type = $_SESSION['LASTPOST']['type'];
+        $ldap = $this->config->get_ldap_link();
+
+        $baseToUse = $base;
+        if($this->DivListFai->selectedBranch != "main" ){
+          $baseToUse = $this->DivListFai->selectedBranch;
         }
-      }
 
-      $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); 
-      $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; 
+        /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
+
+        $CurrentReleases  = $this->getBranches();
+        $NewReleaseName   = $name;
+        if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) {
+          if($this->DivListFai->selectedBranch != "main"){
+            $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name;
+            $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
+          }else{
+            $NewReleaseName   = $name;
+          }
+        }
+
+        $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); 
+        $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; 
+
+        $mimesrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,",$baseToUse); 
+        $mimedst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,","ou=".$name.",".$baseToUse) ; 
 
-      /* Print header to have styles included */
-      echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
-      echo "<body style='background-image:none;margin:3px;color:black'>";
+        /* Print header to have styles included */
+        echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+          <html>
+          <head>
+          <title></title>
+          <style type="text/css">@import url("themes/default/style.css");</style>
+          <script language="javascript" src="include/focus.js" type="text/javascript"></script>
+          </head>
+          <body style="background: none;margin:3px;color:black">
+          ';
 
-      /* Duplicate applications 
-       */
-      $ldap->cd ($appdst);
-      $ldap->recursive_remove();
-      $ldap->cd ($this->config->current['BASE']);
-      $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
 
-      /* Duplicate fai objects 
-       */
-      $ldap->cd ("ou=".$name.",".$baseToUse);
-      $ldap->recursive_remove();
-      $ldap->cd ($this->config->current['BASE']);
-      $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
+        /* Duplicate applications 
+         */
+        $ldap->cat($appsrc,array("dn")) ;
+        if($ldap->count()){
+          $ldap->cd ($appdst);
+          $ldap->recursive_remove();
+          $ldap->cd ($this->config->current['BASE']);
+          $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
+        }
+
+        /* Duplicate mime types 
+         */
+        $ldap->cat($mimesrc,array("dn")) ;
+        if($ldap->count()){
+          $ldap->cd ($appdst);
+          $ldap->recursive_remove();
+          $ldap->cd ($this->config->current['BASE']);
+          $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
+        }
+
+        $attr = array();
+        $attr['objectClass'] = array("organizationalUnit","FAIbranch");
+        $attr['ou']       = $name;
+        $attr['FAIstate'] = $type;
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->cd("ou=".$name.",".$baseToUse);
+        $ldap->cat("ou=".$name.",".$baseToUse);
+        if($ldap->count()){
+          $ldap->modify($attr);
+        }else{
+          $ldap->add($attr);
+        }
 
-      echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
-              <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
-            </form></div>";
+        /* Duplicate fai objects 
+         */
+        //      $ldap->cd ("ou=".$name.",".$baseToUse);
+        //      $ldap->recursive_remove();
+        //      $ldap->cd ($this->config->current['BASE']);
+        //      $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
 
-      /* Print footer to have valid html */
-      echo "</body></html>";
+        echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
+          <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
+          </form></div>";
 
-      $this->dispNewFreeze = false; 
+        echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
 
-      /* Postcreate */ 
+        /* Print footer to have valid html */
+        echo "</body></html>";
 
-      /* Assign possible attributes */
-      $this->lock_type  = $type; 
-      $this->lock_name  = $name; 
-      $this->lock_dn    = $baseToUse;
-      $this->postcreate();
-      exit();
-    }
+        $this->dispNewFreeze = false; 
 
+        /* Postcreate */ 
+
+        /* Assign possible attributes */
+        $this->lock_type  = $type; 
+        $this->lock_name  = $name; 
+        $this->lock_dn    = $baseToUse;
+        $this->postcreate();
+        exit();
+      }
+    }
 
     /****************
       Display dialog to enter new Branch name
@@ -444,17 +509,28 @@ class faiManagement extends plugin
                     "new_package"       =>  "FAIpackageList");
 
     if(isset($types[$s_action])){
-      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
+      $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/".$type_acl_mapping[$types[$s_action]]);
+      if(preg_match("/c/",$acl)){
+        $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
+      }else{
+        print_red(sprintf(_("You are not allowed to create a new '%s' object."),$types[$s_action]));
+      }
     }
 
     /* New Profile */
     if($s_action == "new_profile"){
       $this->dn = "new" ;
-      $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
 
-      $this->dialog = new $a_setup[0]($this->config,
-          $this->config->data['TABS'][$a_setup[2]],$this->dn);
-      $this->is_dialog = true;
+      $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/faiProfile");
+      if(preg_match("/c/",$acl)){
+        $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
+        $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
+        $this->dialog->set_acl_base($_SESSION['CurrentMainBase']);
+
+        $this->is_dialog = false;
+      }else{
+        print_red(sprintf(_("You are not allowed to create a new '%s' object."),"FAIprofile"));
+      }
     }
 
 
@@ -473,8 +549,8 @@ class faiManagement extends plugin
         $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
         $name = $this->dialog->save();
 
-        $this->dialog = new $a_setup[0]($this->config,
-            $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
+        $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
+        $this->dialog->set_acl_base($_SESSION['CurrentMainBase']);
         $this->dialog->by_object[$a_setup[1]]->cn = $name;
         $this->is_dialog = true;
       }                
@@ -511,6 +587,7 @@ class faiManagement extends plugin
                                }
                        }else{
                                $this->dialog->save();
+        save_release_changes_now();
         if (!isset($_POST['edit_apply'])){
           del_lock ($this->dn);
           unset($this->dialog);
@@ -535,25 +612,36 @@ class faiManagement extends plugin
                if(($this->dialog != NULL) && (isset($this->dialog->config))){
                        $display .= $this->dialog->execute();
                        /* Don't show buttons if tab dialog requests this */
-                       if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
-                               
-                       }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
-                               $display.= "<p style=\"text-align:right\">\n";
-                               $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
-                               $display.= "&nbsp;\n";
-        if ($this->dn != "new"){
-          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+
+      if(isset($this->dialog->current)){
+
+        $obj = $this->dialog->by_object[$this->dialog->current];
+
+        if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
+
+          $display.= "<p style=\"text-align:right\">\n";
+          $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
           $display.= "&nbsp;\n";
+          if ($this->dn != "new"){
+            $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+            $display.= "&nbsp;\n";
+          }
+          $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+          $display.= "</p>";
+        }elseif(!isset($this->dialog->current)){
+          $display.= "<p style=\"text-align:right\">\n";
+          $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
+          $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+          $display.= "</p>";
         }
-                               $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-                               $display.= "</p>";
-                       }elseif(!isset($this->dialog->current)){
-                               $display.= "<p style=\"text-align:right\">\n";
-                               $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
-                               $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-                               $display.= "</p>";
-                       }
-                       return($display);
+      }else{
+        $display.= "<p style=\"text-align:right\">\n";
+        $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
+        $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "</p>";
+
+      }
+      return($display);
                }
                
 
@@ -562,16 +650,8 @@ class faiManagement extends plugin
      ****************/
 
     /* Check if there is a snapshot dialog open */
-    $tmp = array();
-    $types = array("hooks","scripts","disk","packages","profiles","templates","variables");
-    foreach($types as $type){
-      if($this->DivListFai->selectedBranch == "main"){
-        $tmp[] = "ou=".$type.",ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
-      }else{
-        $tmp[] = "ou=".$type.",".$this->DivListFai->selectedBranch;
-      }
-    }
-    if($str = $this->showSnapshotDialog($this->DivListFai->selectedBase,$tmp)){
+    $base = $this->DivListFai->selectedBase;
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
       return($str);
     }
 
@@ -585,43 +665,49 @@ class faiManagement extends plugin
        }
 
 
+  /* Return departments, that will be included within snapshot detection */
+  function get_used_snapshot_bases()
+  {
+    $tmp = array();
+    $types = array("hooks","scripts","disk","packages","profiles","templates","variables");
+    foreach($types as $type){
+      if($this->DivListFai->selectedBranch == "main"){
+        $tmp[] = "ou=".$type.",ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
+      }else{
+        $tmp[] = "ou=".$type.",".$this->DivListFai->selectedBranch;
+      }
+    }
+    return($tmp);
+  }
+
+
   /* Get available branches for current base */
   function getBranches($base = false,$prefix = "")
   {
     $ret = array("main"=>"/");
     $ldap = $this->config->get_ldap_link();
     if(!$base){
-      $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
+      $base= $_SESSION['CurrentMainBase'];
     }
-    $ldap->ls("(objectClass=FAIbranch)",$base);
-    while($attrs = $ldap->fetch()){
-      if((isset($attrs['ou']))&&($attrs['dn']!=$base)){
-        $ret[$attrs['dn']]= $prefix.$attrs['ou'][0];
-        $ret = array_merge($ret,$this->getBranches($attrs['dn'],"".$prefix.$attrs['ou'][0]."/"));
-      }
+    $tmp = get_all_releases_from_base($base,true);
+    foreach($tmp as $dn => $name){
+      $ret[$dn]=$name;
     }
-
     return ($ret);
   }
 
   
+
   /* reload list of objects */
-       function reload()
-       {
-    /* Create a new list of FAI object 
-     * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
-     */
-    $ObjectTypes = array(
-        "FAIpartitionTable"  => array("OU"=>"ou=disk,"       , "CHKBOX"=>"ShowPartitions"),
-        "FAIpackageList"     => array("OU"=>"ou=packages,"    , "CHKBOX"=>"ShowPackages"),
-        "FAIscript"          => array("OU"=>"ou=scripts,"     , "CHKBOX"=>"ShowScripts"),
-        "FAIvariable"        => array("OU"=>"ou=variables,"   , "CHKBOX"=>"ShowVariables"),
-        "FAIhook"            => array("OU"=>"ou=hooks,"       , "CHKBOX"=>"ShowHooks"),
-        "FAIprofile"         => array("OU"=>"ou=profiles,"    , "CHKBOX"=>"ShowProfiles"),
-        "FAItemplate"        => array("OU"=>"ou=templates,"   , "CHKBOX"=>"ShowTemplates"));
-
-    /* Set base for all searches */
-    $base           = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
+  function reload()
+  {
+    /* Variable initialisation */
+    $str            = "";
+    $Regex          = $this->DivListFai->Regex;
+    $this->objects  = array();
+
+    /* Get base */
+    $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
     if($this->DivListFai->selectedBranch != "main"){
       $br = $this->getBranches();
       if(isset($br[$this->DivListFai->selectedBranch])){
@@ -631,62 +717,76 @@ class faiManagement extends plugin
       }
     }
 
-    $Regex          = $this->DivListFai->Regex;
-    $str            = "";
-    $objects        = array();
-    $this->objects  = array();
-
-    /* Walk through possible sub departments and fetch all FAI objects */
-               foreach($ObjectTypes as $type => $obj){
+    $this->lock_type = get_release_tag(get_release_dn($base));
 
-      /* Skip all unchecked types */
-      if(! $this->DivListFai->$obj['CHKBOX']){
-        continue;
+    /* Create a new list of FAI object 
+     * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
+     */
+    $ObjectTypes = array(
+        "FAIpartitionTable"  => array("OU"=>"ou=disk,"        , "CHKBOX"=>"ShowPartitions"  ,"ACL" => "faiPartitionTable"),
+        "FAIpackageList"     => array("OU"=>"ou=packages,"    , "CHKBOX"=>"ShowPackages"    ,"ACL" => "faiPackage"),
+        "FAIscript"          => array("OU"=>"ou=scripts,"     , "CHKBOX"=>"ShowScripts"     ,"ACL" => "faiScript"),
+        "FAIvariable"        => array("OU"=>"ou=variables,"   , "CHKBOX"=>"ShowVariables"   ,"ACL" => "faiVariable"),
+        "FAIhook"            => array("OU"=>"ou=hooks,"       , "CHKBOX"=>"ShowHooks"       ,"ACL" => "faiHook"),
+        "FAIprofile"         => array("OU"=>"ou=profiles,"    , "CHKBOX"=>"ShowProfiles"    ,"ACL" => "faiProfile"),
+        "FAItemplate"        => array("OU"=>"ou=templates,"   , "CHKBOX"=>"ShowTemplates"   ,"ACL" => "faiTemplate"));
+
+    $filter = "";
+    foreach($ObjectTypes as $key => $data){
+      if($this->DivListFai->$data['CHKBOX']){
+        $filter.= "(objectClass=".$key.")";
       }
+    }
+    $filter = "(&(|".$filter.")(cn=$Regex))";
+    
+    /* Get resolved release dependencies */
+    $tmp = get_all_objects_for_given_base($base,$filter);
 
-      /* Fetch objects from fai sub department */
-      $res= get_list("(&(objectClass=".$type.")(cn=$Regex))", $this->ui->subtreeACL, $obj['OU'].$base,
-            array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT);
-
-      /* Walk through objects */
-                       foreach($res as $object){
-
-        /* Prepare object */
-                               unset($object['objectClass']['count']);
-                               if(!isset($object['description'][0])){
-                                       $object['description'][0]="";
-                               }
-                               
-                               /* Clean up object informations */
-                               $obj['cn']                            = $object['cn'][0];
-                               $obj['dn']                            = $object['dn'];
-                               $obj['description']   = $object['description'][0];
-                               $obj['objectClass']   = $object['objectClass'];
-
-        /* Append type to this string, to be able to check if the selected 
-         * entry is of type 'freeze' or 'branch'
-         */
-        if(isset($object['FAIstate'])){
-          $obj['FAIstate'] = $object['FAIstate'][0];
-          $str.="|".$obj['FAIstate'];
-        }else{
-          $obj['FAIstate'] ="";
+    /* Ge listed ldap objects */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    foreach($tmp as $entry){
+
+      /* Get some more informations about the object */ 
+      $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
+      $object  = $ldap->fetch();
+
+      /* Walk through possible types */
+      foreach($ObjectTypes as $type => $rest){  
+
+        $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
+
+        if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
+
+          /* Prepare object */
+          unset($object['objectClass']['count']);
+          if(!isset($object['description'][0])){
+            $object['description'][0]="";
+          }
+
+          /* Clean up object informations */
+          $obj                  = array();
+          $obj['cn']                         = $object['cn'][0];
+          $obj['dn']                         = $object['dn'];
+          $obj['acl']                      = $acl;
+          $obj['description']   = $object['description'][0];
+          $obj['objectClass']   = $object['objectClass'];
+
+          /* Append type to this string, to be able to check if the selected 
+           * entry is of type 'freeze' or 'branch'
+           */
+          if(!isset($object['FAIstate'])){
+            $obj['FAIstate'] = $this->lock_type;
+          }else{
+            $obj['FAIstate'] = $object['FAIstate'][0]; 
+          }
+
+          $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
+          $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
         }
-                               $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
-                               $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
                        }
                }
 
-    /* Tell class what we have currently opened 
-        'main' has type '' */
-    if(preg_match("/freeze/",$str)){
-      $this->lock_type = "freeze";
-    }elseif(preg_match("/branch/",$str)){
-      $this->lock_type = "branch";
-    }else{
-      $this->lock_type = "";
-    }
-
                ksort($this->objects);
                reset ($this->objects);
        
@@ -734,12 +834,10 @@ class faiManagement extends plugin
   function CheckNewBranchName($name,$base)
   {
     $f = $this->DivListFai->selectedBranch;
-    if(empty($name)){
+    if($name == ""){
       return(false);
     }elseif(in_array($name,$this->getBranches($f))) {
       return(false);
-    }elseif(empty($name)){
-      return(false);
     }elseif(is_department_name_reserved($name,$base)){
       return(false);
     }
@@ -751,6 +849,21 @@ class faiManagement extends plugin
     $this->DivListFai->save_object();
   }
 
+
+  /* Return plugin informations for acl handling */ 
+  function plInfo()
+  {
+    return (array( 
+          "plShortName"   => _("FAI releases"),
+          "plDescription" => _("FAI release management"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),           
+          "plCategory"    => array("fai"=> array("description" => _("FAI"),
+                                                 "objectClass" => "FAIclass")),
+          "plProvidedAcls"=> array()));
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>