Code

Added sorting to FAIscripts
[gosa.git] / plugins / admin / fai / class_faiPackage.inc
index c3b84bfe1d63a60b8d17d66c5e44b92695ac33a2..e607b601697f0740f8b156f25cd1f3b5e2aee34d 100644 (file)
@@ -37,7 +37,7 @@ class faiPackage extends plugin
   var $SubObjects       = array();  // All leafobjects of this object
 
   var $FAIdebianRelease          = ""; // The selected release
-  var $FAIdebianSection          = ""; // selected section
+  var $FAIdebianSection          = array(); // selected section
   var $FAIinstallMethod          = "aptitude"; // hard coded
   var $mirror                    = ""; // selected mirror
 
@@ -55,6 +55,7 @@ class faiPackage extends plugin
   var $newDialogShown   =false;
 
   var $FAIstate         = "";
+  var $view_logged      = FALSE;
 
   var $FAIinstallMethods  = array( "install", "ninstall", "remove", 
       "dselect-upgrade", "taskinst", "taskrm",
@@ -168,9 +169,13 @@ class faiPackage extends plugin
   function execute()
   {
     /* Call parent execute */
-
     plugin::execute();
 
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","fai/".get_class($this),$this->dn);
+    }
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
@@ -191,8 +196,10 @@ class faiPackage extends plugin
 
       /* Assemble sections */
       $repos= $this->getServerInfos();
-      $this->FAIdebianSection= $repos[$this->FAIdebianRelease];
-      $this->FAIdebianSection= array_unique($this->FAIdebianSection);
+      if(isset($repos[$this->FAIdebianRelease])){
+        $this->FAIdebianSection= $repos[$this->FAIdebianRelease];
+        $this->FAIdebianSection= array_unique($this->FAIdebianSection);
+      }
 
       /* Assign Repository settings*/ 
       $this->is_account     = true;
@@ -251,7 +258,7 @@ class faiPackage extends plugin
     }
 
     /* Configuration dialog open*/
-    if((isset($_POST['Conpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages'])) && $this->acl_is_writeable("FAIdebconfInfo")){
+    if((isset($_POST['Conpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages'][0])) && $this->acl_is_writeable("FAIdebconfInfo")){
       $path = CONFIG_DIR."/fai/".$this->FAIdebianRelease."/debconf.d";
       $pkg_config = array();
       $pkg = $_POST['usedPackages'][0];
@@ -336,6 +343,8 @@ class faiPackage extends plugin
 
     prepare_to_save_FAI_object($use_dn,array(),true);
 
+    new log("remove","fai/".get_class($this),$use_dn,$this->attributes);
+
     foreach($this->ConfiguredPackages as $pkgname => $attrs){
       foreach($attrs as $name => $attr){
         $pkgdn =  "FAIvariable=".$name.",".$this->dn;
@@ -415,7 +424,8 @@ class faiPackage extends plugin
     return($a_ret);
   }
 
-  function genPkgs(){
+  function genPkgs()
+  {
     /* Generate a list off available packages for this mirror, section and release
      */
     /* Only read this file if it wasn't read before */
@@ -471,6 +481,12 @@ class faiPackage extends plugin
 
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/package list with dn '%s' failed."),$this->dn));
+    
+    if($this->initially_was_account){
+      new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      new log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
 
     /* Do object tagging */
     $this->handle_object_tagging();